index.nvue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <map :style="'width: '+ windowWidth +'px; height: '+ (windowHeight) +'px;'" class="map-view" :key="mapKey" :scale="9" :latitude="latitudeStore" :longitude="longitudeStore" :markers="covers" @markertap="markertap">
  3. <view v-if="markerIdTapped" class="cover-view">
  4. <view class="cover-view-item">
  5. <text class="cover-view-text title">{{ markertapped.name }}</text>
  6. <view class="store-wrap" @tap="openStore(markertapped.id)">
  7. <text class="store">进店选购</text>
  8. <text class="iconfont icon-xiangyou">&#xe679;</text>
  9. </view>
  10. </view>
  11. <view class="cover-view-item">
  12. <view class="address-wrap">
  13. <rich-text class="cover-view-text address" :nodes="richNodes(markertapped)"></rich-text>
  14. </view>
  15. <view class="group-button">
  16. <view class="button" @tap="makePhoneCall(markertapped.phone)">
  17. <text class="iconfont icon-dianhua">&#xe7fc;</text>
  18. </view>
  19. <view class="button" @tap="openLocation(markertapped)">
  20. <text class="iconfont icon-dingwei2">&#xe7fb;</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </map>
  26. </template>
  27. <script>
  28. import colors from "@/mixins/color";
  29. import {
  30. getList
  31. } from '@/api/new_store.js';
  32. export default {
  33. mixins: [colors],
  34. beforeCreate() {
  35. const domModule = uni.requireNativePlugin('dom')
  36. domModule.addRule('fontFace', {
  37. 'fontFamily': "iconfont",
  38. 'src': "url('http://at.alicdn.com/t/c/font_993865_0rmejz9fdizr.ttf?t=1689647362545')"
  39. });
  40. },
  41. data() {
  42. return {
  43. latitudeStore: uni.getStorageSync('user_latitude'),
  44. longitudeStore: uni.getStorageSync('user_longitude'),
  45. content: {
  46. latitude: uni.getStorageSync('user_latitude'),
  47. longitude: uni.getStorageSync('user_longitude'),
  48. store_type: 1,
  49. keyword: "",
  50. province: 0,
  51. city: 0,
  52. area: 0,
  53. },
  54. storeList: [],
  55. markerIdTapped: 0,
  56. mapKey: '',
  57. windowWidth: 0,
  58. windowHeight: 0,
  59. }
  60. },
  61. computed: {
  62. covers() {
  63. return this.storeList.map(({
  64. id,
  65. latitude,
  66. longitude,
  67. image
  68. }) => ({
  69. id,
  70. latitude,
  71. longitude,
  72. iconPath: image,
  73. width: 30,
  74. height: 30
  75. }));
  76. },
  77. markertapped() {
  78. return this.storeList.find(item => item.id === this.markerIdTapped);
  79. }
  80. },
  81. onLoad(option) {
  82. this.windowWidth = uni.getSystemInfoSync().windowWidth;
  83. this.windowHeight = uni.getSystemInfoSync().windowHeight;
  84. this.content.province = option.province;
  85. this.content.city = option.city;
  86. this.content.area = option.area;
  87. this.getList();
  88. },
  89. methods: {
  90. getList() {
  91. getList(this.content).then(res => {
  92. let storeList = res.data;
  93. this.storeList = storeList;
  94. });
  95. },
  96. markertap(e) {
  97. this.markerIdTapped = e.detail.markerId;
  98. },
  99. openStore(id) {
  100. uni.reLaunch({
  101. url: `/pages/store_cate/store_cate?id=${id}`
  102. });
  103. },
  104. makePhoneCall(phoneNumber) {
  105. uni.makePhoneCall({
  106. phoneNumber
  107. });
  108. },
  109. openLocation({
  110. latitude,
  111. longitude,
  112. name,
  113. address,
  114. detailed_address
  115. }) {
  116. uni.openLocation({
  117. latitude: Number(latitude),
  118. longitude: Number(longitude),
  119. name,
  120. address: `${address}-${detailed_address}`
  121. });
  122. },
  123. richNodes(item) {
  124. return [{
  125. children: [{
  126. type: 'text',
  127. attrs: {
  128. class: 'lin-msg-name'
  129. },
  130. text: item.detailed_address
  131. }
  132. ]
  133. }]
  134. }
  135. },
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .iconfont {
  140. font-family:iconfont;
  141. }
  142. .map-view {
  143. position: fixed;
  144. top: 0;
  145. right: 0;
  146. bottom: 0;
  147. left: 0;
  148. }
  149. .cover-view {
  150. position: absolute;
  151. right: 48rpx;
  152. bottom: 48rpx;
  153. left: 48rpx;
  154. padding: 28rpx 28rpx 24rpx 30rpx;
  155. border-radius: 12rpx;
  156. background-color: #FFFFFF;
  157. box-shadow: 0 0 28rpx 0rpx rgba(0, 0, 0, 0.1);
  158. }
  159. .cover-view-item {
  160. flex-direction: row;
  161. }
  162. .cover-view-item + .cover-view-item {
  163. margin-top: 18rpx;
  164. }
  165. .cover-view-text {
  166. flex: 1;
  167. padding-right: 50rpx;
  168. }
  169. .title {
  170. font-weight: bold;
  171. font-size: 28rpx;
  172. color: #333333;
  173. }
  174. .store-wrap {
  175. flex-direction: row;
  176. }
  177. .store {
  178. flex-direction: row;
  179. font-size: 22rpx;
  180. line-height: 28rpx;
  181. color: #E93323;
  182. }
  183. .icon-xiangyou {
  184. margin-left: 10rpx;
  185. font-size: 22rpx;
  186. line-height: 28rpx;
  187. color: #E93323;
  188. }
  189. .address-wrap {
  190. flex: 1;
  191. }
  192. .address {
  193. font-size: 22rpx;
  194. line-height: 32rpx;
  195. color: #888888;
  196. }
  197. .group-button {
  198. flex-direction: row;
  199. .button {
  200. flex-direction: row;
  201. justify-content: center;
  202. align-items: center;
  203. width: 40rpx;
  204. height: 40rpx;
  205. border-radius: 50%;
  206. background-color: rgba(233, 51, 35, 0.1);
  207. +.button {
  208. margin-left: 20rpx;
  209. }
  210. }
  211. .iconfont {
  212. font-size: 20rpx;
  213. color: #E93323;
  214. }
  215. }
  216. </style>