index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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>
  15. </view>
  16. <view class="particulars">
  17. <view class="search_btn_top">
  18. 已点击设备:{{punctuation_id || "无"}}
  19. </view>
  20. <view class="search_btn_bot">
  21. <view class="particulars_par" @click="eqinfo">
  22. 查看详情
  23. </view>
  24. <view class="particulars_ser" @click="serTFs">
  25. 搜索
  26. </view>
  27. </view>
  28. </view>
  29. <view class="distri_ser" v-if="serTF">
  30. <view class="distri_ser_input">
  31. <input type="number" v-model="device_id" placeholder="请输入设备ID" @confirm="doSearch" />
  32. <u-icon name="search" size="38rpx" @click="search"></u-icon>
  33. </view>
  34. <p class="distri_ser_title">请选择设备类型(点击选择)</p>
  35. <view class="distri_ser_type">
  36. <view :class="typeindex==index?'type_items_bor':'type_items'" v-for="item,index in 6" :key="index" @click="typeselect(index)">
  37. <image :src="icon[item].url" mode="" class="type_items_img"></image>
  38. <p class="type_items_p">{{list[item].name}}</p>
  39. </view>
  40. </view>
  41. <view class="search_btn">
  42. <view class="btn_f" @click="btnF">
  43. 取 消
  44. </view>
  45. <view class="btn_t" @click="btnT">
  46. 确 定
  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: "80vh",
  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. this.covers = []
  133. for (var i = 0; i < res.length; i++) {
  134. var obj = {}
  135. obj.latitude = res[i].lat
  136. obj.longitude = res[i].lng
  137. obj.id = [res[i].device_id, res[i].d_id, res[i].device_type_id]
  138. obj.title = res[i].device_name || res[i].device_id
  139. // obj.width = 25
  140. for (var j = 0; j < this.icon.length; j++) {
  141. if (res[i].device_type_id == this.icon[j].id) {
  142. obj.iconPath = this.icon[j].url
  143. }
  144. }
  145. this.covers.push(obj)
  146. }
  147. console.log(res)
  148. },
  149. change(index) {
  150. this.current = index
  151. if (index == 0) {
  152. this.type = ''
  153. } else {
  154. this.type = index + 1
  155. }
  156. this.history()
  157. },
  158. markertap(e) {
  159. console.log(e)
  160. this.punctuation_id = e.detail.markerId[0]
  161. this.punctuation_did = e.detail.markerId[1]
  162. this.punctuation_type = e.detail.markerId[2]
  163. },
  164. typeselect(index) { //选择设备类型
  165. this.typeindex = index
  166. this.type = this.icon[index + 1].id
  167. console.log(this.type)
  168. },
  169. doSearch() { //按下回车键
  170. this.search()
  171. },
  172. search() { //点击搜索
  173. // this.history()
  174. if (this.type == '') {
  175. uni.showToast({
  176. title: '请选择设备类型',
  177. duration: 2000,
  178. icon: "none"
  179. });
  180. } else {
  181. this.history()
  182. this.serTF = !this.serTF
  183. }
  184. },
  185. serTFs() {
  186. this.serTF = !this.serTF
  187. this.style.height = "63vh"
  188. },
  189. btnF() { //取消
  190. this.serTF = !this.serTF
  191. this.style.height = "80vh"
  192. },
  193. btnT() { //确定
  194. this.search()
  195. },
  196. eqinfo() { //设备信息
  197. if (this.punctuation_id == '') {
  198. uni.showToast({
  199. title: '请点击需查看的设备',
  200. duration: 2000,
  201. icon: "none"
  202. });
  203. } else {
  204. switch (this.punctuation_type) {
  205. case 2:
  206. uni.navigateTo({
  207. url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  208. })
  209. break;
  210. case 3:
  211. uni.navigateTo({
  212. url: "../cb/cbd/equip-set/historyfile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  213. })
  214. break;
  215. case 4:
  216. uni.navigateTo({
  217. url: "../cb/xy/equip-set/xyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  218. })
  219. break;
  220. case 5:
  221. uni.navigateTo({
  222. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  223. })
  224. break;
  225. case 6:
  226. // uni.navigateTo({
  227. // url: "../prevention/ucharts?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  228. // })
  229. break;
  230. case 7:
  231. uni.navigateTo({
  232. url: "../cb/bzy/equip-set/bzyhistoryile?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_id
  233. })
  234. break;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss">
  242. .utabs {
  243. width: 100%;
  244. position: fixed;
  245. top: 0px;
  246. z-index: 100;
  247. background-color: #FFFFFF;
  248. }
  249. .page-section {
  250. margin-top: 44px;
  251. }
  252. .particulars {
  253. width: 100%;
  254. height: 160rpx;
  255. position: absolute;
  256. bottom: 0;
  257. .search_btn_top {
  258. width: 100%;
  259. height: 80rpx;
  260. line-height: 80rpx;
  261. font-size: 32rpx;
  262. padding-left: 30rpx;
  263. box-sizing: border-box;
  264. }
  265. .search_btn_bot {
  266. width: 100%;
  267. display: flex;
  268. }
  269. .particulars_par {
  270. background-color: #F1F1F1;
  271. text-align: center;
  272. width: 50%;
  273. height: 80rpx;
  274. line-height: 80rpx;
  275. font-size: 28rpx;
  276. }
  277. .particulars_ser {
  278. background-color: #57C87B;
  279. text-align: center;
  280. width: 50%;
  281. height: 80rpx;
  282. line-height: 80rpx;
  283. font-size: 28rpx;
  284. color: #FFFFFF;
  285. }
  286. }
  287. .distri_ser {
  288. position: absolute;
  289. bottom: 17rpx;
  290. right: 0px;
  291. width: 100%;
  292. height: 400rpx;
  293. background-color: #FFFFFF;
  294. .distri_ser_input {
  295. width: 90%;
  296. margin: 20rpx auto;
  297. display: flex;
  298. background-color: #F1F1F1;
  299. height: 60rpx;
  300. border-radius: 30rpx;
  301. padding: 10rpx 20rpx;
  302. box-sizing: border-box;
  303. input {
  304. width: 90%;
  305. font-size: 28rpx;
  306. margin-right: 20rpx;
  307. }
  308. }
  309. .distri_ser_title {
  310. width: 90%;
  311. margin: 0 auto;
  312. padding-left: 20rpx;
  313. border-left: 4rpx solid #57C87B;
  314. font-size: 28rpx;
  315. }
  316. .distri_ser_type {
  317. width: 90%;
  318. margin: 20rpx auto;
  319. display: flex;
  320. justify-content: space-around;
  321. .type_items {
  322. height: 120rpx;
  323. width: 120rpx;
  324. padding: 20rpx 0;
  325. }
  326. .type_items_bor {
  327. height: 120rpx;
  328. width: 120rpx;
  329. border: 2rpx solid #57C87B;
  330. padding: 20rpx 0;
  331. }
  332. .type_items_img {
  333. width: 70rpx;
  334. height: 70rpx;
  335. margin-left: 20rpx;
  336. }
  337. .type_items_p {
  338. font-size: 24rpx;
  339. text-align: center;
  340. }
  341. }
  342. }
  343. .search_btn {
  344. width: 100%;
  345. display: flex;
  346. .btn_f,
  347. .btn_t {
  348. width: 50%;
  349. text-align: center;
  350. height: 80rpx;
  351. line-height: 80rpx;
  352. font-size: 28rpx;
  353. }
  354. .btn_f {
  355. background-color: #F1F1F1;
  356. }
  357. .btn_t {
  358. background-color: #57C87B;
  359. color: #FFFFFF;
  360. }
  361. }
  362. </style>