index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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.device_id = ''
  192. this.current = index
  193. if (index == 0) {
  194. this.type = ''
  195. }else{
  196. for (var i = 0; i < this.icon.length; i++) {
  197. if (this.list[index].name == this.icon[i].name) {
  198. console.log(this.icon[i].id)
  199. this.type = this.icon[i].id
  200. }
  201. }
  202. }
  203. this.history()
  204. },
  205. markertap(e) {
  206. this.punctuation_did = this.facilitydatas[e.detail.markerId].d_id
  207. this.punctuation_type = this.facilitydatas[e.detail.markerId].device_type_id
  208. this.device_id = this.facilitydatas[e.detail.markerId].device_id
  209. },
  210. serTFs() {
  211. this.history()
  212. },
  213. eqinfo() { //设备信息
  214. if (this.punctuation_type == '') {
  215. uni.showToast({
  216. title: '请点击需查看的设备',
  217. duration: 2000,
  218. icon: "none"
  219. });
  220. } else {
  221. switch (this.punctuation_type) {
  222. case 2:
  223. uni.navigateTo({
  224. url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&imei=" + this.device_id
  225. })
  226. break;
  227. case 3:
  228. uni.navigateTo({
  229. url: "../cb/cbd/equip-set/historyfile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  230. })
  231. break;
  232. case 4:
  233. uni.navigateTo({
  234. url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  235. })
  236. break;
  237. case 5:
  238. uni.navigateTo({
  239. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  240. })
  241. break;
  242. case 6:
  243. // uni.navigateTo({
  244. // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  245. // })
  246. break;
  247. case 7:
  248. uni.navigateTo({
  249. url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  250. })
  251. break;
  252. case 10:
  253. uni.navigateTo({
  254. url:"../cb/xy2.0/historydatas?d_id=" + this.punctuation_did + "&device_id=" + this.device_id
  255. })
  256. break;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss">
  264. .utabs {
  265. width: 100%;
  266. position: fixed;
  267. top: 0px;
  268. z-index: 100;
  269. background-color: #FFFFFF;
  270. }
  271. .LocationAndDetails{
  272. width: 100%;
  273. height: 200rpx;
  274. position: fixed;
  275. top: 54px;
  276. .search{
  277. display: flex;
  278. input{
  279. width: 90%;
  280. font-size: 28rpx;
  281. margin-left: 40rpx;
  282. border: 1px solid #cfccc9;
  283. height: 60rpx;
  284. padding-left: 15px;
  285. box-sizing: border-box;
  286. border-radius: 60rpx;
  287. }
  288. }
  289. .Location{
  290. display: flex;
  291. margin-top: 20rpx;
  292. justify-content: space-around;
  293. .particulars_par {
  294. background-color: #F1F1F1;
  295. text-align: center;
  296. width: 40%;
  297. height: 80rpx;
  298. line-height: 80rpx;
  299. font-size: 28rpx;
  300. border-radius: 40rpx;
  301. }
  302. .particulars_ser {
  303. background-color: #57C87B;
  304. text-align: center;
  305. width: 40%;
  306. height: 80rpx;
  307. line-height: 80rpx;
  308. font-size: 28rpx;
  309. color: #FFFFFF;
  310. border-radius: 40rpx;
  311. }
  312. }
  313. }
  314. .page-section {
  315. margin-top: 144px;
  316. height: 80vh;
  317. // position: fixed;
  318. // top: 144px;
  319. .map{
  320. width: 100%;
  321. height: 100%;
  322. }
  323. }
  324. .particulars {
  325. width: 100%;
  326. height: 160rpx;
  327. position: absolute;
  328. bottom: 0;
  329. .search_btn_top {
  330. width: 100%;
  331. height: 80rpx;
  332. line-height: 80rpx;
  333. font-size: 32rpx;
  334. padding-left: 30rpx;
  335. box-sizing: border-box;
  336. }
  337. .search_btn_bot {
  338. width: 100%;
  339. display: flex;
  340. }
  341. }
  342. .distri_ser {
  343. position: absolute;
  344. bottom: 0rpx;
  345. right: 0px;
  346. width: 100%;
  347. height: 440rpx;
  348. background-color: #FFFFFF;
  349. .distri_ser_input {
  350. width: 90%;
  351. margin: 20rpx auto;
  352. display: flex;
  353. background-color: #F1F1F1;
  354. height: 60rpx;
  355. border-radius: 30rpx;
  356. padding: 10rpx 20rpx;
  357. box-sizing: border-box;
  358. input {
  359. width: 90%;
  360. font-size: 28rpx;
  361. margin-right: 20rpx;
  362. }
  363. }
  364. .distri_ser_title {
  365. width: 90%;
  366. margin: 0 auto;
  367. padding-left: 20rpx;
  368. border-left: 4rpx solid #57C87B;
  369. font-size: 28rpx;
  370. }
  371. .distri_ser_type {
  372. width: 90%;
  373. margin: 20rpx auto;
  374. display: flex;
  375. justify-content: space-around;
  376. .type_items {
  377. height: 120rpx;
  378. width: 120rpx;
  379. padding: 20rpx 0;
  380. }
  381. .type_items_bor {
  382. height: 120rpx;
  383. width: 120rpx;
  384. border: 2rpx solid #57C87B;
  385. padding: 20rpx 0;
  386. }
  387. .type_items_img {
  388. width: 70rpx;
  389. height: 70rpx;
  390. margin-left: 20rpx;
  391. }
  392. .type_items_p {
  393. font-size: 24rpx;
  394. text-align: center;
  395. }
  396. }
  397. }
  398. .search_btn {
  399. width: 100%;
  400. display: flex;
  401. .btn_f,
  402. .btn_t {
  403. width: 50%;
  404. text-align: center;
  405. height: 80rpx;
  406. line-height: 80rpx;
  407. font-size: 28rpx;
  408. }
  409. .btn_f {
  410. background-color: #F1F1F1;
  411. }
  412. .btn_t {
  413. background-color: #57C87B;
  414. color: #FFFFFF;
  415. }
  416. }
  417. </style>