Prechádzať zdrojové kódy

授权登录逻辑修改

hwb0 3 rokov pred
rodič
commit
47b2c81b1c
1 zmenil súbory, kde vykonal 38 pridanie a 12 odobranie
  1. 38 12
      pages/login/index.vue

+ 38 - 12
pages/login/index.vue

@@ -32,20 +32,46 @@
 		},
 		methods: {
 			getPhoneNumber(e) {
+				let _this = this
 				uni.showLoading({
 					title: '登录中'
 				});
-				$http.post('/api/v1/mp/user/wxauth/mobile', {
-					code: e.detail.code,
-					identity: 1
-				}).then(res => {
-					if (res.code == 0) {
-						uni.setStorageSync('token', res.token)
-						this.getBaseInfo()
-					}
-				}).catch(() => {
-					uni.hideLoading();
-				})
+				console.log(e);
+				if (e.detail & e.detail.code) {
+					$http.post('/api/v1/mp/user/wxauth/mobile', {
+						...e.detail,
+						identity: 1,
+						noToken: true
+					}).then(res => {
+						uni.hideLoading();
+						if (res.code == 0) {
+							uni.setStorageSync('token', res.token)
+							_this.getBaseInfo()
+						}
+					}).catch(() => {
+						uni.hideLoading();
+					})
+				}else{
+					uni.login({
+						success(res) {
+							console.log('login', res);
+							$http.post('/api/v1/mp/user/wxauth/mobile', {
+								...e.detail,
+								loginCode: res.code,
+								identity: 1,
+								noToken: true
+							}).then(res => {
+								uni.hideLoading();
+								if (res.code == 0) {
+									uni.setStorageSync('token', res.token)
+									_this.getBaseInfo()
+								}
+							}).catch(() => {
+								uni.hideLoading();
+							})
+						}
+					})
+				}
 			},
 
 			// 关闭授权
@@ -90,7 +116,7 @@
 
 	.login {
 		flex-direction: column;
-		
+
 		&-image {
 			flex-direction: column;
 			padding: 100rpx 0 200rpx;