store-choose.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="container">
  3. <!-- 地图容器 -->
  4. <view class="map-wrap">
  5. <map style="width: 100%; height: 300px;"
  6. id="map"
  7. :latitude="latitude"
  8. :longitude="longitude"
  9. :scale="scale"
  10. :show-location="true"
  11. :enable-building="true"
  12. :markers="markers"
  13. @markertap="handleMarkerTap"
  14. >
  15. </map>
  16. </view>
  17. <!-- 地区 -->
  18. <!-- <view class="h-area-wrap">
  19. <view class="h-search">
  20. <view class="h-time">
  21. <view class="time">{{areaName}}</view>
  22. <u-icon name="arrow-down" color="#000" size="18"></u-icon>
  23. </view>
  24. <view class="h-name">
  25. </view>
  26. </view>
  27. </view> -->
  28. <!-- 门店列表 -->
  29. <view class="h-store-wrap">
  30. <view v-for="(item,index) in storeList" class="h-store-content">
  31. <view @click="selectStore(item)" class="h-row">
  32. <view class="h-left-value">
  33. <text class="h-name">{{item.storeName}}</text>
  34. </view>
  35. <view class="h-right-value">
  36. <!-- <text class="h-text">4.2km</text> -->
  37. </view>
  38. </view>
  39. <view class="h-row" @click="selectStore(item)">
  40. <view class="h-left-value">
  41. <view class="h-text">
  42. <image src="../../static/goods/dingwei.png" mode=""></image>
  43. <text>地址:{{item.address}}</text>
  44. </view>
  45. <view class="h-text">
  46. <image src="../../static/goods/time.png" mode=""></image>
  47. 营业时间:
  48. <text>{{item.tradeTime}}~{{item.gooutTime}}</text>
  49. </view>
  50. <view class="h-text">
  51. <image src="../../static/goods/zixun.png" mode=""></image>
  52. 咨询热线:
  53. <text>{{item.phone || ''}}</text>
  54. </view>
  55. </view>
  56. <!-- <view class="h-right-value h-flex">-->
  57. <!-- <view class="phone">-->
  58. <!-- <image src="../../static/goods/u291.png" mode=""></image>-->
  59. <!-- </view>-->
  60. <!-- <view class="sure">-->
  61. <!-- <image src="../../static/goods/u292.png" mode=""></image>-->
  62. <!-- </view>-->
  63. <!-- </view>-->
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. markers:[],
  74. areaName: '贵阳市',
  75. latitude: 26.5737,
  76. longitude: 106.7135,
  77. scale: 10,
  78. img: '/static/index/u55.png',
  79. reqParm: {
  80. auth: true,
  81. longitude: 0,
  82. latitude: 0
  83. },
  84. storeList: [],
  85. type: '1',
  86. navigateRouter:null
  87. }
  88. },
  89. onReady() {
  90. // 初始化地图
  91. // this.initMap();
  92. },
  93. onLoad(option) {
  94. // 获取商店数据
  95. this.getStoreListData();
  96. this.getLocation()
  97. // 判断Openid是否为空
  98. if (option.type) {
  99. this.type = option.type;
  100. }
  101. },
  102. onShow(){
  103. this.navigateRouter = uni.getStorageSync('router');
  104. },
  105. methods: {
  106. getLocation() {
  107. let that = this
  108. uni.getLocation({
  109. type: 'gcj02',
  110. success: function (res) {
  111. that.latitude = res.latitude; // 纬度
  112. that.longitude = res.longitude; // 经度
  113. let mapContext = uni.createMapContext("map", this);
  114. mapContext.moveToLocation()
  115. },
  116. fail: function (fail) {
  117. console.log('获取用户地址失败==》', fail)
  118. },
  119. complete: function (complete) {
  120. console.log('获取用户地址失败or成功==》', complete)
  121. }
  122. })
  123. },
  124. // 选择门店
  125. selectStore(item) {
  126. // 更新用户选择的门店信息
  127. uni.setStorageSync('storeInfo', item);
  128. if(this.navigateRouter == 0){
  129. uni.redirectTo({
  130. url: '/orderPages/storeService/index'
  131. })
  132. uni.removeStorage({
  133. key: 'router'
  134. });
  135. }else if(this.navigateRouter == 1){
  136. uni.redirectTo({
  137. url: '/orderPages/bookService/index'
  138. })
  139. uni.removeStorage({
  140. key: 'router'
  141. });
  142. }else {
  143. uni.switchTab({
  144. url: '/pages/index/index'
  145. })
  146. }
  147. },
  148. // 获取门店列表数据
  149. getStoreListData() {
  150. let that = this;
  151. this.$api.storeList({
  152. latitude: this.latitude,
  153. longitude: this.longitude,
  154. }).then((res) => {
  155. console.log(res)
  156. that.storeList = res.data.data
  157. // 添加坐标点
  158. that.addMarkers();
  159. }).catch(() => {
  160. console.log("获取用户门店列表报错")
  161. })
  162. },
  163. addMarkers() {
  164. this.markers = []
  165. // 处理点的数据
  166. this.storeList.forEach((p, i) => {
  167. this.markers.push(
  168. {
  169. id: i,
  170. iconPath: '/static/index/u55.png',
  171. width: 30,
  172. height: 30,
  173. latitude: p.latitude,
  174. longitude: p.longitude,
  175. // joinCluster: true, // 指定了该参数才会参与聚合
  176. label: {
  177. width: 150,
  178. height: 30,
  179. textAlign: 'center',
  180. content: p.storeName
  181. }
  182. }
  183. )
  184. })
  185. },
  186. // 点击地图上的点
  187. handleMarkerTap(marker) {
  188. console.log('Marker tapped:', marker);
  189. console.log(this.storeList[marker.markerId])
  190. },
  191. // 打电话
  192. makePhone(phoneNumber) {
  193. uni.makePhoneCall({
  194. phoneNumber: phoneNumber
  195. });
  196. },
  197. // 去下单页面
  198. gotoOrder(item) {
  199. this.type = '2';
  200. this.selectStore(item);
  201. },
  202. },
  203. };
  204. </script>
  205. <style scoped lang="scss">
  206. .h-store-wrap {
  207. margin-top: 12px;
  208. background: #fff;
  209. padding-top: 4px;
  210. padding-left: 12px;
  211. padding-right: 12px;
  212. border-radius: 12px;
  213. .h-store-content {
  214. margin-top: 12px;
  215. margin-bottom: 12px;
  216. background: #fafafa;
  217. padding: 12px;
  218. border-radius: 6px;
  219. font-family: PingFangSC-Regular, PingFang SC;
  220. .h-row {
  221. display: flex;
  222. justify-content: space-between;
  223. .h-left-value {
  224. .h-name {
  225. font-size: 28rpx;
  226. font-weight: 400;
  227. color: #333333;
  228. line-height: 40rpx;
  229. }
  230. .h-text {
  231. font-size: 24rpx;
  232. font-weight: 400;
  233. color: #999999;
  234. line-height: 40rpx;
  235. display: flex;
  236. align-items: center;
  237. image {
  238. margin-right: 12rpx;
  239. height: 24rpx;
  240. width: 24rpx;
  241. }
  242. }
  243. }
  244. .h-right-value {
  245. .h-text {
  246. font-size: 10px;
  247. font-weight: 400;
  248. color: #999999;
  249. line-height: 18px;
  250. }
  251. }
  252. .h-flex {
  253. display: flex;
  254. justify-content: space-between;
  255. image {
  256. height: 30px;
  257. width: 30px;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. .h-area-wrap {
  264. margin-right: 12px;
  265. margin-left: 12px;
  266. margin-top: 12px;
  267. }
  268. .h-search {
  269. font-size: 14px;
  270. display: flex;
  271. padding-left: 12px;
  272. padding-top: 8px;
  273. padding-right: 12px;
  274. background: #fff;
  275. padding-bottom: 8px;
  276. border-radius: 6px;
  277. .h-time {
  278. width: 30%;
  279. display: flex;
  280. .time {
  281. padding-right: 2px;
  282. }
  283. }
  284. .h-name {
  285. width: 70%;
  286. text-align: right;
  287. display: flex;
  288. justify-content: flex-end;
  289. .name {
  290. padding-right: 6px;
  291. }
  292. }
  293. }
  294. </style>