index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view>
  3. <view class="page-body">
  4. <view class="utabs">
  5. <view style="width: 95%;margin: 0 auto;">
  6. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" item-width="140" font-size="24" gutter="20"
  7. bar-width="60" active-color="#42b983"></u-tabs>
  8. </view>
  9. </view>
  10. <view class="page-section page-section-gap">
  11. <map style="width: 100%; height: 85vh;" scale="3" :latitude="latitude" :longitude="longitude" :markers="covers"
  12. :enable-zoom="true" @markertap="markertap">
  13. </map>
  14. </view>
  15. </view>
  16. <view class="particulars">
  17. <view class="particulars_par" @click="eqinfo">
  18. 查看详情
  19. </view>
  20. <view class="particulars_ser" @click="serTF=!serTF">
  21. 搜索
  22. </view>
  23. </view>
  24. <view class="distri_ser" v-if="serTF">
  25. <view class="distri_ser_input">
  26. <input type="number" v-model="device_id" placeholder="请输入设备ID" @confirm="doSearch" />
  27. <u-icon name="search" size="38rpx" @click="search"></u-icon>
  28. </view>
  29. <p class="distri_ser_title">请选择设备类型(点击选择)</p>
  30. <view class="distri_ser_type">
  31. <view :class="typeindex==index?'type_items_bor':'type_items'" v-for="item,index in 6" :key="index" @click="typeselect(index)">
  32. <image :src="icon[item].url" mode="" class="type_items_img"></image>
  33. <p class="type_items_p">{{list[item].name}}</p>
  34. </view>
  35. </view>
  36. <view class="search_btn">
  37. <view class="btn_f" @click="btnF">
  38. 取 消
  39. </view>
  40. <view class="btn_t" @click="btnT">
  41. 确 定
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. id: 0, // 使用 marker点击事件 需要填写id
  52. title: 'map',
  53. latitude: 39.909,
  54. longitude: 116.39742,
  55. covers: [],
  56. list: [{
  57. name: "全部"
  58. }, {
  59. name: "杀虫灯"
  60. }, {
  61. name: "测报灯"
  62. }, {
  63. name: "性诱测报"
  64. }, {
  65. name: "环境检测"
  66. }, {
  67. name: "监控设备"
  68. }, {
  69. name: "孢子仪"
  70. }],
  71. current: 0,
  72. icon: [{
  73. id: '', //全部
  74. url: "../../static/image/distribution/f38c3024bf12cd5777348593e7e5daf.png"
  75. },
  76. {
  77. id: 2, //杀虫灯
  78. url: "../../static/image/distribution/70f9fc043155ddaca85c847df2c670c.png"
  79. },
  80. {
  81. id: 3, //测报灯
  82. url: "../../static/image/distribution/621d60f8f64bbe1462e47b4a26635eb.png"
  83. },
  84. {
  85. id: 4, //性诱测报
  86. url: "../../static/image/distribution/b7f317cb75082eac43ee4dd84e5156e.png"
  87. },
  88. {
  89. id: 5, //环境检测
  90. url: "../../static/image/distribution/3a4b76ff573ebed04f29b408986cb56.png"
  91. },
  92. {
  93. id: 6, //监控设备
  94. url: "../../static/image/distribution/c792f8b4befeaa06824f988ac8c9ddc.png"
  95. },
  96. {
  97. id: 7, //孢子仪
  98. url: "../../static/image/distribution/14b9bc2ef553b53872389c22a537baf.png"
  99. },
  100. ],
  101. type: '', //设备类型
  102. typeindex: null, //设备选择
  103. device_id: '', //设备号
  104. serTF: false, //设备搜索显示隐藏
  105. punctuationTF: false, //判断是否以点击标点
  106. punctuation_id: "", //点击标点的id
  107. punctuation_did: '',
  108. punctuation_type: ''
  109. }
  110. },
  111. onLoad() {
  112. this.history()
  113. },
  114. methods: {
  115. async history() { //获取分布位置
  116. const res = await this.$myRequest({
  117. url: '/api/api_gateway?method=home.homes.equip_map_location',
  118. data: {
  119. equip_type: this.type,
  120. device_id: this.device_id
  121. }
  122. })
  123. this.covers = []
  124. for (var i = 0; i < res.length; i++) {
  125. var obj = {}
  126. obj.latitude = res[i].lat
  127. obj.longitude = res[i].lng
  128. obj.id = [res[i].device_id, res[i].d_id, res[i].device_type_id]
  129. obj.title = res[i].device_name
  130. for (var j = 0; j < this.icon.length; j++) {
  131. if (res[i].device_type_id == this.icon[j].id) {
  132. obj.iconPath = this.icon[j].url
  133. }
  134. }
  135. this.covers.push(obj)
  136. }
  137. console.log(res)
  138. },
  139. change(index) {
  140. this.current = index
  141. if (index == 0) {
  142. this.type = ''
  143. } else {
  144. this.type = index + 1
  145. }
  146. this.history()
  147. },
  148. markertap(e) {
  149. this.punctuation_id = e.detail.markerId[0]
  150. this.punctuation_did = e.detail.markerId[1]
  151. this.punctuation_type = e.detail.markerId[2]
  152. },
  153. typeselect(index) { //选择设备类型
  154. this.typeindex = index
  155. this.type = this.icon[index + 1].id
  156. console.log(this.type)
  157. },
  158. doSearch() { //按下回车键
  159. this.search()
  160. },
  161. search() { //点击搜索
  162. // this.history()
  163. if (this.type == '') {
  164. uni.showToast({
  165. title: '请选择设备类型',
  166. duration: 2000,
  167. icon: "none"
  168. });
  169. } else {
  170. this.history()
  171. this.serTF = !this.serTF
  172. }
  173. },
  174. btnF() { //确定
  175. this.serTF = !this.serTF
  176. },
  177. btnT() { //取消
  178. this.search()
  179. },
  180. eqinfo() { //设备信息
  181. if (this.punctuation_id == '') {
  182. uni.showToast({
  183. title: '请点击需查看的设备',
  184. duration: 2000,
  185. icon: "none"
  186. });
  187. } else {
  188. switch (this.punctuation_type) {
  189. case 2:
  190. uni.navigateTo({
  191. url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  192. })
  193. break;
  194. case 3:
  195. uni.navigateTo({
  196. url: "../cb/cbd/equip-set/historyfile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  197. })
  198. break;
  199. case 4:
  200. uni.navigateTo({
  201. url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  202. })
  203. break;
  204. case 5:
  205. uni.navigateTo({
  206. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  207. })
  208. break;
  209. case 6:
  210. // uni.navigateTo({
  211. // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  212. // })
  213. break;
  214. case 7:
  215. uni.navigateTo({
  216. url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  217. })
  218. break;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss">
  226. .utabs {
  227. width: 100%;
  228. position: fixed;
  229. top: 44px;
  230. z-index: 100;
  231. background-color: #FFFFFF;
  232. }
  233. .particulars {
  234. position: absolute;
  235. bottom: 0rpx;
  236. right: 0rpx;
  237. width: 160rpx;
  238. text-align: center;
  239. color: #FFFFFF;
  240. .particulars_par {
  241. background-color: #35A478;
  242. height: 60rpx;
  243. padding: 10rpx 20rpx;
  244. width: 100%;
  245. box-sizing: border-box;
  246. font-size: 24rpx;
  247. }
  248. .particulars_ser {
  249. margin-top: 10rpx;
  250. background-color: #35A478;
  251. height: 60rpx;
  252. padding: 10rpx 20rpx;
  253. width: 100%;
  254. box-sizing: border-box;
  255. font-size: 24rpx;
  256. }
  257. }
  258. .distri_ser {
  259. position: absolute;
  260. bottom: 17rpx;
  261. right: 0px;
  262. width: 100%;
  263. height: 400rpx;
  264. background-color: #FFFFFF;
  265. .distri_ser_input {
  266. width: 90%;
  267. margin: 20rpx auto;
  268. display: flex;
  269. background-color: #F1F1F1;
  270. height: 60rpx;
  271. border-radius: 30rpx;
  272. padding: 10rpx 20rpx;
  273. box-sizing: border-box;
  274. input {
  275. width: 90%;
  276. font-size: 28rpx;
  277. margin-right: 20rpx;
  278. }
  279. }
  280. .distri_ser_title {
  281. width: 90%;
  282. margin: 0 auto;
  283. padding-left: 20rpx;
  284. border-left: 4rpx solid #57C87B;
  285. font-size: 28rpx;
  286. }
  287. .distri_ser_type {
  288. width: 90%;
  289. margin: 20rpx auto;
  290. display: flex;
  291. justify-content: space-around;
  292. .type_items {
  293. height: 120rpx;
  294. width: 120rpx;
  295. padding: 20rpx 0;
  296. }
  297. .type_items_bor {
  298. height: 120rpx;
  299. width: 120rpx;
  300. border: 2rpx solid #57C87B;
  301. padding: 20rpx 0;
  302. }
  303. .type_items_img {
  304. width: 70rpx;
  305. height: 70rpx;
  306. margin-left: 20rpx;
  307. }
  308. .type_items_p {
  309. font-size: 24rpx;
  310. text-align: center;
  311. }
  312. }
  313. }
  314. .search_btn {
  315. width: 100%;
  316. display: flex;
  317. .btn_f,
  318. .btn_t {
  319. width: 50%;
  320. text-align: center;
  321. height: 80rpx;
  322. line-height: 80rpx;
  323. font-size: 28rpx;
  324. }
  325. .btn_f {
  326. background-color: #F1F1F1;
  327. }
  328. .btn_t {
  329. background-color: #57C87B;
  330. color: #FFFFFF;
  331. }
  332. }
  333. </style>