index.vue 11 KB

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