Ver código fonte

refactor:首页选择门店

zhanghui 2 anos atrás
pai
commit
203c1fa113
3 arquivos alterados com 50 adições e 54 exclusões
  1. 10 0
      pages.json
  2. 14 19
      pages/index/index.vue
  3. 26 35
      storePages/store/store-choose.vue

+ 10 - 0
pages.json

@@ -123,6 +123,16 @@
 					"navigationStyle": "custom"
 				}
 			}]
+		},
+		{
+			"root": "storePages",
+			"pages": [{
+				"path": "store/store-choose",
+				"style": {
+					"navigationBarTitleText": "选择门店",
+					"enablePullDownRefresh": false
+				}
+			}]
 		}
 	],
 	"tabBar": {

+ 14 - 19
pages/index/index.vue

@@ -253,20 +253,8 @@
 				storeInfo: {}
 			};
 		},
-		mounted() {
-			// 获取经纬度信息
-			this.getLocation();
-
-			//公告信息
-			this.getNoticeListData();
-
-			// 获取banner图列表
-			this.getSlideshowList();
-
-			// 用户信息
-			this.userInfo = uni.getStorageSync('userInfo');
-			this.getImgUrlByOssId(this.userInfo.selfPhoto);
 
+		onShow(){
 			// 查询门店信息
 			const data = uni.getStorageSync('storeInfo');
 			if(!data){
@@ -276,14 +264,24 @@
 			} else {
 				this.storeInfo = data;
 			}
-
 		},
 		onLoad(){
 			uni.hideTabBar({
 				animation:false
 			})
 
+			// 获取经纬度信息
+			this.getLocation();
+
+			//公告信息
+			this.getNoticeListData();
+
+			// 获取banner图列表
+			this.getSlideshowList();
 
+			// 用户信息
+			this.userInfo = uni.getStorageSync('userInfo');
+			this.getImgUrlByOssId(this.userInfo.selfPhoto);
 		},
 		// 分享到朋友圈
 		onShareTimeline() {},
@@ -427,11 +425,8 @@
 
 			// 去选择门店
 			gotoStoreChoose(){
-				uni.$u.route({
-					url: '/pages/goods/store-choose',
-					params: {
-						type: '1'
-					}
+				uni.navigateTo({
+					url: '/storePages/store/store-choose?type=1',
 				})
 			},
 			// 去再来一单

+ 26 - 35
storePages/store/store-choose.vue

@@ -1,22 +1,22 @@
 <template>
 	<view class="container">
-		
+
 		<!-- 地图容器 -->
 		<view class="map-wrap">
-			<map style="width: 100%; height: 300px;" 
+			<map style="width: 100%; height: 300px;"
 				id="map"
-				:latitude="latitude" 
-				:longitude="longitude" 
+				:latitude="latitude"
+				:longitude="longitude"
 				:scale="scale"
 				:show-location="true"
 				 @markertap="handleMarkerTap"
 				>
 			</map>
 		</view>
-		
+
 		<!-- 地区 -->
-		<!-- <view class="h-area-wrap"> 
-		    
+		<!-- <view class="h-area-wrap">
+
 			<view class="h-search">
 			  <view class="h-time">
 				  <view  class="time">{{areaName}}</view>
@@ -26,7 +26,7 @@
 			  </view>
 			</view>
 		</view> -->
-		
+
 		<!-- 门店列表 -->
 		<view class="h-store-wrap">
 			<view v-for="(item,index) in storeList" class="h-store-content">
@@ -50,10 +50,10 @@
 						</view>
 					</view>
 					<view class="h-right-value h-flex">
-						<view @click="makePhone(item)" class="phone">
+						<view  class="phone">
 							<image src="../../static/goods/u291.png" mode=""></image>
 						</view>
-						<view @click="gotoOrder(item)" class="sure">
+						<view  class="sure">
 							<image src="../../static/goods/u292.png" mode=""></image>
 						</view>
 					</view>
@@ -64,7 +64,6 @@
 </template>
 
 <script>
-import {storeList} from '/src/api/goods/goods.js';
 export default {
   data() {
     return {
@@ -109,12 +108,12 @@ export default {
   	this.initMap();
   },
   onLoad(option) {
-	  
+
 	// 获取商店数据
 	this.getStoreListData();
-	
+
 	// 判断Openid是否为空
-	if(!this.$isDataEmpty(option.type)){
+	if(option.type){
 		this.type = option.type;
 	}
   },
@@ -122,28 +121,20 @@ export default {
 	// 选择门店
 	selectStore(item){
 		// 更新用户选择的门店信息
-		this.$store.commit('updateStoreInfo',  item);
-		let pageCur = 'index';
-		if(this.type == '2'){
-			pageCur = 'goods';
-		}
-		uni.$u.route({
-			url: '/pages/index/tabbar',
-			params: {
-				PageCur: pageCur
-			}
+		uni.setStorageSync('storeInfo',  item);
+
+		uni.switchTab({
+			url: '/pages/index/index',
 		})
 	},
 	// 获取门店列表数据
 	getStoreListData(){
 		let that = this;
-		storeList({data:this.reqParm}).then((res)=>{
+		this.$api.storeList({data:this.reqParm}).then((res)=>{
 			console.log(res)
-			if(res.length>0){
-				that.storeList = res
+				that.storeList = res.data.data
 				// 添加坐标点
 				// that.addMarkers();
-			}
 		}).catch(() =>{
 			console.log("获取用户门店列表报错")
 			// uni.showToast({
@@ -153,7 +144,7 @@ export default {
 	},
 	initMap(){
 		this._mapContext = uni.createMapContext("map", this);
-		
+
 		// 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})
 		this._mapContext.initMarkerCluster({
 			enableDefaultStyle: false,
@@ -163,11 +154,11 @@ export default {
 			  console.log('initMarkerCluster', res)
 			}
 		});
-	
+
 		this._mapContext.on("markerClusterCreate", (e) => {
 			console.log("markerClusterCreate", e);
 		});
-	
+
 	},
 	addMarkers() {
 		const markers = []
@@ -195,7 +186,7 @@ export default {
 			},p)
 		  )
 		})
-		
+
 		// 添加点
 		this._mapContext.addMarkers({
 			markers,
@@ -205,7 +196,7 @@ export default {
 			}
 		})
 	},
-	
+
 	// 点击地图上的点
 	handleMarkerTap(marker){
 		console.log('Marker tapped:', marker);
@@ -214,7 +205,7 @@ export default {
 	// 打电话
 	makePhone(phoneNumber){
 		uni.makePhoneCall({
-			phoneNumber: phoneNumber 
+			phoneNumber: phoneNumber
 		});
 	},
 	// 去下单页面
@@ -318,4 +309,4 @@ export default {
 		}
 	}
 }
-</style>
+</style>