store-choose.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. console.log(this.navigateRouter)
  129. if(this.navigateRouter == 1){
  130. uni.reLaunch({
  131. url: '/orderPages/storeService/index'
  132. })
  133. uni.removeStorage({
  134. key: 'router'
  135. });
  136. }else if(this.navigateRouter == 2){
  137. uni.reLaunch({
  138. url: '/orderPages/bookService/index'
  139. })
  140. uni.removeStorage({
  141. key: 'router'
  142. });
  143. }else {
  144. uni.switchTab({
  145. url: '/pages/index/index'
  146. })
  147. }
  148. },
  149. // 获取门店列表数据
  150. getStoreListData() {
  151. let that = this;
  152. this.$api.storeList({
  153. latitude: this.latitude,
  154. longitude: this.longitude,
  155. }).then((res) => {
  156. console.log(res)
  157. that.storeList = res.data.data
  158. // 添加坐标点
  159. that.addMarkers();
  160. }).catch(() => {
  161. console.log("获取用户门店列表报错")
  162. })
  163. },
  164. addMarkers() {
  165. this.markers = []
  166. // 处理点的数据
  167. this.storeList.forEach((p, i) => {
  168. this.markers.push(
  169. {
  170. id: i,
  171. iconPath: '/static/index/u55.png',
  172. width: 30,
  173. height: 30,
  174. latitude: p.latitude,
  175. longitude: p.longitude,
  176. // joinCluster: true, // 指定了该参数才会参与聚合
  177. label: {
  178. width: 150,
  179. height: 30,
  180. textAlign: 'center',
  181. content: p.storeName
  182. }
  183. }
  184. )
  185. })
  186. },
  187. // 点击地图上的点
  188. handleMarkerTap(marker) {
  189. console.log('Marker tapped:', marker);
  190. console.log(this.storeList[marker.markerId])
  191. },
  192. // 打电话
  193. makePhone(phoneNumber) {
  194. uni.makePhoneCall({
  195. phoneNumber: phoneNumber
  196. });
  197. },
  198. // 去下单页面
  199. gotoOrder(item) {
  200. this.type = '2';
  201. this.selectStore(item);
  202. },
  203. },
  204. };
  205. </script>
  206. <style scoped lang="scss">
  207. .h-store-wrap {
  208. margin-top: 12px;
  209. background: #fff;
  210. padding-top: 4px;
  211. padding-left: 12px;
  212. padding-right: 12px;
  213. border-radius: 12px;
  214. .h-store-content {
  215. margin-top: 12px;
  216. margin-bottom: 12px;
  217. background: #fafafa;
  218. padding: 12px;
  219. border-radius: 6px;
  220. font-family: PingFangSC-Regular, PingFang SC;
  221. .h-row {
  222. display: flex;
  223. justify-content: space-between;
  224. .h-left-value {
  225. .h-name {
  226. font-size: 28rpx;
  227. font-weight: 400;
  228. color: #333333;
  229. line-height: 40rpx;
  230. }
  231. .h-text {
  232. font-size: 24rpx;
  233. font-weight: 400;
  234. color: #999999;
  235. line-height: 40rpx;
  236. display: flex;
  237. align-items: center;
  238. image {
  239. margin-right: 12rpx;
  240. height: 24rpx;
  241. width: 24rpx;
  242. }
  243. }
  244. }
  245. .h-right-value {
  246. .h-text {
  247. font-size: 10px;
  248. font-weight: 400;
  249. color: #999999;
  250. line-height: 18px;
  251. }
  252. }
  253. .h-flex {
  254. display: flex;
  255. justify-content: space-between;
  256. image {
  257. height: 30px;
  258. width: 30px;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. .h-area-wrap {
  265. margin-right: 12px;
  266. margin-left: 12px;
  267. margin-top: 12px;
  268. }
  269. .h-search {
  270. font-size: 14px;
  271. display: flex;
  272. padding-left: 12px;
  273. padding-top: 8px;
  274. padding-right: 12px;
  275. background: #fff;
  276. padding-bottom: 8px;
  277. border-radius: 6px;
  278. .h-time {
  279. width: 30%;
  280. display: flex;
  281. .time {
  282. padding-right: 2px;
  283. }
  284. }
  285. .h-name {
  286. width: 70%;
  287. text-align: right;
  288. display: flex;
  289. justify-content: flex-end;
  290. .name {
  291. padding-right: 6px;
  292. }
  293. }
  294. }
  295. </style>