my-map.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. uninitialized: true,
  66. latitude: 30.746129,
  67. longitude: 120.755486,
  68. markers: [],
  69. information: [],
  70. facility: {},
  71. h5Popup: false,
  72. };
  73. },
  74. created() {
  75. this.setLocation();
  76. },
  77. methods: {
  78. init(forcedUpdating = true) {
  79. this.uninitialized = false;
  80. this.getList()
  81. console.log("加载地图")
  82. },
  83. getList() {
  84. this.$Http.basic({
  85. "id": 20230711144102,
  86. "content": {
  87. "pageNumber": 1,
  88. "pageSize": 9999,
  89. "where": {
  90. "condition": "",
  91. "areaname": ""
  92. }
  93. }
  94. }).then(res => {
  95. console.log("设备列表", res)
  96. if (this.cutoff(res.msg)) return;
  97. this.markers = res.data.filter(v => v.latitude).map(v => {
  98. v.id = v.w_deviceid - 0;
  99. v.title = v.devicename;
  100. if (this.usePort == 'h5') v.iconPath = require("../../../static/img/icon.png");
  101. v.customCallout = { display: 'BYCLICK', anchorY: -10 }
  102. return v
  103. });
  104. })
  105. },
  106. onMarkerTap(e) {
  107. console.log("单击标点", e)
  108. this.h5Popup = true;
  109. this.information = [];
  110. this.$Http.basic({
  111. "id": 20230711165702,
  112. "content": {
  113. "w_deviceid": e.detail.markerId
  114. }
  115. }).then(res => {
  116. console.log("设备详情", res)
  117. if (this.cutoff(res.msg)) return;
  118. this.information = res.data;
  119. if (this.usePort == 'h5') {
  120. this.facility = this.markers.find(v => v.id == e.detail.markerId);
  121. console.log(this.facility)
  122. }
  123. })
  124. },
  125. async setLocation() {
  126. let res = this.location || await this.getLocation();
  127. this.__proto__.location = res;
  128. this.latitude = res.latitude;
  129. this.longitude = res.longitude;
  130. console.log("地图", res)
  131. }
  132. },
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. page {
  137. width: 100vw;
  138. height: 100vh;
  139. overflow: hidden;
  140. }
  141. .container {
  142. position: relative;
  143. .popup {
  144. position: absolute;
  145. top: 13%;
  146. right: 12%;
  147. z-index: 99999;
  148. padding: 10px;
  149. box-sizing: border-box;
  150. }
  151. }
  152. .customCallout {
  153. width: 178px;
  154. background: rgba($color: #ffffff, $alpha: .8);
  155. border-radius: 4px;
  156. padding: 10rpx;
  157. box-sizing: border-box;
  158. .title {
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. line-height: 22px;
  163. font-size: 16px;
  164. font-family: PingFang SC-Medium, PingFang SC;
  165. font-weight: bold;
  166. color: #333333;
  167. .icon {
  168. margin-right: 5px;
  169. }
  170. }
  171. .rep {
  172. margin-top: 5px;
  173. .row {
  174. display: flex !important;
  175. line-height: 17px;
  176. font-size: 12px;
  177. color: #333333;
  178. margin-top: 5px;
  179. .value {
  180. flex: 1;
  181. width: 0;
  182. line-height: 17px;
  183. font-size: 12px;
  184. color: #000;
  185. }
  186. .status {
  187. line-height: 17px;
  188. font-size: 12px;
  189. color: #3874F6;
  190. }
  191. }
  192. }
  193. .botton {
  194. width: 100%;
  195. text-align: center;
  196. height: 30px;
  197. line-height: 30px;
  198. font-size: 14px;
  199. color: #3874F6;
  200. background: #EBF2FF;
  201. border: 1px solid #3874F6;
  202. border-radius: 4px;
  203. box-sizing: border-box;
  204. margin-top: 10px;
  205. }
  206. }
  207. </style>