index.vue 8.8 KB

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