index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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" :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. url: "../../static/images/distribution/1bd535eb7dbb0809940030d40c64b4c.png",
  50. name: "杀虫灯"
  51. },
  52. {
  53. id: 3, //测报灯
  54. url: "../../static/images/distribution/0b551e50be351dbc14f0dd6470e3443.png",
  55. name: "测报灯"
  56. },
  57. {
  58. id: 4, //性诱测报
  59. url: "../../static/images/distribution/be5c1cfed22713a9544f020cf41c25f.png",
  60. name: "性诱测报"
  61. },
  62. {
  63. id: 5, //环境检测
  64. url: "../../static/images/distribution/8325b1b6079456ce43f952ce13d2919.png",
  65. name: "环境监测"
  66. },
  67. {
  68. id: 6, //监控设备
  69. url: "../../static/images/distribution/2eb9e550709430a1bd8178568c14785.png",
  70. name: "监控设备"
  71. },
  72. {
  73. id: 7, //孢子仪
  74. url: "../../static/images/distribution/54a96e2b0ad4efeecbd4a7b5e6deda3.png",
  75. name: "孢子仪",
  76. },
  77. {
  78. id: 10, //性诱2.0
  79. url: "../../static/images/distribution/515ea6143e0aaff4a823270c7aa00a6.png",
  80. name: "性诱2.0"
  81. },
  82. ],
  83. type: '5', //设备类型
  84. typeindex: null, //设备选择
  85. device_id: '', //设备号
  86. serTF: false, //设备搜索显示隐藏
  87. punctuationTF: false, //判断是否以点击标点
  88. punctuation_id: "", //点击标点的id
  89. punctuation_did: '',
  90. punctuation_type: '',
  91. listindex: 1, //以选择设备名称
  92. disstyle: {
  93. position: "absolute",
  94. bottom: "0rpx"
  95. },
  96. facilitydatas: [],
  97. }
  98. },
  99. onLoad() {
  100. this.device_id = ""
  101. this.usertype()
  102. },
  103. methods: {
  104. async history() { //获取分布位置
  105. const res = await this.$myRequest({
  106. url: '/api/api_gateway?method=home.homes.equip_map_location',
  107. data: {
  108. equip_type: this.type,
  109. device_id: this.device_id
  110. }
  111. })
  112. console.log(res)
  113. this.covers = []
  114. var arr = []
  115. for (var i = 0; i < res.length; i++) {
  116. if (res[i].lat !== "" && res[i].lng !== "") {
  117. // if (i < 2000) {
  118. var obj = {}
  119. obj.latitude = Number(res[i].lat)
  120. obj.longitude = Number(res[i].lng)
  121. obj.id = parseInt(i)
  122. obj.title = res[i].device_name || res[i].device_id
  123. obj.width = 30
  124. obj.height = 30
  125. obj.joinCluster = true
  126. // for (var j = 0; j < this.icon.length; j++) {
  127. // if (res[i].device_type_id == this.icon[j].id) {
  128. // obj.iconPath = this.icon[j].url
  129. // }
  130. // }
  131. // this.covers.push(obj)
  132. arr.push(obj)
  133. // }
  134. }
  135. }
  136. this.covers = arr
  137. this.facilitydatas = res
  138. if (res.length == 0) {
  139. uni.showToast({
  140. title: '未查询到设备',
  141. duration: 2000,
  142. icon: "none"
  143. });
  144. }
  145. },
  146. async usertype() { //设备列表
  147. const res = await this.$myRequest({
  148. url: '/api/api_gateway?method=home.homes.user_device_type',
  149. })
  150. for (var i = 0; i < res.length; i++) {
  151. if (res[i].type_name == "性诱3.0" ||
  152. res[i].type_name == "吸虫塔" ||
  153. res[i].type_name == "病虫害可视监测" ||
  154. res[i].type_name == "小麦赤霉病" ||
  155. res[i].type_name == "温室大棚"
  156. ) {
  157. continue;
  158. }
  159. var obj = {
  160. name: res[i].type_name,
  161. id: res[i].id
  162. }
  163. this.list.push(obj)
  164. }
  165. this.type = this.list[0].id
  166. this.history(this.device_id)
  167. // console.log(this.list)
  168. },
  169. change(index) {
  170. console.log(index)
  171. this.device_id = ""
  172. this.current = index
  173. for (var i = 0; i < this.icon.length; i++) {
  174. if (this.list[index].name == this.icon[i].name) {
  175. console.log(this.icon[i].id)
  176. this.type = this.icon[i].id
  177. }
  178. }
  179. this.history()
  180. },
  181. markertap(e) {
  182. console.log(e)
  183. console.log(this.facilitydatas[e.detail.markerId])
  184. this.device_id = this.facilitydatas[e.detail.markerId].device_id
  185. this.punctuation_did = this.facilitydatas[e.detail.markerId].d_id
  186. this.punctuation_type = this.facilitydatas[e.detail.markerId].device_type_id
  187. uni.showModal({
  188. title: '设备详情查询',
  189. content: "设备id:" + this.device_id,
  190. cancelText: "取消",
  191. confirmText: "设备详情",
  192. success: (res) => {
  193. if (res.confirm) {
  194. this.eqinfo(this.facilitydatas[e.detail.markerId])
  195. } else if (res.cancel) {
  196. // this.serTFs()
  197. }
  198. }
  199. });
  200. },
  201. serTFs() {
  202. this.history()
  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 5:
  219. uni.navigateTo({
  220. url: "../environment/equipment?shebei=" + JSON.stringify(item)
  221. })
  222. break;
  223. case 10:
  224. uni.navigateTo({
  225. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  226. })
  227. break;
  228. default:
  229. uni.navigateTo({
  230. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  231. })
  232. break;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss">
  240. .utabs {
  241. width: 100%;
  242. position: fixed;
  243. top: 0px;
  244. z-index: 100;
  245. background-color: #FFFFFF;
  246. }
  247. .LocationAndDetails {
  248. width: 100%;
  249. height: 60rpx;
  250. position: fixed;
  251. top: 54px;
  252. .search_bot_input {
  253. width: 90%;
  254. height: 54rpx;
  255. background-color: #E4E4E4;
  256. border-radius: 27rpx;
  257. position: relative;
  258. box-sizing: border-box;
  259. padding-top: 8rpx;
  260. margin: 0 auto;
  261. input {
  262. width: 85%;
  263. // text-indent: 1rem;
  264. font-size: 26rpx;
  265. padding-left: 40rpx;
  266. box-sizing: border-box;
  267. }
  268. .icon {
  269. position: absolute;
  270. top: 8rpx;
  271. right: 26rpx;
  272. }
  273. }
  274. // .Location{
  275. // display: flex;
  276. // margin-top: 20rpx;
  277. // justify-content: space-around;
  278. // .particulars_par {
  279. // background-color: #F1F1F1;
  280. // text-align: center;
  281. // width: 40%;
  282. // height: 80rpx;
  283. // line-height: 80rpx;
  284. // font-size: 28rpx;
  285. // border-radius: 40rpx;
  286. // }
  287. // .particulars_ser {
  288. // background-color: #57C87B;
  289. // text-align: center;
  290. // width: 40%;
  291. // height: 80rpx;
  292. // line-height: 80rpx;
  293. // font-size: 28rpx;
  294. // color: #FFFFFF;
  295. // border-radius: 40rpx;
  296. // }
  297. // }
  298. }
  299. .page-section {
  300. margin-top: 100px;
  301. height: 80vh;
  302. // position: fixed;
  303. // top: 144px;
  304. .map {
  305. width: 100%;
  306. height: 100%;
  307. }
  308. }
  309. .particulars {
  310. width: 100%;
  311. height: 160rpx;
  312. position: absolute;
  313. bottom: 0;
  314. .search_btn_top {
  315. width: 100%;
  316. height: 80rpx;
  317. line-height: 80rpx;
  318. font-size: 32rpx;
  319. padding-left: 30rpx;
  320. box-sizing: border-box;
  321. }
  322. .search_btn_bot {
  323. width: 100%;
  324. display: flex;
  325. }
  326. }
  327. .distri_ser {
  328. position: absolute;
  329. bottom: 0rpx;
  330. right: 0px;
  331. width: 100%;
  332. height: 440rpx;
  333. background-color: #FFFFFF;
  334. .distri_ser_input {
  335. width: 90%;
  336. margin: 20rpx auto;
  337. display: flex;
  338. background-color: #F1F1F1;
  339. height: 60rpx;
  340. border-radius: 30rpx;
  341. padding: 10rpx 20rpx;
  342. box-sizing: border-box;
  343. input {
  344. width: 90%;
  345. font-size: 28rpx;
  346. margin-right: 20rpx;
  347. }
  348. }
  349. .distri_ser_title {
  350. width: 90%;
  351. margin: 0 auto;
  352. padding-left: 20rpx;
  353. border-left: 4rpx solid #57C87B;
  354. font-size: 28rpx;
  355. }
  356. .distri_ser_type {
  357. width: 90%;
  358. margin: 20rpx auto;
  359. display: flex;
  360. justify-content: space-around;
  361. .type_items {
  362. height: 120rpx;
  363. width: 120rpx;
  364. padding: 20rpx 0;
  365. }
  366. .type_items_bor {
  367. height: 120rpx;
  368. width: 120rpx;
  369. border: 2rpx solid #57C87B;
  370. padding: 20rpx 0;
  371. }
  372. .type_items_img {
  373. width: 70rpx;
  374. height: 70rpx;
  375. margin-left: 20rpx;
  376. }
  377. .type_items_p {
  378. font-size: 24rpx;
  379. text-align: center;
  380. }
  381. }
  382. }
  383. .search_btn {
  384. width: 100%;
  385. display: flex;
  386. .btn_f,
  387. .btn_t {
  388. width: 50%;
  389. text-align: center;
  390. height: 80rpx;
  391. line-height: 80rpx;
  392. font-size: 28rpx;
  393. }
  394. .btn_f {
  395. background-color: #F1F1F1;
  396. }
  397. .btn_t {
  398. background-color: #57C87B;
  399. color: #FFFFFF;
  400. }
  401. }
  402. </style>