gcz 2 жил өмнө
parent
commit
35b2edf1ab

+ 5 - 0
common/apiurl.js

@@ -304,6 +304,11 @@ const apiurl = {
 		url: '/memberCreditDesc/getRegistinfoByName',
 		type: 'get'
 	},
+	// 带参小程序解码
+	uncompress: {
+		url: '/common/uncompress',
+		type: 'get'
+	},
 }
 
 

+ 6 - 1
pages/index/index.vue

@@ -133,7 +133,12 @@
 				hotGoods:[]
 			}
 		},
-		onLoad() {
+		onLoad(query) {
+			const scene = decodeURIComponent(query.scene);
+			scene&&uni.setStorage({
+				key:'scene',
+				data:scene
+			});
 			// let userInfo = uni.getStorageSync('userInfo');
 			// console.log('userInfo',userInfo);
 			let that = this;

+ 26 - 3
pages/login/login.vue

@@ -115,6 +115,7 @@
 				customStyleUnOk:{},
 				customStyleOk:{'margin-left': '30px',color:'#00A447'},
 				backUrl:null,
+				scene:'',
 			};
 		},
 		onLoad() {
@@ -165,7 +166,7 @@
 					success(res) {
 						//成功后带着微信登录返回的code去请求我们的后端
 						that.code = res.code;
-						console.log('code',that.code);
+						// console.log('code',that.code);
 					}
 				})
 			},
@@ -209,6 +210,15 @@
 				this.showAuthorizePhone=false;
 				this.loginBtn = false;
 				let _this = this;
+				
+				await uni.getStorage({
+					key: 'scene',
+					success: function (res) {
+						// console.log('scene====',res.data);
+						_this.scene = res.data;
+					}
+				});
+				
 				// this.getMobile()
 				let mobileData = await this.$u.api.getMobile({code:e.detail.code});
 				console.log('mobileData',mobileData);
@@ -243,14 +253,27 @@
 					sourceType:1,
 					mobile:this.mobile
 				}
+				if(this.scene!='undefined'){
+					await this.$u.api.uncompress({scene:this.scene}).then(res=>{
+						data.agentId = res.data.agentId;
+						data.agentShopId = res.data.agentShopId;
+						// console.log('uncompress',res.data);
+					}).catch(err=>{
+						console.log('uncompress',err);
+					})
+				}
 				// console.log('----------登陆中',data)
 				this.$u.api.login(data).then(res=>{
-					console.log('微信登录返回结果========',res.data)
+					// console.log('微信登录返回结果========',res.data)
 					_this.$u.vuex('vuex_user_info', res.data);
 					// _this.$u.vuex('vuex_member_info',res.data);
 					// uni.setStorageSync('userInfo', res.data)
-					this.showAuthorizePhone = false
+					this.showAuthorizePhone = false;
+					uni.removeStorage({
+						key:'scene'
+					});
 					this.getMemberInfo(res.data.userid);
+					
 				}).catch(err=>{
 					console.log('err',err);
 					this.showAuthorizePhone = false