index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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-dianhua"></view>
  15. </view>
  16. <view class="button" @tap="openLocation(markertapped)">
  17. <view class="iconfont icon-dingwei2"></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. keyword: "",
  41. province: 0,
  42. city: 0,
  43. area: 0,
  44. },
  45. storeList: [],
  46. markerIdTapped: 0,
  47. mapKey: ''
  48. }
  49. },
  50. computed: {
  51. covers() {
  52. return this.storeList.map(({
  53. id,
  54. latitude,
  55. longitude,
  56. path: iconPath
  57. }) => ({
  58. id,
  59. latitude,
  60. longitude,
  61. iconPath,
  62. width: 30,
  63. height: 30
  64. }));
  65. },
  66. markertapped() {
  67. return this.storeList.find(item => item.id === this.markerIdTapped);
  68. }
  69. },
  70. onLoad(option) {
  71. this.content.province = option.province;
  72. this.content.city = option.city;
  73. this.content.area = option.area;
  74. this.getList();
  75. },
  76. methods: {
  77. getList() {
  78. getList(this.content).then(res => {
  79. let storeList = res.data;
  80. this.storeList = storeList;
  81. for (let i = 0; i < this.storeList.length; i++) {
  82. this.downloadImage(i);
  83. }
  84. });
  85. },
  86. downloadImage(index) {
  87. uni.request({
  88. url: this.storeList[index].image,
  89. responseType:'arraybuffer',
  90. success: (res) => {
  91. const base64 = uni.arrayBufferToBase64(res.data);
  92. this.$set(this.storeList[index], 'path', 'data:image/png;base64,' + base64);
  93. this.mapKey = index;
  94. }
  95. })
  96. },
  97. markertap(e) {
  98. this.markerIdTapped = e.detail.markerId;
  99. },
  100. openStore(id) {
  101. uni.reLaunch({
  102. url: `/pages/store_cate/store_cate?id=${id}`
  103. });
  104. },
  105. makePhoneCall(phoneNumber) {
  106. uni.makePhoneCall({
  107. phoneNumber
  108. });
  109. },
  110. openLocation({
  111. latitude,
  112. longitude,
  113. name,
  114. address,
  115. detailed_address
  116. }) {
  117. uni.openLocation({
  118. latitude: Number(latitude),
  119. longitude: Number(longitude),
  120. name,
  121. address: `${address}-${detailed_address}`
  122. });
  123. }
  124. },
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .map-view {
  129. position: fixed;
  130. top: 0;
  131. right: 0;
  132. width: 100%;
  133. height: 100%;
  134. }
  135. .cover-view {
  136. position: absolute;
  137. right: 48rpx;
  138. bottom: 48rpx;
  139. bottom: calc(48rpx + constant(safe-area-inset-bottom));
  140. bottom: calc(48rpx + env(safe-area-inset-bottom));
  141. left: 48rpx;
  142. padding: 28rpx 28rpx 24rpx 30rpx;
  143. border-radius: 12rpx;
  144. background-color: #FFFFFF;
  145. box-shadow: 0 0 28rpx 0rpx rgba(0, 0, 0, 0.1);
  146. }
  147. .cover-view-item {
  148. display: flex;
  149. +.cover-view-item {
  150. margin-top: 18rpx;
  151. }
  152. }
  153. .cover-view-text {
  154. flex: 1;
  155. min-width: 0;
  156. padding-right: 50rpx;
  157. }
  158. .title {
  159. font-weight: bold;
  160. font-size: 28rpx;
  161. color: #333333;
  162. }
  163. .store {
  164. display: flex;
  165. font-size: 22rpx;
  166. line-height: 28rpx;
  167. color: var(--view-theme);
  168. .iconfont {
  169. margin-left: 10rpx;
  170. font-size: 22rpx;
  171. }
  172. }
  173. .address {
  174. white-space: normal;
  175. font-size: 22rpx;
  176. line-height: 32rpx;
  177. color: #888888;
  178. }
  179. .group-button {
  180. align-self: center;
  181. display: flex;
  182. .button {
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. width: 40rpx;
  187. height: 40rpx;
  188. border-radius: 50%;
  189. background-color: var(--view-minorColorT);
  190. +.button {
  191. margin-left: 20rpx;
  192. }
  193. }
  194. .iconfont {
  195. font-size: 20rpx;
  196. color: var(--view-theme);
  197. }
  198. }
  199. </style>