index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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" :style="disstyle">
  30. <view class="distri_ser_input">
  31. <input type="number" v-model="device_id" placeholder="请输入设备ID" @confirm="doSearch" :adjust-position="false" @focus="focus" auto-blur @blur="disblur"/>
  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/be5c1cfed22713a9544f020cf41c25f.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. disstyle:{
  122. position:"absolute",
  123. bottom:"0rpx"
  124. }
  125. }
  126. },
  127. onLoad() {
  128. this.history()
  129. },
  130. methods: {
  131. async history() { //获取分布位置
  132. const res = await this.$myRequest({
  133. url: '/api/api_gateway?method=home.homes.equip_map_location',
  134. data: {
  135. equip_type: this.type,
  136. device_id: this.device_id
  137. }
  138. })
  139. console.log(res)
  140. this.covers = []
  141. for (var i = 0; i < res.length; i++) {
  142. var obj = {}
  143. obj.latitude = res[i].lat
  144. obj.longitude = res[i].lng
  145. obj.id = [res[i].device_id, res[i].d_id, res[i].device_type_id]
  146. obj.title = res[i].device_name || res[i].device_id
  147. // obj.width = 25
  148. for (var j = 0; j < this.icon.length; j++) {
  149. if (res[i].device_type_id == this.icon[j].id) {
  150. obj.iconPath = this.icon[j].url
  151. }
  152. }
  153. this.covers.push(obj)
  154. }
  155. console.log(res)
  156. },
  157. change(index) {
  158. this.current = index
  159. if (index == 0) {
  160. this.type = ''
  161. } else {
  162. this.type = index + 1
  163. }
  164. this.history()
  165. },
  166. markertap(e) {
  167. console.log(e)
  168. this.punctuation_id = e.detail.markerId[0]
  169. this.punctuation_did = e.detail.markerId[1]
  170. this.punctuation_type = e.detail.markerId[2]
  171. this.listindex = e.detail.markerId[2]
  172. },
  173. typeselect(index) { //选择设备类型
  174. this.typeindex = index
  175. this.type = this.icon[index + 1].id
  176. console.log(this.type)
  177. },
  178. doSearch() { //按下回车键
  179. this.search()
  180. },
  181. search() { //点击搜索
  182. if (this.type == '') {
  183. uni.showToast({
  184. title: '请选择设备类型',
  185. duration: 2000,
  186. icon: "none"
  187. });
  188. } else {
  189. this.history()
  190. this.serTF = !this.serTF
  191. this.style.height = "85%"
  192. }
  193. },
  194. serTFs() {
  195. this.serTF = !this.serTF
  196. this.style.height = "65%"
  197. },
  198. btnF() { //取消
  199. this.serTF = !this.serTF
  200. this.style.height = "85%"
  201. },
  202. btnT() { //确定
  203. this.search()
  204. },
  205. focus(e){
  206. this.disstyle.bottom = e.detail.height-170+"rpx"
  207. this.style.height = "55%"
  208. },
  209. disblur(){
  210. this.disstyle.bottom = 0
  211. this.style.height = "65%"
  212. },
  213. eqinfo() { //设备信息
  214. if (this.punctuation_id == '') {
  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.punctuation_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.punctuation_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.punctuation_id
  235. })
  236. break;
  237. case 5:
  238. uni.navigateTo({
  239. url: "../environment/history?d_id=" + this.punctuation_did + "&device_id=" + this.punctuation_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.punctuation_id
  250. })
  251. break;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .utabs {
  260. width: 100%;
  261. position: fixed;
  262. top: 0px;
  263. z-index: 100;
  264. background-color: #FFFFFF;
  265. }
  266. .page-section {
  267. margin-top: 44px;
  268. height: 94vh;
  269. }
  270. .particulars {
  271. width: 100%;
  272. height: 160rpx;
  273. position: absolute;
  274. bottom: 0;
  275. .search_btn_top {
  276. width: 100%;
  277. height: 80rpx;
  278. line-height: 80rpx;
  279. font-size: 32rpx;
  280. padding-left: 30rpx;
  281. box-sizing: border-box;
  282. }
  283. .search_btn_bot {
  284. width: 100%;
  285. display: flex;
  286. }
  287. .particulars_par {
  288. background-color: #F1F1F1;
  289. text-align: center;
  290. width: 50%;
  291. height: 80rpx;
  292. line-height: 80rpx;
  293. font-size: 28rpx;
  294. }
  295. .particulars_ser {
  296. background-color: #57C87B;
  297. text-align: center;
  298. width: 50%;
  299. height: 80rpx;
  300. line-height: 80rpx;
  301. font-size: 28rpx;
  302. color: #FFFFFF;
  303. }
  304. }
  305. .distri_ser {
  306. position: absolute;
  307. bottom: 0rpx;
  308. right: 0px;
  309. width: 100%;
  310. height: 440rpx;
  311. background-color: #FFFFFF;
  312. .distri_ser_input {
  313. width: 90%;
  314. margin: 20rpx auto;
  315. display: flex;
  316. background-color: #F1F1F1;
  317. height: 60rpx;
  318. border-radius: 30rpx;
  319. padding: 10rpx 20rpx;
  320. box-sizing: border-box;
  321. input {
  322. width: 90%;
  323. font-size: 28rpx;
  324. margin-right: 20rpx;
  325. }
  326. }
  327. .distri_ser_title {
  328. width: 90%;
  329. margin: 0 auto;
  330. padding-left: 20rpx;
  331. border-left: 4rpx solid #57C87B;
  332. font-size: 28rpx;
  333. }
  334. .distri_ser_type {
  335. width: 90%;
  336. margin: 20rpx auto;
  337. display: flex;
  338. justify-content: space-around;
  339. .type_items {
  340. height: 120rpx;
  341. width: 120rpx;
  342. padding: 20rpx 0;
  343. }
  344. .type_items_bor {
  345. height: 120rpx;
  346. width: 120rpx;
  347. border: 2rpx solid #57C87B;
  348. padding: 20rpx 0;
  349. }
  350. .type_items_img {
  351. width: 70rpx;
  352. height: 70rpx;
  353. margin-left: 20rpx;
  354. }
  355. .type_items_p {
  356. font-size: 24rpx;
  357. text-align: center;
  358. }
  359. }
  360. }
  361. .search_btn {
  362. width: 100%;
  363. display: flex;
  364. .btn_f,
  365. .btn_t {
  366. width: 50%;
  367. text-align: center;
  368. height: 80rpx;
  369. line-height: 80rpx;
  370. font-size: 28rpx;
  371. }
  372. .btn_f {
  373. background-color: #F1F1F1;
  374. }
  375. .btn_t {
  376. background-color: #57C87B;
  377. color: #FFFFFF;
  378. }
  379. }
  380. </style>