index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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="LocationAndDetails">
  11. <view class="search_bot_input">
  12. <input type="text" value="" placeholder="请输入设备ID" @input="searchinput" />
  13. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  14. </view>
  15. </view>
  16. <view class="page-section page-section-gap">
  17. <map class="map" scale="3" :markers="covers" :enable-zoom="true"
  18. @markertap="markertap" >
  19. </map>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. Debounce,
  27. Throttle
  28. } from "../../util/anitthro.js"
  29. var imports = ""
  30. export default {
  31. data() {
  32. return {
  33. id: 0, // 使用 marker点击事件 需要填写id
  34. title: 'map',
  35. covers: [],
  36. list: [{
  37. name: "全部"
  38. }],
  39. current: 0,
  40. icon: [{
  41. id: '', //全部
  42. url: "../../static/images/distribution/7610e3983eb33ed5b9ad72ebdfc8ed2.png",
  43. name: "全部"
  44. },
  45. {
  46. id: 2, //杀虫灯
  47. url: "../../static/images/distribution/1bd535eb7dbb0809940030d40c64b4c.png",
  48. name: "杀虫灯"
  49. },
  50. {
  51. id: 3, //测报灯
  52. url: "../../static/images/distribution/0b551e50be351dbc14f0dd6470e3443.png",
  53. name: "测报灯"
  54. },
  55. {
  56. id: 4, //性诱测报
  57. url: "../../static/images/distribution/be5c1cfed22713a9544f020cf41c25f.png",
  58. name: "性诱测报"
  59. },
  60. {
  61. id: 5, //环境检测
  62. url: "../../static/images/distribution/8325b1b6079456ce43f952ce13d2919.png",
  63. name: "环境检测"
  64. },
  65. {
  66. id: 6, //监控设备
  67. url: "../../static/images/distribution/2eb9e550709430a1bd8178568c14785.png",
  68. name: "监控设备"
  69. },
  70. {
  71. id: 7, //孢子仪
  72. url: "../../static/images/distribution/54a96e2b0ad4efeecbd4a7b5e6deda3.png",
  73. name: "孢子仪",
  74. },
  75. {
  76. id: 10, //性诱2.0
  77. url: "../../static/images/distribution/515ea6143e0aaff4a823270c7aa00a6.png",
  78. name: "性诱2.0"
  79. },
  80. ],
  81. type: '', //设备类型
  82. typeindex: null, //设备选择
  83. device_id: '', //设备号
  84. serTF: false, //设备搜索显示隐藏
  85. punctuationTF: false, //判断是否以点击标点
  86. punctuation_id: "", //点击标点的id
  87. punctuation_did: '',
  88. punctuation_type: '',
  89. listindex:1,//以选择设备名称
  90. disstyle:{
  91. position:"absolute",
  92. bottom:"0rpx"
  93. },
  94. facilitydatas:[]
  95. }
  96. },
  97. onLoad() {
  98. this.history(this.device_id)
  99. },
  100. onShow() {
  101. this.device_id = ""
  102. this.list = [{
  103. name: "全部"
  104. }]
  105. uni.getStorage({
  106. key: "jurisdiction",
  107. success: (res) => {
  108. console.log(JSON.parse(res.data))
  109. var res = JSON.parse(res.data)
  110. for (var i = 0; i < res.length; i++) {
  111. switch (res[i].purview_name) {
  112. case "测报系统":
  113. for (var j = 0; j < res[i].children.length; j++) {
  114. var obj = {
  115. name: res[i].children[j].purview_name=="虫情测报灯"?"测报灯":res[i].children[j].purview_name
  116. }
  117. this.list.push(obj)
  118. }
  119. break;
  120. case "监控系统":
  121. for (var j = 0; j < res[i].children.length; j++) {
  122. var obj = {
  123. name: res[i].children[j].purview_name
  124. }
  125. this.list.push(obj)
  126. }
  127. break;
  128. case "环境监测系统":
  129. for (var j = 0; j < res[i].children.length; j++) {
  130. var obj = {
  131. name: res[i].children[j].purview_name
  132. }
  133. this.list.push(obj)
  134. }
  135. break;
  136. case "防治系统":
  137. for (var j = 0; j < res[i].children.length; j++) {
  138. var obj = {
  139. name: res[i].children[j].purview_name
  140. }
  141. this.list.push(obj)
  142. }
  143. break;
  144. }
  145. }
  146. for (var i = 0; i < this.icon.length; i++) {
  147. if (this.list[0].name == this.icon[i].name) {
  148. this.type = this.icon[i].id
  149. }
  150. }
  151. // this.history()
  152. },
  153. })
  154. },
  155. methods: {
  156. async history(device_id) { //获取分布位置
  157. const res = await this.$myRequest({
  158. url: '/api/api_gateway?method=home.homes.equip_map_location',
  159. data: {
  160. equip_type: this.type,
  161. device_id: device_id
  162. }
  163. })
  164. // console.log(res)
  165. this.covers = []
  166. var arr = []
  167. for (var i = 0; i < res.length; i++) {
  168. var obj = {}
  169. obj.latitude = Number(res[i].lat)
  170. obj.longitude = Number(res[i].lng)
  171. obj.id = parseInt(i)
  172. obj.title = res[i].device_name || res[i].device_id
  173. // obj.width = 30
  174. // obj.height = 30
  175. for (var j = 0; j < this.icon.length; j++) {
  176. if (res[i].device_type_id == this.icon[j].id) {
  177. obj.iconPath = this.icon[j].url
  178. }
  179. }
  180. arr.push(obj)
  181. // console.log(arr)
  182. }
  183. this.covers = arr
  184. this.facilitydatas = res
  185. if(res.length == 0){
  186. uni.showToast({
  187. title: '未查询到设备',
  188. duration: 2000,
  189. icon: "none"
  190. });
  191. }
  192. },
  193. change(index) {
  194. console.log(index)
  195. this.device_id = ''
  196. this.current = index
  197. if (index == 0) {
  198. this.type = ''
  199. }else{
  200. for (var i = 0; i < this.icon.length; i++) {
  201. if (this.list[index].name == this.icon[i].name) {
  202. console.log(this.icon[i].id)
  203. this.type = this.icon[i].id
  204. }
  205. }
  206. }
  207. this.history(this.device_id)
  208. },
  209. markertap(e) {
  210. console.log(this.facilitydatas[e.detail.markerId])
  211. this.punctuation_did = this.facilitydatas[e.detail.markerId].d_id
  212. this.punctuation_type = this.facilitydatas[e.detail.markerId].device_type_id
  213. this.device_id = this.facilitydatas[e.detail.markerId].device_id
  214. console.log(this.device_id)
  215. uni.showModal({
  216. title: '设备详情查询',
  217. content: "设备id:"+this.device_id,
  218. cancelText:"取消",
  219. confirmText:"设备详情",
  220. success:(res)=> {
  221. if (res.confirm) {
  222. this.eqinfo(this.facilitydatas[e.detail.markerId])
  223. } else if (res.cancel) {
  224. // this.serTFs()
  225. }
  226. }
  227. });
  228. },
  229. search() { //搜索
  230. this.history(imports)
  231. },
  232. searchinput(e) {
  233. console.log(e.detail.value)
  234. imports = e.detail.value
  235. console.log(imports)
  236. Debounce(() => {
  237. this.history(imports)
  238. }, 1000)()
  239. },
  240. eqinfo(item) { //设备信息
  241. if (this.punctuation_type == '') {
  242. uni.showToast({
  243. title: '请点击需查看的设备',
  244. duration: 2000,
  245. icon: "none"
  246. });
  247. } else {
  248. switch (this.punctuation_type) {
  249. case 2:
  250. uni.navigateTo({
  251. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  252. })
  253. break;
  254. // case 3:
  255. // case 4:
  256. // uni.navigateTo({
  257. // url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  258. // })
  259. // break;
  260. case 5:
  261. uni.navigateTo({
  262. url: "../environment/equipment?shebei=" +JSON.stringify(item)
  263. })
  264. break;
  265. // case 6:
  266. // // uni.navigateTo({
  267. // // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  268. // // })
  269. // break;
  270. // case 7:
  271. // uni.navigateTo({
  272. // url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  273. // })
  274. // break;
  275. case 10:
  276. uni.navigateTo({
  277. url:"../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  278. })
  279. break;
  280. default:
  281. uni.navigateTo({
  282. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  283. })
  284. break;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="scss">
  292. .utabs {
  293. width: 100%;
  294. position: fixed;
  295. top: 0px;
  296. z-index: 100;
  297. background-color: #FFFFFF;
  298. }
  299. .LocationAndDetails{
  300. width: 100%;
  301. height: 60rpx;
  302. position: fixed;
  303. top: 54px;
  304. .search_bot_input {
  305. width: 90%;
  306. height: 54rpx;
  307. background-color: #E4E4E4;
  308. border-radius: 27rpx;
  309. position: relative;
  310. box-sizing: border-box;
  311. padding-top: 8rpx;
  312. margin: 0 auto;
  313. input {
  314. width: 85%;
  315. text-indent: 1rem;
  316. font-size: 26rpx;
  317. }
  318. .icon {
  319. position: absolute;
  320. top: 8rpx;
  321. right: 26rpx;
  322. }
  323. }
  324. // background-color: #ff0;
  325. // .search{
  326. // display: flex;
  327. // input{
  328. // width: 90%;
  329. // font-size: 28rpx;
  330. // margin-left: 40rpx;
  331. // border: 1px solid #cfccc9;
  332. // height: 60rpx;
  333. // padding-left: 15px;
  334. // box-sizing: border-box;
  335. // border-radius: 60rpx;
  336. // }
  337. // }
  338. // .Location{
  339. // display: flex;
  340. // margin-top: 20rpx;
  341. // justify-content: space-around;
  342. // .particulars_par {
  343. // background-color: #F1F1F1;
  344. // text-align: center;
  345. // width: 40%;
  346. // height: 80rpx;
  347. // line-height: 80rpx;
  348. // font-size: 28rpx;
  349. // border-radius: 40rpx;
  350. // }
  351. // .particulars_ser {
  352. // background-color: #57C87B;
  353. // text-align: center;
  354. // width: 40%;
  355. // height: 80rpx;
  356. // line-height: 80rpx;
  357. // font-size: 28rpx;
  358. // color: #FFFFFF;
  359. // border-radius: 40rpx;
  360. // }
  361. // }
  362. }
  363. .page-section {
  364. margin-top: 100px;
  365. height: 95vh;
  366. .map{
  367. width: 100%;
  368. height: 100%;
  369. }
  370. }
  371. .particulars {
  372. width: 100%;
  373. height: 160rpx;
  374. position: absolute;
  375. bottom: 0;
  376. .search_btn_top {
  377. width: 100%;
  378. height: 80rpx;
  379. line-height: 80rpx;
  380. font-size: 32rpx;
  381. padding-left: 30rpx;
  382. box-sizing: border-box;
  383. }
  384. .search_btn_bot {
  385. width: 100%;
  386. display: flex;
  387. }
  388. }
  389. .distri_ser {
  390. position: absolute;
  391. bottom: 0rpx;
  392. right: 0px;
  393. width: 100%;
  394. height: 440rpx;
  395. background-color: #FFFFFF;
  396. .distri_ser_input {
  397. width: 90%;
  398. margin: 20rpx auto;
  399. display: flex;
  400. background-color: #F1F1F1;
  401. height: 60rpx;
  402. border-radius: 30rpx;
  403. padding: 10rpx 20rpx;
  404. box-sizing: border-box;
  405. input {
  406. width: 90%;
  407. font-size: 28rpx;
  408. margin-right: 20rpx;
  409. }
  410. }
  411. .distri_ser_title {
  412. width: 90%;
  413. margin: 0 auto;
  414. padding-left: 20rpx;
  415. border-left: 4rpx solid #57C87B;
  416. font-size: 28rpx;
  417. }
  418. .distri_ser_type {
  419. width: 90%;
  420. margin: 20rpx auto;
  421. display: flex;
  422. justify-content: space-around;
  423. .type_items {
  424. height: 120rpx;
  425. width: 120rpx;
  426. padding: 20rpx 0;
  427. }
  428. .type_items_bor {
  429. height: 120rpx;
  430. width: 120rpx;
  431. border: 2rpx solid #57C87B;
  432. padding: 20rpx 0;
  433. }
  434. .type_items_img {
  435. width: 70rpx;
  436. height: 70rpx;
  437. margin-left: 20rpx;
  438. }
  439. .type_items_p {
  440. font-size: 24rpx;
  441. text-align: center;
  442. }
  443. }
  444. }
  445. .search_btn {
  446. width: 100%;
  447. display: flex;
  448. .btn_f,
  449. .btn_t {
  450. width: 50%;
  451. text-align: center;
  452. height: 80rpx;
  453. line-height: 80rpx;
  454. font-size: 28rpx;
  455. }
  456. .btn_f {
  457. background-color: #F1F1F1;
  458. }
  459. .btn_t {
  460. background-color: #57C87B;
  461. color: #FFFFFF;
  462. }
  463. }
  464. </style>