index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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"
  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 = "https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/distribution/"+res[i].device_type_id+".png"
  123. arr.push(obj)
  124. }
  125. // console.log(arr)
  126. }
  127. this.covers = arr
  128. this.facilitydatas = res
  129. if (res.length == 0) {
  130. uni.showToast({
  131. title: '未查询到设备',
  132. duration: 2000,
  133. icon: "none"
  134. });
  135. }
  136. },
  137. async usertype() { //设备列表
  138. const res = await this.$myRequest({
  139. url: '/api/api_gateway?method=home.homes.user_device_type',
  140. })
  141. for (var i = 0; i < res.length; i++) {
  142. if(res[i].type_name == "性诱3.0" ||
  143. res[i].type_name == "吸虫塔" ||
  144. res[i].type_name == "病虫害可视监测" ||
  145. res[i].type_name == "小麦赤霉病" ||
  146. res[i].type_name == "温室大棚"
  147. ){
  148. continue;
  149. }
  150. var obj = {
  151. name: res[i].type_name,
  152. id: res[i].id
  153. }
  154. this.list.push(obj)
  155. }
  156. this.type = this.list[0].id
  157. this.history(this.device_id)
  158. // console.log(this.list)
  159. },
  160. change(index) {
  161. console.log(index)
  162. this.device_id = ''
  163. this.current = index
  164. for (var i = 0; i < this.icon.length; i++) {
  165. if (this.list[index].name == this.icon[i].name) {
  166. console.log(this.icon[i].id)
  167. this.type = this.icon[i].id
  168. }
  169. }
  170. console.log(this.device_id)
  171. this.history(this.device_id)
  172. },
  173. markertap(e) {
  174. console.log(this.facilitydatas[e.detail.markerId])
  175. this.punctuation_did = this.facilitydatas[e.detail.markerId].d_id
  176. this.punctuation_type = this.facilitydatas[e.detail.markerId].device_type_id
  177. this.device_id = this.facilitydatas[e.detail.markerId].device_id
  178. console.log(this.device_id)
  179. uni.showModal({
  180. title: '设备详情查询',
  181. content: "设备id:" + this.device_id,
  182. cancelText: "取消",
  183. confirmText: "设备详情",
  184. success: (res) => {
  185. if (res.confirm) {
  186. this.eqinfo(this.facilitydatas[e.detail.markerId])
  187. } else if (res.cancel) {
  188. // this.serTFs()
  189. }
  190. }
  191. });
  192. },
  193. search() { //搜索
  194. this.history(imports)
  195. },
  196. searchinput(e) {
  197. console.log(e.detail.value)
  198. imports = e.detail.value
  199. console.log(imports)
  200. Debounce(() => {
  201. this.history(imports)
  202. }, 1000)()
  203. },
  204. eqinfo(item) { //设备信息
  205. if (this.punctuation_type == '') {
  206. uni.showToast({
  207. title: '请点击需查看的设备',
  208. duration: 2000,
  209. icon: "none"
  210. });
  211. } else {
  212. switch (this.punctuation_type) {
  213. case 2:
  214. uni.navigateTo({
  215. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  216. })
  217. break;
  218. // case 3:
  219. // case 4:
  220. // uni.navigateTo({
  221. // url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  222. // })
  223. // break;
  224. case 5:
  225. uni.navigateTo({
  226. url: "../environment/equipment?shebei=" + JSON.stringify(item)
  227. })
  228. break;
  229. // case 6:
  230. // // uni.navigateTo({
  231. // // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  232. // // })
  233. // break;
  234. // case 7:
  235. // uni.navigateTo({
  236. // url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  237. // })
  238. // break;
  239. case 10:
  240. uni.navigateTo({
  241. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  242. })
  243. break;
  244. default:
  245. uni.navigateTo({
  246. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  247. })
  248. break;
  249. }
  250. }
  251. },
  252. regionchange(e) {
  253. console.log(e)
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .utabs {
  260. width: 100%;
  261. position: fixed;
  262. top: 0px;
  263. z-index: 100;
  264. background-color: #FFFFFF;
  265. }
  266. .LocationAndDetails {
  267. width: 100%;
  268. height: 60rpx;
  269. position: fixed;
  270. top: 54px;
  271. .search_bot_input {
  272. width: 90%;
  273. height: 54rpx;
  274. background-color: #E4E4E4;
  275. border-radius: 27rpx;
  276. position: relative;
  277. box-sizing: border-box;
  278. padding-top: 8rpx;
  279. margin: 0 auto;
  280. input {
  281. width: 85%;
  282. text-indent: 1rem;
  283. font-size: 26rpx;
  284. }
  285. .icon {
  286. position: absolute;
  287. top: 8rpx;
  288. right: 26rpx;
  289. }
  290. }
  291. }
  292. .page-section {
  293. margin-top: 100px;
  294. height: 95vh;
  295. .map {
  296. width: 100%;
  297. height: 100%;
  298. }
  299. }
  300. .particulars {
  301. width: 100%;
  302. height: 160rpx;
  303. position: absolute;
  304. bottom: 0;
  305. .search_btn_top {
  306. width: 100%;
  307. height: 80rpx;
  308. line-height: 80rpx;
  309. font-size: 32rpx;
  310. padding-left: 30rpx;
  311. box-sizing: border-box;
  312. }
  313. .search_btn_bot {
  314. width: 100%;
  315. display: flex;
  316. }
  317. }
  318. .distri_ser {
  319. position: absolute;
  320. bottom: 0rpx;
  321. right: 0px;
  322. width: 100%;
  323. height: 440rpx;
  324. background-color: #FFFFFF;
  325. .distri_ser_input {
  326. width: 90%;
  327. margin: 20rpx auto;
  328. display: flex;
  329. background-color: #F1F1F1;
  330. height: 60rpx;
  331. border-radius: 30rpx;
  332. padding: 10rpx 20rpx;
  333. box-sizing: border-box;
  334. input {
  335. width: 90%;
  336. font-size: 28rpx;
  337. margin-right: 20rpx;
  338. }
  339. }
  340. .distri_ser_title {
  341. width: 90%;
  342. margin: 0 auto;
  343. padding-left: 20rpx;
  344. border-left: 4rpx solid #57C87B;
  345. font-size: 28rpx;
  346. }
  347. .distri_ser_type {
  348. width: 90%;
  349. margin: 20rpx auto;
  350. display: flex;
  351. justify-content: space-around;
  352. .type_items {
  353. height: 120rpx;
  354. width: 120rpx;
  355. padding: 20rpx 0;
  356. }
  357. .type_items_bor {
  358. height: 120rpx;
  359. width: 120rpx;
  360. border: 2rpx solid #57C87B;
  361. padding: 20rpx 0;
  362. }
  363. .type_items_img {
  364. width: 70rpx;
  365. height: 70rpx;
  366. margin-left: 20rpx;
  367. }
  368. .type_items_p {
  369. font-size: 24rpx;
  370. text-align: center;
  371. }
  372. }
  373. }
  374. .search_btn {
  375. width: 100%;
  376. display: flex;
  377. .btn_f,
  378. .btn_t {
  379. width: 50%;
  380. text-align: center;
  381. height: 80rpx;
  382. line-height: 80rpx;
  383. font-size: 28rpx;
  384. }
  385. .btn_f {
  386. background-color: #F1F1F1;
  387. }
  388. .btn_t {
  389. background-color: #57C87B;
  390. color: #FFFFFF;
  391. }
  392. }
  393. </style>