chenxiong 3 سال پیش
والد
کامیت
c74b313d31
1فایلهای تغییر یافته به همراه42 افزوده شده و 5 حذف شده
  1. 42 5
      pages/login/login.vue

+ 42 - 5
pages/login/login.vue

@@ -33,8 +33,8 @@
 				</view>
 			</view>
 			
-			<view  class="wxBtn" v-if="false">
-				<button type="default"  class="wxloginBtn"></button>
+			<view  class="wxBtn">
+				<button type="default" open-type="getPhoneNumber" @getphonenumber="wxLogin" class="wxloginBtn"></button>
 				<view style="text-align: center;color: #999999;font-size: 24rpx;margin-top: 10rpx;">微信快捷登录</view>
 			</view>
 		</view>
@@ -117,17 +117,54 @@ export default {
 		if(option.isBack){
 			this.isBack = option.isBack;
 		}
-		/* let that = this;
-		this.from = option.from;
+		let that = this;
+		// this.from = option.from; 
 		uni.login({
 			provider: 'weixin',
 			success: function(loginRes) {
 				that.code = loginRes.code;
 			}
-		}); */
+		});
 	},
 	mounted() {},
 	methods: {
+		wxLogin(e) {
+			
+			console.log(e)
+						
+			this.$api.wxLogin({
+				code: this.code,
+				encryptedData: e.detail.encryptedData,
+				iv:  e.detail.iv
+			}).then(res => {
+				if(res.data.data.full_info){
+					//信息完善,直接进入页面
+					uni.setStorageSync('user_account', res.data.data.user_account);
+					uni.setStorageSync('token', res.data.data.token);
+					this.$api.getInfo().then(resdata => {
+						if(resdata.data.code == 200){
+							this.$store.state.userInfo = resdata.data.data;
+							
+							if(!this.isBack){
+								uni.reLaunch({
+									url:'/pages/index/index'
+								})
+							}else{
+								uni.navigateBack();
+							}
+						}
+						
+					});
+					
+				}else{
+					//未完善信息,存为临时信息
+					uni.setStorageSync('user_account_temp', res.data.data.user_account);
+					uni.setStorageSync('token_temp', res.data.data.token);
+					this.$navTo.togo('/pages2/register/bind');
+				}	
+				
+			})
+		},
 		canLogin() {
 			if(this.current == 0) {
 				if(this.form.account && this.form.pwd) {