Bladeren bron

登录流程

LuoDLeo 2 jaren geleden
bovenliggende
commit
9730850e0e

+ 1 - 1
App.vue

@@ -22,7 +22,7 @@
                             // })
                         }else {
                             uni.navigateTo({
-                                url: '/loginPages/bindAccount/index',
+                                url: '/pages/login/login',
                             })
                         }
 

+ 8 - 7
loginPages/login/bind-account.vue

@@ -5,7 +5,6 @@
 			<u--form
 				labelPosition="left"
 				:model="userInfo"
-				:rules="rules"
 				ref="form1"
 			>
 				<u-form-item
@@ -94,14 +93,17 @@ export default {
 	data() {
 		return {
 			errShow: false,
-			userInfo: {},
+			userInfo: {
+        phonenumber:'',
+        smsCode:''
+      },
 			tips2: '',
 			rules: {
 				phonenumber:  [
 					{
 						required: true,
-						min: 10,
-						max: 12,
+						min: 11,
+						max: 11,
 						message: '请输入11位电话号码',
 						trigger: ['blur', 'change'],
 					},
@@ -127,7 +129,7 @@ export default {
 	},
 	onLoad(option) {
 		// 判断Openid是否为空
-		this.userInfo =	uni.getStorageSync('userInfo');
+		this.userInfo.openId =	uni.getStorageSync('userInfoOpenId');
 	},
 	onReady() {
 		this.$refs.form1.setRules(this.rules)
@@ -154,12 +156,11 @@ export default {
 			// 验证电话号码是否存在
 			this.$api.phoneIsExist({data:this.userInfo}).then((res)=>{
 				console.log(res)
-				if(!res.phoneIsExist){ // 存在
+				if(res.phoneIsExist){ // 存在
 					that.errShow = true;
 				} else {
 					that.userInfo.phone = that.userInfo.phonenumber;
 					that.userInfo.type = "1";
-					console.log("++++++++++++++++++++++")
 					uni.navigateTo({
 						url: '/loginPages/login/bind-transaction-password?data='+JSON.stringify(that.userInfo),
 					})

+ 23 - 29
loginPages/login/bind-transaction-password.vue

@@ -101,7 +101,7 @@ export default {
 	},
 	onLoad(option) {
 		// 判断Openid是否为空
-		if(!this.$isDataEmpty(option)){
+		if(option != undefined){
 			this.userInfo = JSON.parse(option.data);
 		}
 	},
@@ -133,16 +133,14 @@ export default {
 		wechatRegister(){
 			const that = this;
 			// 新微信新手机注册账号
-			wechatRegister(null,{data:this.userInfo}).then((res)=>{
-				console.log(res)
-				console.log(res.access_token)
-				if(!this.$isDataEmpty(res.access_token)){
-					that.setUserData(res);
-				} else {
-					uni.showToast({
-						title: "用户注册失败"
-					})
-				}
+      this.$api.wechatRegister({...this.userInfo}).then((res)=>{
+       if(res.data.code == 200){
+         that.setUserData(res);
+       }else {
+         uni.showToast({
+           title: "用户注册失败"
+         })
+       }
 			}).catch(() =>{
 				uni.showToast({
 					title: "操作失败"
@@ -150,17 +148,16 @@ export default {
 			});
 		},
 		realNameAuthLogin(){
+      const that = this;
 			// 新微信老手机注册账号
-			realNameAuthLogin(null,{data:this.userInfo}).then((res)=>{
-				console.log(res)
-				console.log(res.access_token)
-				if(!this.$isDataEmpty(res.access_token)){
-					that.setUserData(res);
-				} else {
-					uni.showToast({
-						title: "用户注册失败"
-					})
-				}
+      this.$api.realNameAuthLogin({...this.userInfo}).then((res)=>{
+        if(res.data.code == 200){
+          that.setUserData(res);
+        }else {
+          uni.showToast({
+            title: "用户注册失败"
+          })
+        }
 			}).catch(() =>{
 				uni.showToast({
 					title: "操作失败"
@@ -174,15 +171,12 @@ export default {
 				accessToken: ""
 			}
 			// 数据获取token
-			loginState.accessToken = res.access_token;
+			loginState.accessToken = res.data.access_token;
 			this.$store.commit('updateLoginState', loginState);
-			this.$store.commit('updateLoginUserInfo', res.userInfo)
-			uni.$u.route({
-				url: '/pages/index/tabbar',
-				params: {
-					PageCur: 'index'
-				}
-			})
+			this.$store.commit('updateLoginUserInfo', res.data.userInfo)
+      uni.switchTab({
+        url: '/pages/index/index',
+      })
 		},
 
 	}

+ 12 - 6
loginPages/login/login-old-account.vue

@@ -116,12 +116,18 @@ export default {
 			// 根据手机和密码找回账号,成功自动登录
 			this.$api.wechatRetrieveAccountPwdLogin(this.reqParm).then((res)=>{
 
-				uni.setStorageSync('userInfo',res.userInfo)
-				uni.setStorageSync('accessToken',res.access_token)
-				uni.switchTab({
-					url: '/pages/index/index',
-				})
-
+			  if (res.data.code == 200){
+          uni.setStorageSync('userInfo',res.userInfo)
+          uni.setStorageSync('accessToken',res.access_token)
+          uni.switchTab({
+            url: '/pages/index/index',
+          })
+        }else {
+          uni.showToast({
+            icon: 'error',
+            title: "操作失败"
+          })
+        }
 			}).catch(() =>{
 				uni.showToast({
 					title: "操作失败"

+ 2 - 1
pages/login/login.vue

@@ -128,7 +128,7 @@
 			},
 			// 自动登录不成功,用户手动授权登录
 			authWechatCodeLogin(){
-				if(!this.userInfo.openId){
+				if(this.userInfo == undefined){
 					this.show = true;
 				}
 			},
@@ -140,6 +140,7 @@
 					success(re) {
 						that.$api.wxAuthLogin({code:re.code}).then(res=>{
 							that.userInfo = res.data.data.userInfo
+							uni.setStorageSync('userInfoOpenId',res.data.data.openId)
 							uni.setStorageSync('userInfo',res.data.data.userInfo)
 							uni.setStorageSync('accessToken',res.data.data.access_token)
 							uni.setStorageSync('phoneIsBind',res.data.data.phoneIsBind)