serviceStation.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="safety" id="container">
  3. <map style="width: 100%; height: 75%;" :latitude="latitude" :longitude="longitude" scale="10"  
  4. :markers="markers" :show-location="true" @markertap="markertap">
  5. </map>
  6. <view class="model">
  7. <view class="info">
  8. <image class="img" src="/static/logo9.png"></image>
  9. <view class="info-data">
  10. <view class="info-title">名称:{{model.shopsName ? model.shopsName : '-'}}</view>
  11. <view class="info-text">电话:{{model.shopsTel ? model.shopsTel : '-'}}</view>
  12. <view class="info-shopsIntroduce">地址:{{model.shopsAddress ? model.shopsAddress : '-'}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import amap from '@/lib/amap-wx.130.js'
  20. import server from "@/api/index";
  21. import http from '@/common/http.js'
  22. export default {
  23. data() {
  24. return {
  25. pageNo: 1,
  26. pageSize: 10,
  27. id: 0,
  28. clickable: true,
  29. latitude: 43.616996,
  30. longitude: 125.323643,
  31. mapKey: '1dc63f21c12985e199a715faf4c02f36',
  32. markers: [],
  33. list: [],
  34. model:{
  35. shopsName: '',
  36. shopsTel: '',
  37. shopsPic: '',
  38. shopsAddress: ''
  39. }
  40. }
  41. },
  42. onLoad() {
  43. let that = this;
  44. this.amapPlugin = new amap.AMapWX({
  45. key: this.mapKey //该key 是在高德中申请的微信小程序key
  46. });
  47. this.amapPlugin.getRegeo({
  48. type: 'gcj02', //map 组件使用的经纬度是国测局坐标, type 为 gcj02
  49. success: function(res) {
  50. const latitude = res[0].latitude;
  51. const longitude = res[0].longitude;
  52. that.longitude = longitude;
  53. that.latitude = latitude;
  54. console.log(that.longitude, that.latitude)
  55. that.mapInfo = res[0];
  56. },
  57. fail: (res) => {
  58. console.log(JSON.stringify(res));
  59. }
  60. });
  61. this.getFn()
  62. },
  63. methods: {
  64. image(e) {
  65. return http.webUrl + e
  66. },
  67. getFn() {
  68. server.getServiceList().then(res =>{
  69. res.forEach((item, index) => {
  70. this.markers.push({
  71. id: item.id,
  72. latitude: item.latitude,
  73. longitude: item.longitude,
  74. iconPath: '../../../../static/logo3.png',
  75. width: 24,
  76. height: 24,
  77. clickable: true,
  78. shopsName: item.name,
  79. shopsTel: item.phone,
  80. shopsAddress: item.position
  81. })
  82. })
  83. if (this.markers[0]) {
  84. this.model.shopsName = this.markers[0].shopsName
  85. this.model.shopsTel = this.markers[0].shopsTel
  86. this.model.shopsAddress = this.markers[0].shopsAddress
  87. }
  88. })
  89. },
  90. markertap(e) {
  91. this.markers.forEach(item => {
  92. if (e.detail.markerId === item.id) {
  93. this.model.shopsName = item.shopsName
  94. this.model.shopsTel = item.shopsTel
  95. this.model.shopsAddress = item.shopsAddress
  96. }
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .safety {
  104. position: absolute;
  105. width: 100%;
  106. height: 100%;
  107. box-sizing: border-box;
  108. }
  109. .model {
  110. width: 100%;
  111. height: 25%;
  112. position: absolute;
  113. left: 0upx;
  114. bottom: 0upx;
  115. background-color: #FFFFFF;
  116. z-index: 9999;
  117. padding: 0rpx 30rpx;
  118. .info {
  119. width: 100%;
  120. height: 100%;
  121. display: flex;
  122. flex-direction: row;
  123. align-items: center;
  124. justify-content: space-around;
  125. .img{
  126. width: 180rpx;
  127. height: 200rpx;
  128. }
  129. .info-data{
  130. width: calc(100% - 180rpx);
  131. padding-left: 20upx;
  132. }
  133. .info-title{
  134. }
  135. .info-text{
  136. padding-top: 10upx;
  137. }
  138. .info-shopsIntroduce{
  139. padding-top: 10upx;
  140. line-height: 40rpx;
  141. height: auto;
  142. overflow: visible;
  143. }
  144. }
  145. }
  146. </style>