index.vue 10 KB

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