store-choose.vue 13 KB

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