index.vue 8.4 KB

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