index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view :style="colorStyle">
  3. <map class="map-view" :key="mapKey" :scale="9" :latitude="latitudeStore" :longitude="longitudeStore" :markers="covers" @markertap="markertap">
  4. <view v-if="markerIdTapped" class="cover-view">
  5. <view class="cover-view-item">
  6. <view class="cover-view-text title">{{ markertapped.name }}</view>
  7. <view class="store" @tap="openStore(markertapped.id)">进店选购<view class="iconfont icon-xiangyou"></view>
  8. </view>
  9. </view>
  10. <view class="cover-view-item">
  11. <view class="cover-view-text address">{{ markertapped.detailed_address }}</view>
  12. <view class="group-button">
  13. <view class="button" @tap="makePhoneCall(markertapped.phone)">
  14. <view class="iconfont icon-ic_phone"></view>
  15. </view>
  16. <view class="button" @tap="openLocation(markertapped)">
  17. <view class="iconfont icon-ic_location"></view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </map>
  23. </view>
  24. </template>
  25. <script>
  26. import colors from "@/mixins/color";
  27. import {
  28. getList
  29. } from '@/api/new_store.js';
  30. export default {
  31. mixins: [colors],
  32. data() {
  33. return {
  34. latitudeStore: uni.getStorageSync('user_latitude'),
  35. longitudeStore: uni.getStorageSync('user_longitude'),
  36. content: {
  37. latitude: uni.getStorageSync('user_latitude'),
  38. longitude: uni.getStorageSync('user_longitude'),
  39. store_type: 1,
  40. },
  41. storeList: [],
  42. markerIdTapped: 0,
  43. mapKey: ''
  44. }
  45. },
  46. computed: {
  47. covers() {
  48. return this.storeList.map(({
  49. id,
  50. latitude,
  51. longitude,
  52. image: iconPath
  53. }) => ({
  54. id,
  55. latitude,
  56. longitude,
  57. iconPath,
  58. width: 30,
  59. height: 30
  60. }));
  61. },
  62. markertapped() {
  63. return this.storeList.find(item => item.id === this.markerIdTapped);
  64. }
  65. },
  66. onLoad() {
  67. this.getList();
  68. },
  69. methods: {
  70. getList() {
  71. getList(this.content).then(res => {
  72. let storeList = res.data;
  73. this.storeList = storeList;
  74. console.log(this.storeList)
  75. // for (let i = 0; i < this.storeList.length; i++) {
  76. // this.downloadImage(i);
  77. // }
  78. });
  79. },
  80. downloadImage(index) {
  81. uni.request({
  82. url: this.storeList[index].image,
  83. responseType:'arraybuffer',
  84. success: (res) => {
  85. const base64 = uni.arrayBufferToBase64(res.data);
  86. this.$set(this.storeList[index], 'path', 'data:image/png;base64,' + base64);
  87. this.mapKey = index;
  88. }
  89. })
  90. },
  91. markertap(e) {
  92. this.markerIdTapped = e.detail.markerId;
  93. },
  94. openStore(id) {
  95. uni.navigateTo({
  96. url: '/pages/store/home/index?mapFrom=1&id=' + id
  97. })
  98. },
  99. makePhoneCall(phoneNumber) {
  100. uni.makePhoneCall({
  101. phoneNumber
  102. });
  103. },
  104. openLocation({
  105. latitude,
  106. longitude,
  107. name,
  108. address,
  109. detailed_address
  110. }) {
  111. uni.openLocation({
  112. latitude: Number(latitude),
  113. longitude: Number(longitude),
  114. name,
  115. address: `${address}-${detailed_address}`
  116. });
  117. }
  118. },
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .map-view {
  123. position: fixed;
  124. top: 0;
  125. right: 0;
  126. width: 100%;
  127. height: 100%;
  128. }
  129. .cover-view {
  130. position: absolute;
  131. right: 48rpx;
  132. bottom: 48rpx;
  133. bottom: calc(48rpx + constant(safe-area-inset-bottom));
  134. bottom: calc(48rpx + env(safe-area-inset-bottom));
  135. left: 48rpx;
  136. padding: 28rpx 28rpx 24rpx 30rpx;
  137. border-radius: 12rpx;
  138. background-color: #FFFFFF;
  139. box-shadow: 0 0 28rpx 0rpx rgba(0, 0, 0, 0.1);
  140. }
  141. .cover-view-item {
  142. display: flex;
  143. +.cover-view-item {
  144. margin-top: 18rpx;
  145. }
  146. }
  147. .cover-view-text {
  148. flex: 1;
  149. min-width: 0;
  150. padding-right: 50rpx;
  151. }
  152. .title {
  153. font-weight: bold;
  154. font-size: 28rpx;
  155. color: #333333;
  156. }
  157. .store {
  158. display: flex;
  159. font-size: 22rpx;
  160. line-height: 28rpx;
  161. color: var(--view-theme);
  162. .iconfont {
  163. margin-left: 10rpx;
  164. font-size: 22rpx;
  165. }
  166. }
  167. .address {
  168. white-space: normal;
  169. font-size: 22rpx;
  170. line-height: 32rpx;
  171. color: #888888;
  172. }
  173. .group-button {
  174. align-self: center;
  175. display: flex;
  176. .button {
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. width: 40rpx;
  181. height: 40rpx;
  182. border-radius: 50%;
  183. background-color: var(--view-minorColorT);
  184. +.button {
  185. margin-left: 20rpx;
  186. }
  187. }
  188. .iconfont {
  189. font-size: 20rpx;
  190. color: var(--view-theme);
  191. }
  192. }
  193. </style>