index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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="page-section page-section-gap">
  11. <map :style="style" scale="3" :latitude="latitude" :longitude="longitude" :markers="covers" :enable-zoom="true"
  12. @markertap="markertap" :include-points="covers">
  13. </map>
  14. <view class="particulars">
  15. <view class="search_btn_top">
  16. 已点击设备:{{punctuation_id || "无"}}
  17. </view>
  18. <view class="search_btn_bot">
  19. <view class="particulars_par" @click="eqinfo">
  20. 查看详情
  21. </view>
  22. <view class="particulars_ser" @click="serTFs">
  23. 搜索
  24. </view>
  25. </view>
  26. </view>
  27. <view class="distri_ser" v-if="serTF">
  28. <view class="distri_ser_input">
  29. <input type="number" v-model="device_id" placeholder="请输入设备ID" @confirm="doSearch" />
  30. <u-icon name="search" size="38rpx" @click="search"></u-icon>
  31. </view>
  32. <p class="distri_ser_title">请选择设备类型(点击选择)</p>
  33. <view class="distri_ser_type">
  34. <view :class="typeindex==index?'type_items_bor':'type_items'" v-for="item,index in 6" :key="index" @click="typeselect(index)">
  35. <image :src="icon[item].url" mode="" class="type_items_img"></image>
  36. <p class="type_items_p">{{list[item].name}}</p>
  37. </view>
  38. </view>
  39. <view class="search_btn">
  40. <view class="btn_f" @click="btnF">
  41. 取 消
  42. </view>
  43. <view class="btn_t" @click="btnT">
  44. 确 定
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. id: 0, // 使用 marker点击事件 需要填写id
  57. title: 'map',
  58. latitude: 39.909,
  59. longitude: 116.39742,
  60. covers: [],
  61. list: [{
  62. name: "全部"
  63. }, {
  64. name: "杀虫灯"
  65. }, {
  66. name: "测报灯"
  67. }, {
  68. name: "性诱测报"
  69. }, {
  70. name: "环境检测"
  71. }, {
  72. name: "监控设备"
  73. }, {
  74. name: "孢子仪"
  75. }],
  76. current: 0,
  77. icon: [{
  78. id: '', //全部
  79. url: "../../static/image/distribution/7610e3983eb33ed5b9ad72ebdfc8ed2.png"
  80. },
  81. {
  82. id: 2, //杀虫灯
  83. url: "../../static/image/distribution/1bd535eb7dbb0809940030d40c64b4c.png"
  84. },
  85. {
  86. id: 3, //测报灯
  87. url: "../../static/image/distribution/0b551e50be351dbc14f0dd6470e3443.png"
  88. },
  89. {
  90. id: 4, //性诱测报
  91. url: "../../static/image/distribution/e19abf8bb442aefd6208f9c4687b57d.png"
  92. },
  93. {
  94. id: 5, //环境检测
  95. url: "../../static/image/distribution/8325b1b6079456ce43f952ce13d2919.png"
  96. },
  97. {
  98. id: 6, //监控设备
  99. url: "../../static/image/distribution/2eb9e550709430a1bd8178568c14785.png"
  100. },
  101. {
  102. id: 7, //孢子仪
  103. url: "../../static/image/distribution/54a96e2b0ad4efeecbd4a7b5e6deda3.png"
  104. },
  105. ],
  106. type: '', //设备类型
  107. typeindex: null, //设备选择
  108. device_id: '', //设备号
  109. serTF: false, //设备搜索显示隐藏
  110. punctuationTF: false, //判断是否以点击标点
  111. punctuation_id: "", //点击标点的id
  112. punctuation_did: '',
  113. punctuation_type: '',
  114. style: {
  115. width: "100%",
  116. height: "85%",
  117. }
  118. }
  119. },
  120. onLoad() {
  121. this.history()
  122. },
  123. methods: {
  124. async history() { //获取分布位置
  125. const res = await this.$myRequest({
  126. url: '/api/api_gateway?method=home.homes.equip_map_location',
  127. data: {
  128. equip_type: this.type,
  129. device_id: this.device_id
  130. }
  131. })
  132. console.log(res)
  133. this.covers = []
  134. for (var i = 0; i < res.length; i++) {
  135. var obj = {}
  136. obj.latitude = res[i].lat
  137. obj.longitude = res[i].lng
  138. obj.id = [res[i].device_id, res[i].d_id, res[i].device_type_id]
  139. obj.title = res[i].device_name || res[i].device_id
  140. // obj.width = 25
  141. for (var j = 0; j < this.icon.length; j++) {
  142. if (res[i].device_type_id == this.icon[j].id) {
  143. obj.iconPath = this.icon[j].url
  144. }
  145. }
  146. this.covers.push(obj)
  147. }
  148. console.log(res)
  149. },
  150. change(index) {
  151. this.current = index
  152. if (index == 0) {
  153. this.type = ''
  154. } else {
  155. this.type = index + 1
  156. }
  157. this.history()
  158. },
  159. markertap(e) {
  160. console.log(e)
  161. this.punctuation_id = e.detail.markerId[0]
  162. this.punctuation_did = e.detail.markerId[1]
  163. this.punctuation_type = e.detail.markerId[2]
  164. },
  165. typeselect(index) { //选择设备类型
  166. this.typeindex = index
  167. this.type = this.icon[index + 1].id
  168. console.log(this.type)
  169. },
  170. doSearch() { //按下回车键
  171. this.search()
  172. },
  173. search() { //点击搜索
  174. // this.history()
  175. if (this.type == '') {
  176. uni.showToast({
  177. title: '请选择设备类型',
  178. duration: 2000,
  179. icon: "none"
  180. });
  181. } else {
  182. this.history()
  183. this.serTF = !this.serTF
  184. }
  185. },
  186. serTFs() {
  187. this.serTF = !this.serTF
  188. this.style.height = "65%"
  189. },
  190. btnF() { //取消
  191. this.serTF = !this.serTF
  192. this.style.height = "85%"
  193. },
  194. btnT() { //确定
  195. this.search()
  196. },
  197. eqinfo() { //设备信息
  198. if (this.punctuation_id == '') {
  199. uni.showToast({
  200. title: '请点击需查看的设备',
  201. duration: 2000,
  202. icon: "none"
  203. });
  204. } else {
  205. switch (this.punctuation_type) {
  206. case 2:
  207. uni.navigateTo({
  208. url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&imei=" + this.punctuation_id
  209. })
  210. break;
  211. case 3:
  212. uni.navigateTo({
  213. url: "../cb/cbd/equip-set/historyfile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  214. })
  215. break;
  216. case 4:
  217. uni.navigateTo({
  218. url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  219. })
  220. break;
  221. case 5:
  222. uni.navigateTo({
  223. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  224. })
  225. break;
  226. case 6:
  227. // uni.navigateTo({
  228. // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  229. // })
  230. break;
  231. case 7:
  232. uni.navigateTo({
  233. url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  234. })
  235. break;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. </script>
  242. <style lang="scss">
  243. .utabs {
  244. width: 100%;
  245. position: fixed;
  246. top: 0px;
  247. z-index: 100;
  248. background-color: #FFFFFF;
  249. }
  250. .page-section {
  251. margin-top: 44px;
  252. height: 94vh;
  253. }
  254. .particulars {
  255. width: 100%;
  256. height: 160rpx;
  257. position: absolute;
  258. bottom: 0;
  259. .search_btn_top {
  260. width: 100%;
  261. height: 80rpx;
  262. line-height: 80rpx;
  263. font-size: 32rpx;
  264. padding-left: 30rpx;
  265. box-sizing: border-box;
  266. }
  267. .search_btn_bot {
  268. width: 100%;
  269. display: flex;
  270. }
  271. .particulars_par {
  272. background-color: #F1F1F1;
  273. text-align: center;
  274. width: 50%;
  275. height: 80rpx;
  276. line-height: 80rpx;
  277. font-size: 28rpx;
  278. }
  279. .particulars_ser {
  280. background-color: #57C87B;
  281. text-align: center;
  282. width: 50%;
  283. height: 80rpx;
  284. line-height: 80rpx;
  285. font-size: 28rpx;
  286. color: #FFFFFF;
  287. }
  288. }
  289. .distri_ser {
  290. position: absolute;
  291. bottom: 17rpx;
  292. right: 0px;
  293. width: 100%;
  294. height: 400rpx;
  295. background-color: #FFFFFF;
  296. .distri_ser_input {
  297. width: 90%;
  298. margin: 20rpx auto;
  299. display: flex;
  300. background-color: #F1F1F1;
  301. height: 60rpx;
  302. border-radius: 30rpx;
  303. padding: 10rpx 20rpx;
  304. box-sizing: border-box;
  305. input {
  306. width: 90%;
  307. font-size: 28rpx;
  308. margin-right: 20rpx;
  309. }
  310. }
  311. .distri_ser_title {
  312. width: 90%;
  313. margin: 0 auto;
  314. padding-left: 20rpx;
  315. border-left: 4rpx solid #57C87B;
  316. font-size: 28rpx;
  317. }
  318. .distri_ser_type {
  319. width: 90%;
  320. margin: 20rpx auto;
  321. display: flex;
  322. justify-content: space-around;
  323. .type_items {
  324. height: 120rpx;
  325. width: 120rpx;
  326. padding: 20rpx 0;
  327. }
  328. .type_items_bor {
  329. height: 120rpx;
  330. width: 120rpx;
  331. border: 2rpx solid #57C87B;
  332. padding: 20rpx 0;
  333. }
  334. .type_items_img {
  335. width: 70rpx;
  336. height: 70rpx;
  337. margin-left: 20rpx;
  338. }
  339. .type_items_p {
  340. font-size: 24rpx;
  341. text-align: center;
  342. }
  343. }
  344. }
  345. .search_btn {
  346. width: 100%;
  347. display: flex;
  348. .btn_f,
  349. .btn_t {
  350. width: 50%;
  351. text-align: center;
  352. height: 80rpx;
  353. line-height: 80rpx;
  354. font-size: 28rpx;
  355. }
  356. .btn_f {
  357. background-color: #F1F1F1;
  358. }
  359. .btn_t {
  360. background-color: #57C87B;
  361. color: #FFFFFF;
  362. }
  363. }
  364. </style>