ソースを参照

fix: 优化获取门店列表

zhanghui 2 年 前
コミット
61465afe5f
2 ファイル変更30 行追加3 行削除
  1. 16 2
      pages/index/index.vue
  2. 14 1
      storePages/store/store-choose.vue

+ 16 - 2
pages/index/index.vue

@@ -241,6 +241,7 @@
 		},
 		data() {
 			return {
+				isGetAddress:true, //是否获取到了经纬度
 				noticeList: [],
 				notice: '',
 				userInfo: {},
@@ -266,6 +267,14 @@
 			// 查询门店信息
 			const data = uni.getStorageSync('storeInfo');
 			if (!data) {
+				setTimeout(e=>{
+					console.log('定时器要执行了 isGetAddress =>',this.isGetAddress)
+					if (this.isGetAddress){
+						console.log('定时器执行了isGetAddress =>',this.isGetAddress)
+						this.isGetAddress = !this.isGetAddress
+						this.getStoreListData(this.reqParm)
+					}
+				},5000)
 				// 获取位置信息查询门店列表数据
 				this.getLocation();
 			} else {
@@ -301,7 +310,7 @@
 				console.log("用户扫技师端或者拓客端二维码传递过来的参数",param)
 			}
 
-			this.getLocation();
+
 
 			//公告信息
 			this.getNoticeListData();
@@ -490,7 +499,12 @@
 					},
 					complete: function(complete) {
 						console.log('获取用户地址失败or成功==》', complete)
-						that.getStoreListData(that.reqParm)
+						if (that.isGetAddress){
+							console.log("根据位置获取门店执行了 isGetAddress =>",that.isGetAddress)
+							that.isGetAddress = !that.isGetAddress
+							that.getStoreListData(that.reqParm)
+						}
+
 					}
 				});
 			},

+ 14 - 1
storePages/store/store-choose.vue

@@ -81,6 +81,7 @@
     export default {
         data() {
             return {
+                isGetAddress:true, //是否获取到了经纬度
                 markers:[],
                 areaName: '贵阳市',
                 latitude: 26.5737,
@@ -106,6 +107,14 @@
 
 
             this.getLocation()
+            setTimeout(e=>{
+                console.log('定时器要执行了 isGetAddress =>',this.isGetAddress)
+                if (this.isGetAddress){
+                    console.log('定时器执行了isGetAddress =>',this.isGetAddress)
+                    this.isGetAddress = !this.isGetAddress
+                    this.getStoreListData()
+                }
+            },5000)
             // 判断Openid是否为空
             if (option.type) {
                 this.type = option.type;
@@ -157,7 +166,11 @@
                     complete: function (complete) {
                         console.log('获取用户地址失败or成功==》', complete)
                         // 获取商店数据
-                        that.getStoreListData();
+                        if (that.isGetAddress){
+                            console.log("根据位置获取门店执行了 isGetAddress =>",that.isGetAddress)
+                            that.isGetAddress = !that.isGetAddress
+                            that.getStoreListData()
+                        }
                     }
                 })
             },