index.vue 11 KB

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