Browse Source

auto commit

gcz 4 years ago
parent
commit
474816661f
1 changed files with 23 additions and 10 deletions
  1. 23 10
      pages/login/loginType.vue

+ 23 - 10
pages/login/loginType.vue

@@ -90,31 +90,31 @@
 							        // console.log('userInfo',res.data);
 									if(res.data.phone){
 										serf.havePhone = true;
+										this.loginSuccess();										
 									}else{
 										return;
 									}
 							    }
 							});
 							
-							if(serf.backUrl == '' || !serf.backUrl){
-								uni.switchTab({
-									url: '/pages/index/index'
-								})
-							}else{
-								uni.navigateTo({
-									url:serf.backUrl
-								})
-							}
+							
 						})
 					},
 				})
 				
 			},
 			onGetPhoneNumber(e){
+				if(e.detail.errMsg=="getPhoneNumber:fail user deny"){
+					this.$api.msg('拒绝授权,可以下次绑定哟!',2000);
+					setTimeout(()=>{
+						this.loginSuccess();
+					},2000);
+					return;
+				};
 				let serf = this;
 				let userinfo = e.detail;
 				let token = uni.getStorageSync('accessToken').accessToken;
-				console.log('token',token);
+				// console.log('token',token);
 				console.log('e',e);
 				uni.login({
 					provider:'weixin',
@@ -133,6 +133,7 @@
 							Authorization: 'Bearer '+ token, //注意Bearer后面有一空格
 						},
 						}).then(res=>{
+							console.log('res11',res);
 							serf.upInfo();
 							let userKey = uni.getStorageSync('userInfo');
 							if(serf.backUrl == '' || !serf.backUrl){
@@ -152,6 +153,18 @@
 				uni.navigateTo({
 					url:'/pages/login/companyLogin'
 				})
+			},
+			loginSuccess(){
+				let serf = this;
+				if(serf.backUrl == '' || !serf.backUrl){
+					uni.switchTab({
+						url: '/pages/index/index'
+					})
+				}else{
+					uni.navigateTo({
+						url:serf.backUrl
+					})
+				}
 			}
 
 		}