my-map.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="container"><!-- enable-poi layer-style="1" subkey="UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN" -->
  3. <map name="map" style="width: 100%;height: 100vh;" scale="10" :latitude="latitude" :longitude="longitude"
  4. show-location :markers="markers" @markertap="onMarkerTap">
  5. <cover-view slot="callout">
  6. <cover-view class="customCallout" v-for="item in markers" :key="item.id" :marker-id="item.id">
  7. <cover-view class="title">
  8. 设备信息
  9. </cover-view>
  10. <cover-view class="rep">
  11. <cover-view class="row">
  12. 设备名称:<cover-view class="value u-line-1">{{ item.title || ' --' }}</cover-view>
  13. </cover-view>
  14. <cover-view class="row">
  15. 设备编号:<cover-view class="value u-line-1">{{ item.serialnumber || ' --' }}</cover-view>
  16. </cover-view>
  17. <cover-view class="row ">
  18. 设备状态:<cover-view class="status u-line-1">{{ item.status || ' --' }}</cover-view>
  19. </cover-view>
  20. <cover-view class="row" v-for="item1 in information" :key="item1.paramname">
  21. {{ item1.paramname }}:<cover-view class="value u-line-1">{{ item1.lastvalue + item1.unit ||
  22. '--' }}</cover-view>
  23. </cover-view>
  24. </cover-view>
  25. <cover-view class="botton" hover-class="navigator-hover">
  26. 更多信息
  27. </cover-view>
  28. </cover-view>
  29. </cover-view>
  30. </map>
  31. <view class="popup" v-if="h5Popup">
  32. <view class="customCallout" style="padding: 10px;">
  33. <view class="title">
  34. 设备信息
  35. <u-icon name="close" @click="h5Popup = false" :size="tovw('16px')" />
  36. </view>
  37. <view class="rep">
  38. <view class="row">
  39. 设备名称:<view class="value u-line-1">{{ facility.title || ' --' }}士大夫阿萨德阿萨德阿萨德阿三</view>
  40. </view>
  41. <view class="row">
  42. 设备编号:<view class="value u-line-1">{{ facility.serialnumber || ' --' }}</view>
  43. </view>
  44. <view class="row">
  45. 设备状态:<view class="status u-line-1">{{ facility.status || ' --' }}</view>
  46. </view>
  47. <view class="row" v-for="item1 in information" :key="item1.paramname">
  48. {{ item1.paramname }}:<view class="value u-line-1">{{ item1.lastvalue + item1.unit || ' --' }}
  49. </view>
  50. </view>
  51. </view>
  52. <view class="botton" hover-class="navigator-hover">
  53. 更多信息
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. name: 'My-map',
  62. data() {
  63. return {
  64. //subkey: 'GUCBZ-FWJCQ-AOQ5J-BUCCC-V7MJV-2QBDD',微信小程序个性化样式KEY
  65. latitude: 30.746129,
  66. longitude: 120.755486,
  67. markers: [],
  68. information: [],
  69. facility: {},
  70. h5Popup: false,
  71. };
  72. },
  73. created() {
  74. this.setLocation();
  75. this.getList()
  76. },
  77. methods: {
  78. getList() {
  79. this.$Http.basic({
  80. "id": 20230711144102,
  81. "content": {
  82. "pageNumber": 1,
  83. "pageSize": 9999,
  84. "where": {
  85. "condition": "",
  86. "areaname": ""
  87. }
  88. }
  89. }).then(res => {
  90. console.log("设备列表", res)
  91. if (this.cutoff(res.msg)) return;
  92. this.markers = res.data.filter(v => v.latitude).map(v => {
  93. v.id = v.w_deviceid - 0;
  94. v.title = v.devicename;
  95. if (this.usePort == 'h5') v.iconPath = require("../../../static/img/icon.png");
  96. v.customCallout = { display: 'BYCLICK', anchorY: -10 }
  97. return v
  98. });
  99. })
  100. },
  101. onMarkerTap(e) {
  102. console.log("单击标点", e)
  103. this.h5Popup = true;
  104. this.information = [];
  105. this.$Http.basic({
  106. "id": 20230711165702,
  107. "content": {
  108. "w_deviceid": e.detail.markerId
  109. }
  110. }).then(res => {
  111. console.log("设备详情", res)
  112. if (this.cutoff(res.msg)) return;
  113. this.information = res.data;
  114. if (this.usePort == 'h5') {
  115. this.facility = this.markers.find(v => v.id == e.detail.markerId);
  116. console.log(this.facility)
  117. }
  118. })
  119. },
  120. async setLocation() {
  121. let res = this.location || await this.getLocation();
  122. this.__proto__.location = res;
  123. this.latitude = res.latitude;
  124. this.longitude = res.longitude;
  125. console.log("地图", res)
  126. }
  127. },
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. page {
  132. width: 100vw;
  133. height: 100vh;
  134. overflow: hidden;
  135. }
  136. .container {
  137. position: relative;
  138. .popup {
  139. position: absolute;
  140. top: 13%;
  141. right: 12%;
  142. z-index: 99999;
  143. padding: 10px;
  144. box-sizing: border-box;
  145. }
  146. }
  147. .customCallout {
  148. width: 178px;
  149. background: rgba($color: #ffffff, $alpha: .8);
  150. border-radius: 4px;
  151. padding: 10rpx;
  152. box-sizing: border-box;
  153. .title {
  154. display: flex;
  155. align-items: center;
  156. justify-content: space-between;
  157. line-height: 22px;
  158. font-size: 16px;
  159. font-family: PingFang SC-Medium, PingFang SC;
  160. font-weight: bold;
  161. color: #333333;
  162. .icon {
  163. margin-right: 5px;
  164. }
  165. }
  166. .rep {
  167. margin-top: 5px;
  168. .row {
  169. display: flex !important;
  170. line-height: 17px;
  171. font-size: 12px;
  172. color: #333333;
  173. margin-top: 5px;
  174. .value {
  175. flex: 1;
  176. width: 0;
  177. line-height: 17px;
  178. font-size: 12px;
  179. color: #000;
  180. }
  181. .status {
  182. line-height: 17px;
  183. font-size: 12px;
  184. color: #3874F6;
  185. }
  186. }
  187. }
  188. .botton {
  189. width: 100%;
  190. text-align: center;
  191. height: 30px;
  192. line-height: 30px;
  193. font-size: 14px;
  194. color: #3874F6;
  195. background: #EBF2FF;
  196. border: 1px solid #3874F6;
  197. border-radius: 4px;
  198. box-sizing: border-box;
  199. margin-top: 10px;
  200. }
  201. }
  202. </style>