index.vue 8.5 KB

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