index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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" font-size="24" gutter="20"
  7. bar-width="60" active-color="#42b983"></u-tabs>
  8. </view>
  9. </view>
  10. <view class="LocationAndDetails">
  11. <view class="search">
  12. <input type="text" v-model="device_id" placeholder="请输入设备ID"/>
  13. </view>
  14. <view class="Location">
  15. <view class="particulars_par" @click="eqinfo">
  16. 查看详情
  17. </view>
  18. <view class="particulars_ser" @click="serTFs">
  19. 查看位置
  20. </view>
  21. </view>
  22. </view>
  23. <view class="page-section page-section-gap">
  24. <map class="map" scale="3" :markers="covers" :enable-zoom="true"
  25. @markertap="markertap" >
  26. </map>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. id: 0, // 使用 marker点击事件 需要填写id
  36. title: 'map',
  37. covers: [],
  38. list: [{
  39. name: "全部"
  40. }],
  41. current: 0,
  42. icon: [{
  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: '', //设备类型
  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. onShow() {
  100. this.device_id = ""
  101. this.list = [{
  102. name: "全部"
  103. }]
  104. uni.getStorage({
  105. key: "jurisdiction",
  106. success: (res) => {
  107. console.log(JSON.parse(res.data))
  108. var res = JSON.parse(res.data)
  109. for (var i = 0; i < res.length; i++) {
  110. switch (res[i].purview_name) {
  111. case "测报系统":
  112. for (var j = 0; j < res[i].children.length; j++) {
  113. var obj = {
  114. name: res[i].children[j].purview_name=="虫情测报灯"?"测报灯":res[i].children[j].purview_name
  115. }
  116. this.list.push(obj)
  117. }
  118. break;
  119. case "监控系统":
  120. for (var j = 0; j < res[i].children.length; j++) {
  121. var obj = {
  122. name: res[i].children[j].purview_name
  123. }
  124. this.list.push(obj)
  125. }
  126. break;
  127. case "环境监测系统":
  128. for (var j = 0; j < res[i].children.length; j++) {
  129. var obj = {
  130. name: res[i].children[j].purview_name
  131. }
  132. this.list.push(obj)
  133. }
  134. break;
  135. case "防治系统":
  136. for (var j = 0; j < res[i].children.length; j++) {
  137. var obj = {
  138. name: res[i].children[j].purview_name
  139. }
  140. this.list.push(obj)
  141. }
  142. break;
  143. }
  144. }
  145. for (var i = 0; i < this.icon.length; i++) {
  146. if (this.list[0].name == this.icon[i].name) {
  147. this.type = this.icon[i].id
  148. }
  149. }
  150. this.history()
  151. },
  152. })
  153. },
  154. methods: {
  155. async history() { //获取分布位置
  156. const res = await this.$myRequest({
  157. url: '/api/api_gateway?method=home.homes.equip_map_location',
  158. data: {
  159. equip_type: this.type,
  160. device_id: this.device_id
  161. }
  162. })
  163. console.log(res)
  164. this.covers = []
  165. for (var i = 0; i < res.length; i++) {
  166. var obj = {}
  167. obj.latitude = Number(res[i].lat)
  168. obj.longitude = Number(res[i].lng)
  169. obj.id = parseInt(i)
  170. obj.title = res[i].device_name || res[i].device_id
  171. obj.width = 30
  172. obj.height = 30
  173. for (var j = 0; j < this.icon.length; j++) {
  174. if (res[i].device_type_id == this.icon[j].id) {
  175. obj.iconPath = this.icon[j].url
  176. }
  177. }
  178. this.covers.push(obj)
  179. }
  180. this.facilitydatas = res
  181. if(res.length == 0){
  182. uni.showToast({
  183. title: '未查询到设备',
  184. duration: 2000,
  185. icon: "none"
  186. });
  187. }
  188. },
  189. change(index) {
  190. console.log(index)
  191. this.current = index
  192. if (index == 0) {
  193. this.type = ''
  194. }else{
  195. for (var i = 0; i < this.icon.length; i++) {
  196. if (this.list[index].name == this.icon[i].name) {
  197. console.log(this.icon[i].id)
  198. this.type = this.icon[i].id
  199. }
  200. }
  201. }
  202. this.history()
  203. },
  204. markertap(e) {
  205. console.log(e)
  206. console.log(this.facilitydatas[e.detail.markerId])
  207. this.device_id = this.facilitydatas[e.detail.markerId].device_id
  208. this.punctuation_did = this.facilitydatas[e.detail.markerId].d_id
  209. this.punctuation_type = this.facilitydatas[e.detail.markerId].device_type_id
  210. },
  211. serTFs() {
  212. this.history()
  213. },
  214. eqinfo() { //设备信息
  215. if (this.punctuation_type == '') {
  216. uni.showToast({
  217. title: '请点击需查看的设备',
  218. duration: 2000,
  219. icon: "none"
  220. });
  221. } else {
  222. switch (this.punctuation_type) {
  223. case 2:
  224. uni.navigateTo({
  225. url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&imei=" + this.device_id
  226. })
  227. break;
  228. case 3:
  229. uni.navigateTo({
  230. url: "../cb/cbd/equip-set/historyfile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  231. })
  232. break;
  233. case 4:
  234. uni.navigateTo({
  235. url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  236. })
  237. break;
  238. case 5:
  239. uni.navigateTo({
  240. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  241. })
  242. break;
  243. case 6:
  244. // uni.navigateTo({
  245. // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  246. // })
  247. break;
  248. case 7:
  249. uni.navigateTo({
  250. url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  251. })
  252. break;
  253. case 10:
  254. uni.navigateTo({
  255. url:"../cb/xy2.0/historydatas?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  256. })
  257. break;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. .utabs {
  266. width: 100%;
  267. position: fixed;
  268. top: 0px;
  269. z-index: 100;
  270. background-color: #FFFFFF;
  271. }
  272. .LocationAndDetails{
  273. width: 100%;
  274. height: 200rpx;
  275. position: fixed;
  276. top: 54px;
  277. .search{
  278. display: flex;
  279. input{
  280. width: 90%;
  281. font-size: 28rpx;
  282. margin-left: 40rpx;
  283. border: 1px solid #cfccc9;
  284. height: 60rpx;
  285. padding-left: 15px;
  286. box-sizing: border-box;
  287. border-radius: 60rpx;
  288. }
  289. }
  290. .Location{
  291. display: flex;
  292. margin-top: 20rpx;
  293. justify-content: space-around;
  294. .particulars_par {
  295. background-color: #F1F1F1;
  296. text-align: center;
  297. width: 40%;
  298. height: 80rpx;
  299. line-height: 80rpx;
  300. font-size: 28rpx;
  301. border-radius: 40rpx;
  302. }
  303. .particulars_ser {
  304. background-color: #57C87B;
  305. text-align: center;
  306. width: 40%;
  307. height: 80rpx;
  308. line-height: 80rpx;
  309. font-size: 28rpx;
  310. color: #FFFFFF;
  311. border-radius: 40rpx;
  312. }
  313. }
  314. }
  315. .page-section {
  316. margin-top: 144px;
  317. height: 80vh;
  318. // position: fixed;
  319. // top: 144px;
  320. .map{
  321. width: 100%;
  322. height: 100%;
  323. }
  324. }
  325. .particulars {
  326. width: 100%;
  327. height: 160rpx;
  328. position: absolute;
  329. bottom: 0;
  330. .search_btn_top {
  331. width: 100%;
  332. height: 80rpx;
  333. line-height: 80rpx;
  334. font-size: 32rpx;
  335. padding-left: 30rpx;
  336. box-sizing: border-box;
  337. }
  338. .search_btn_bot {
  339. width: 100%;
  340. display: flex;
  341. }
  342. }
  343. .distri_ser {
  344. position: absolute;
  345. bottom: 0rpx;
  346. right: 0px;
  347. width: 100%;
  348. height: 440rpx;
  349. background-color: #FFFFFF;
  350. .distri_ser_input {
  351. width: 90%;
  352. margin: 20rpx auto;
  353. display: flex;
  354. background-color: #F1F1F1;
  355. height: 60rpx;
  356. border-radius: 30rpx;
  357. padding: 10rpx 20rpx;
  358. box-sizing: border-box;
  359. input {
  360. width: 90%;
  361. font-size: 28rpx;
  362. margin-right: 20rpx;
  363. }
  364. }
  365. .distri_ser_title {
  366. width: 90%;
  367. margin: 0 auto;
  368. padding-left: 20rpx;
  369. border-left: 4rpx solid #57C87B;
  370. font-size: 28rpx;
  371. }
  372. .distri_ser_type {
  373. width: 90%;
  374. margin: 20rpx auto;
  375. display: flex;
  376. justify-content: space-around;
  377. .type_items {
  378. height: 120rpx;
  379. width: 120rpx;
  380. padding: 20rpx 0;
  381. }
  382. .type_items_bor {
  383. height: 120rpx;
  384. width: 120rpx;
  385. border: 2rpx solid #57C87B;
  386. padding: 20rpx 0;
  387. }
  388. .type_items_img {
  389. width: 70rpx;
  390. height: 70rpx;
  391. margin-left: 20rpx;
  392. }
  393. .type_items_p {
  394. font-size: 24rpx;
  395. text-align: center;
  396. }
  397. }
  398. }
  399. .search_btn {
  400. width: 100%;
  401. display: flex;
  402. .btn_f,
  403. .btn_t {
  404. width: 50%;
  405. text-align: center;
  406. height: 80rpx;
  407. line-height: 80rpx;
  408. font-size: 28rpx;
  409. }
  410. .btn_f {
  411. background-color: #F1F1F1;
  412. }
  413. .btn_t {
  414. background-color: #57C87B;
  415. color: #FFFFFF;
  416. }
  417. }
  418. </style>