index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. console.log(e)
  150. this.punctuation_id = e.detail.markerId[0]
  151. this.punctuation_did = e.detail.markerId[1]
  152. this.punctuation_type = e.detail.markerId[2]
  153. },
  154. typeselect(index) { //选择设备类型
  155. this.typeindex = index
  156. this.type = this.icon[index + 1].id
  157. console.log(this.type)
  158. },
  159. doSearch() { //按下回车键
  160. this.search()
  161. },
  162. search() { //点击搜索
  163. // this.history()
  164. if (this.type == '') {
  165. uni.showToast({
  166. title: '请选择设备类型',
  167. duration: 2000,
  168. icon: "none"
  169. });
  170. } else {
  171. this.history()
  172. this.serTF = !this.serTF
  173. }
  174. },
  175. btnF() { //确定
  176. this.serTF = !this.serTF
  177. },
  178. btnT() { //取消
  179. this.search()
  180. },
  181. eqinfo() { //设备信息
  182. if (this.punctuation_id == '') {
  183. uni.showToast({
  184. title: '请点击需查看的设备',
  185. duration: 2000,
  186. icon: "none"
  187. });
  188. } else {
  189. switch (this.punctuation_type) {
  190. case 2:
  191. uni.navigateTo({
  192. url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  193. })
  194. break;
  195. case 3:
  196. uni.navigateTo({
  197. url: "../cb/cbd/equip-set/historyfile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  198. })
  199. break;
  200. case 4:
  201. uni.navigateTo({
  202. url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  203. })
  204. break;
  205. case 5:
  206. uni.navigateTo({
  207. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  208. })
  209. break;
  210. case 6:
  211. // uni.navigateTo({
  212. // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  213. // })
  214. break;
  215. case 7:
  216. uni.navigateTo({
  217. url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  218. })
  219. break;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss">
  227. .utabs {
  228. width: 100%;
  229. position: fixed;
  230. top: 44px;
  231. z-index: 100;
  232. background-color: #FFFFFF;
  233. }
  234. .particulars {
  235. position: absolute;
  236. bottom: 0rpx;
  237. right: 0rpx;
  238. width: 160rpx;
  239. text-align: center;
  240. color: #FFFFFF;
  241. .particulars_par {
  242. background-color: #35A478;
  243. height: 60rpx;
  244. padding: 10rpx 20rpx;
  245. width: 100%;
  246. box-sizing: border-box;
  247. font-size: 24rpx;
  248. }
  249. .particulars_ser {
  250. margin-top: 10rpx;
  251. background-color: #35A478;
  252. height: 60rpx;
  253. padding: 10rpx 20rpx;
  254. width: 100%;
  255. box-sizing: border-box;
  256. font-size: 24rpx;
  257. }
  258. }
  259. .distri_ser {
  260. position: absolute;
  261. bottom: 17rpx;
  262. right: 0px;
  263. width: 100%;
  264. height: 400rpx;
  265. background-color: #FFFFFF;
  266. .distri_ser_input {
  267. width: 90%;
  268. margin: 20rpx auto;
  269. display: flex;
  270. background-color: #F1F1F1;
  271. height: 60rpx;
  272. border-radius: 30rpx;
  273. padding: 10rpx 20rpx;
  274. box-sizing: border-box;
  275. input {
  276. width: 90%;
  277. font-size: 28rpx;
  278. margin-right: 20rpx;
  279. }
  280. }
  281. .distri_ser_title {
  282. width: 90%;
  283. margin: 0 auto;
  284. padding-left: 20rpx;
  285. border-left: 4rpx solid #57C87B;
  286. font-size: 28rpx;
  287. }
  288. .distri_ser_type {
  289. width: 90%;
  290. margin: 20rpx auto;
  291. display: flex;
  292. justify-content: space-around;
  293. .type_items {
  294. height: 120rpx;
  295. width: 120rpx;
  296. padding: 20rpx 0;
  297. }
  298. .type_items_bor {
  299. height: 120rpx;
  300. width: 120rpx;
  301. border: 2rpx solid #57C87B;
  302. padding: 20rpx 0;
  303. }
  304. .type_items_img {
  305. width: 70rpx;
  306. height: 70rpx;
  307. margin-left: 20rpx;
  308. }
  309. .type_items_p {
  310. font-size: 24rpx;
  311. text-align: center;
  312. }
  313. }
  314. }
  315. .search_btn {
  316. width: 100%;
  317. display: flex;
  318. .btn_f,
  319. .btn_t {
  320. width: 50%;
  321. text-align: center;
  322. height: 80rpx;
  323. line-height: 80rpx;
  324. font-size: 28rpx;
  325. }
  326. .btn_f {
  327. background-color: #F1F1F1;
  328. }
  329. .btn_t {
  330. background-color: #57C87B;
  331. color: #FFFFFF;
  332. }
  333. }
  334. </style>