index.vue 11 KB

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