store-choose.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="container">
  3. <!-- 地图容器 -->
  4. <view class="map-wrap">
  5. <map class="tencent-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. :show-location="false"
  14. @markertap="handleMarkerTap"
  15. >
  16. </map>
  17. </view>
  18. <!-- 地区 -->
  19. <!-- <view class="h-area-wrap">
  20. <view class="h-search">
  21. <view class="h-time">
  22. <view class="time">{{areaName}}</view>
  23. <u-icon name="arrow-down" color="#000" size="18"></u-icon>
  24. </view>
  25. <view class="h-name">
  26. </view>
  27. </view>
  28. </view> -->
  29. <!-- 门店列表 -->
  30. <view class="h-store-wrap">
  31. <view v-for="(item,index) in storeList" class="h-store-content">
  32. <view @click="selectStore(item)" class="h-row">
  33. <view class="h-left-value">
  34. <text class="h-name">{{item.storeName}}</text>
  35. </view>
  36. <!-- <view class="h-right-value">-->
  37. <!-- <text class="h-text">{{item.distanceDesc}}</text>-->
  38. <!-- </view>-->
  39. </view>
  40. <view class="h-row" @click="selectStore(item)">
  41. <view class="h-left-value">
  42. <view class="h-text">
  43. <image src="../../static/goods/dingwei.png" mode=""></image>
  44. <text>地址:{{item.address}}</text>
  45. </view>
  46. <view class="h-text">
  47. <image src="../../static/goods/time.png" mode=""></image>
  48. 营业时间:
  49. <text>{{item.tradeTime}}~{{item.gooutTime}}</text>
  50. </view>
  51. <view class="h-text">
  52. <image src="../../static/goods/zixun.png" mode=""></image>
  53. 咨询热线:
  54. <text>{{item.phone || ''}}</text>
  55. </view>
  56. </view>
  57. <view>
  58. <view class="h-right-value flex-row justify-between">
  59. <view class="phone" @click.stop="makePhoneCall(item.phone)">
  60. <image src="../../static/goods/phone.png" mode=""></image>
  61. </view>
  62. <view class="sure" @click.stop="openmap(item)">
  63. <image src="../../static/goods/daohang.png" mode=""></image>
  64. </view>
  65. </view>
  66. <view class="juli">
  67. {{item.distanceDesc}}
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. markers:[],
  80. areaName: '贵阳市',
  81. latitude: 26.5737,
  82. longitude: 106.7135,
  83. scale: 12,
  84. img: '/static/index/u55.png',
  85. reqParm: {
  86. auth: true,
  87. longitude: 0,
  88. latitude: 0
  89. },
  90. storeList: [],
  91. type: '1',
  92. navigateRouter:null
  93. }
  94. },
  95. onReady() {
  96. // 初始化地图
  97. // this.initMap();
  98. },
  99. onLoad(option) {
  100. this.getLocation()
  101. // 判断Openid是否为空
  102. if (option.type) {
  103. this.type = option.type;
  104. }
  105. },
  106. onShow(){
  107. this.navigateRouter = uni.getStorageSync('router');
  108. },
  109. methods: {
  110. openmap(selfTake) {
  111. uni.openLocation({
  112. latitude: selfTake.latitude * 1,
  113. longitude: selfTake.longitude * 1,
  114. address: selfTake.address,
  115. success: function () {
  116. console.log('success');
  117. },
  118. fail(err){
  119. console.log(err,"++++++++++++++++++++++++++++++")
  120. },
  121. });
  122. },
  123. makePhoneCall(phone){
  124. if (!phone){
  125. uni.$u.toast('该门店没有设置电话')
  126. return
  127. }
  128. uni.makePhoneCall({
  129. phoneNumber:phone
  130. })
  131. },
  132. getLocation() {
  133. let that = this
  134. uni.getLocation({
  135. type: 'gcj02',
  136. success: function (res) {
  137. that.latitude = res.latitude; // 纬度
  138. that.longitude = res.longitude; // 经度
  139. let mapContext = uni.createMapContext("map", this);
  140. mapContext.moveToLocation()
  141. },
  142. fail: function (fail) {
  143. console.log('获取用户地址失败==》', fail)
  144. },
  145. complete: function (complete) {
  146. console.log('获取用户地址失败or成功==》', complete)
  147. // 获取商店数据
  148. that.getStoreListData();
  149. }
  150. })
  151. },
  152. // 选择门店
  153. selectStore(item) {
  154. // 更新用户选择的门店信息
  155. uni.setStorageSync('storeInfo', item);
  156. console.log(this.navigateRouter)
  157. if(this.navigateRouter == 1){
  158. uni.reLaunch({
  159. url: '/orderPages/storeService/index'
  160. })
  161. uni.removeStorage({
  162. key: 'router'
  163. });
  164. }else if(this.navigateRouter == 2){
  165. uni.reLaunch({
  166. url: '/orderPages/bookService/index'
  167. })
  168. uni.removeStorage({
  169. key: 'router'
  170. });
  171. }else {
  172. uni.switchTab({
  173. url: '/pages/index/index'
  174. })
  175. }
  176. },
  177. // 获取门店列表数据
  178. getStoreListData() {
  179. let that = this;
  180. this.$api.storeList({
  181. latitude: this.latitude,
  182. longitude: this.longitude,
  183. }).then((res) => {
  184. console.log(res)
  185. that.storeList = res.data.data
  186. that.latitude = res.data.data[0].latitude
  187. that.longitude = res.data.data[0].longitude
  188. // 添加坐标点
  189. that.addMarkers();
  190. }).catch(() => {
  191. console.log("获取用户门店列表报错")
  192. })
  193. },
  194. addMarkers() {
  195. this.markers = []
  196. // 处理点的数据
  197. this.storeList.forEach((p, i) => {
  198. this.markers.push(
  199. {
  200. id: i,
  201. iconPath: '/static/index/address.png',
  202. width: 28,
  203. height: 35,
  204. latitude: p.latitude,
  205. longitude: p.longitude,
  206. // joinCluster: true, // 指定了该参数才会参与聚合
  207. // label: {
  208. // width: 150,
  209. // height: 30,
  210. // // display:'ALWAYS',
  211. // // borderWidth:200,
  212. // // bgColor:'#ffffff',
  213. // textAlign: 'center',
  214. // content: p.storeName
  215. // },
  216. callout: {
  217. // width: 150,
  218. // height: 30,
  219. display:'ALWAYS',
  220. borderWidth:6,
  221. color:'#ffffff',//文字颜色
  222. borderRadius:5,//边框圆角
  223. fontSize:14,//文本大小
  224. bgColor:'#645d57',//背景颜色
  225. borderColor: '#645d57',
  226. textAlign: 'center',
  227. content: p.storeName
  228. },
  229. // callout:{//自定义标记点上方的气泡窗口 点击有效
  230. // content: p.storeName,//文本
  231. // color:'#000000',//文字颜色
  232. // // fontSize:14,//文本大小
  233. // borderRadius:15,//边框圆角
  234. // borderWidth:'5',
  235. // bgColor:'#ffffff',//背景颜色
  236. // display:'ALWAYS',//常显
  237. // },
  238. }
  239. )
  240. })
  241. },
  242. // 点击地图上的点
  243. handleMarkerTap(marker) {
  244. console.log('Marker tapped:', marker);
  245. console.log(this.storeList[marker.markerId])
  246. },
  247. // 打电话
  248. makePhone(phoneNumber) {
  249. uni.makePhoneCall({
  250. phoneNumber: phoneNumber
  251. });
  252. },
  253. // 去下单页面
  254. gotoOrder(item) {
  255. this.type = '2';
  256. this.selectStore(item);
  257. },
  258. },
  259. };
  260. </script>
  261. <style scoped lang="scss">
  262. .h-store-wrap {
  263. margin-top: 12px;
  264. background: #fff;
  265. padding-top: 4px;
  266. padding-left: 12px;
  267. padding-right: 12px;
  268. border-radius: 12px;
  269. .h-store-content {
  270. margin-top: 12px;
  271. margin-bottom: 12px;
  272. background: #fafafa;
  273. padding: 12px;
  274. border-radius: 6px;
  275. font-family: PingFangSC-Regular, PingFang SC;
  276. .h-row {
  277. display: flex;
  278. justify-content: space-between;
  279. .h-left-value {
  280. .h-name {
  281. font-size: 28rpx;
  282. font-weight: 400;
  283. color: #333333;
  284. line-height: 40rpx;
  285. }
  286. .h-text {
  287. font-size: 24rpx;
  288. font-weight: 400;
  289. color: #999999;
  290. line-height: 40rpx;
  291. display: flex;
  292. align-items: center;
  293. image {
  294. margin-right: 12rpx;
  295. height: 24rpx;
  296. width: 24rpx;
  297. }
  298. }
  299. }
  300. .h-right-value {
  301. width: 100rpx;
  302. .h-text {
  303. font-size: 10px;
  304. font-weight: 400;
  305. color: #999999;
  306. line-height: 18px;
  307. }
  308. image {
  309. height: 40rpx;
  310. width: 40rpx;
  311. }
  312. }
  313. .h-flex {
  314. display: flex;
  315. justify-content: space-between;
  316. }
  317. }
  318. }
  319. }
  320. .h-area-wrap {
  321. margin-right: 12px;
  322. margin-left: 12px;
  323. margin-top: 12px;
  324. }
  325. .h-search {
  326. font-size: 14px;
  327. display: flex;
  328. padding-left: 12px;
  329. padding-top: 8px;
  330. padding-right: 12px;
  331. background: #fff;
  332. padding-bottom: 8px;
  333. border-radius: 6px;
  334. .h-time {
  335. width: 30%;
  336. display: flex;
  337. .time {
  338. padding-right: 2px;
  339. }
  340. }
  341. .h-name {
  342. width: 70%;
  343. text-align: right;
  344. display: flex;
  345. justify-content: flex-end;
  346. .name {
  347. padding-right: 6px;
  348. }
  349. }
  350. }
  351. .juli{
  352. text-align: center;
  353. font-size: 24rpx;
  354. font-weight: 400;
  355. color: #999999;
  356. line-height: 40rpx;
  357. }
  358. /* 隐藏腾讯地图版权标识 */
  359. .tencent-map .qq-map-copyright {
  360. display: none;
  361. }
  362. </style>