فهرست منبع

feat:获取用户地址

zhanghui 2 سال پیش
والد
کامیت
948295865a
3فایلهای تغییر یافته به همراه44 افزوده شده و 39 حذف شده
  1. 1 0
      orderPages/storeService/index.vue
  2. 14 10
      pages/index/index.vue
  3. 29 29
      storePages/store/store-choose.vue

+ 1 - 0
orderPages/storeService/index.vue

@@ -85,6 +85,7 @@
 		data() {
 			return {
 				timeoutId:null,
+				templateId:[],
 				periodTimeList:[],
 				userInfo: {},
 				store: {},

+ 14 - 10
pages/index/index.vue

@@ -269,8 +269,8 @@ export default {
     // 查询门店信息
     const data = uni.getStorageSync('storeInfo');
     if (!data) {
-      // 获取门店列表数据
-      this.getStoreListData();
+      // 获取位置信息查询门店列表数据
+      this.getLocation();
     } else {
       this.storeInfo = data;
     }
@@ -303,7 +303,7 @@ export default {
 
     }
 
-    this.getLocation();
+    // this.getLocation();
 
     //公告信息
     this.getNoticeListData();
@@ -430,10 +430,10 @@ export default {
       }
     },
     // 获取门店列表数据
-    getStoreListData() {
+    getStoreListData(data) {
       let that = this;
       // 用户绑定门店
-      this.$api.storeList(this.reqParm).then((res) => {
+      this.$api.storeList(data).then((res) => {
         console.log(res.data.data[0])
         that.storeInfo = res.data.data[0]
         // 更新用户选择的门店信息
@@ -468,7 +468,8 @@ export default {
     },
     // 获取经纬度信息
     getLocation() {
-
+      let that = this
+      console.log('+++++++++++++开始获取位置信息++++++++++++++++')
       uni.getLocation({
         type: 'gcj02',
         success: function (res) {
@@ -479,14 +480,17 @@ export default {
           let accuracy = res.accuracy; // 精确度
           // 在这里可以对位置信息进行处理
           console.log("纬度:" + latitude + ";经度" + longitude)
-          this.reqParm.latitude = latitude
-          this.reqParm.longitude = longitude
+          that.reqParm.latitude = latitude
+          that.reqParm.longitude = longitude
+          uni.setStorageSync('location', that.reqParm)
+          that.getStoreListData(that.reqParm)
         },
         fail:function (fail) {
           console.log('获取用户地址失败==》',fail)
+          that.getStoreListData(that.reqParm)
         },
-        complete:function () {
-
+        complete:function (complete) {
+          console.log('获取用户地址失败or成功==》',complete)
         }
       });
     },

+ 29 - 29
storePages/store/store-choose.vue

@@ -82,27 +82,7 @@ export default {
 		  latitude: 0
 	  },
 	  storeList: [
-	    {
-			latitude: 26.5737,
-			longitude: 106.7135,
-			abcname: '123',
-			idx: 0
-	    }, {
-			latitude: 23.099994,
-			longitude: 113.322520,
-			abcname: '123',
-			idx: 1
-	    }, {
-			latitude: 23.099994,
-			longitude: 113.326520,
-			abcname: '123',
-			idx: 2
-	    }, {
-			latitude: 23.096994,
-			longitude: 113.329520,
-			abcname: '123',
-			idx: 3
-	    }
+
 	  ],
 	  type: '1'
 	}
@@ -116,12 +96,30 @@ export default {
 	// 获取商店数据
 	this.getStoreListData();
 
-	// 判断Openid是否为空
+	  this.getLocation()
+	  // 判断Openid是否为空
 	if(option.type){
 		this.type = option.type;
 	}
   },
   methods: {
+	  getLocation(){
+	  	let that = this
+	  	uni.getLocation({
+			type:'gcj02',
+			success:function () {
+				that.latitude = res.latitude; // 纬度
+				that.longitude = res.longitude; // 经度
+			},
+			fail:function (fail) {
+				console.log('获取用户地址失败==》',fail)
+
+			},
+			complete:function (complete) {
+				console.log('获取用户地址失败or成功==》',complete)
+			}
+		})
+	  },
 	// 选择门店
 	selectStore(item){
 		// 更新用户选择的门店信息
@@ -134,16 +132,16 @@ export default {
 	// 获取门店列表数据
 	getStoreListData(){
 		let that = this;
-		this.$api.storeList({data:this.reqParm}).then((res)=>{
+		this.$api.storeList({
+			latitude:this.latitude,
+			longitude:this.longitude,
+		}).then((res)=>{
 			console.log(res)
 				that.storeList = res.data.data
 				// 添加坐标点
-				// that.addMarkers();
+				that.addMarkers();
 		}).catch(() =>{
 			console.log("获取用户门店列表报错")
-			// uni.showToast({
-			// 	title: "操作失败"
-			// })
 		})
 	},
 	initMap(){
@@ -159,6 +157,8 @@ export default {
 			}
 		});
 
+		this._mapContext.moveToLocation()
+
 		this._mapContext.on("markerClusterCreate", (e) => {
 			console.log("markerClusterCreate", e);
 		});
@@ -173,8 +173,8 @@ export default {
 			Object.assign({},{
 			  id: i,
 			  iconPath: this.img,
-			  width: 50,
-			  height: 50,
+			  width: 30,
+			  height: 30,
 			  // joinCluster: true, // 指定了该参数才会参与聚合
 			  label: {
 				  width: 150,