|
|
|
|
@ -48,6 +48,9 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class="logon" @click="loginMobile" v-if="current !== 0">登录</div>
|
|
|
|
|
<div class="logon" @click="submit" v-if="current === 0">登录</div>
|
|
|
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
|
|
|
<div class="logon logon-wechat" v-if="current === 0" @click="mpGzhWechatLogin">微信登录</div>
|
|
|
|
|
<!-- #endif -->
|
|
|
|
|
<div class="tips">
|
|
|
|
|
<!-- <div v-if="current==0" @click="current = 1">快速登录</div> -->
|
|
|
|
|
<div v-if="current==1" @click="current = 0">账号登录</div>
|
|
|
|
|
@ -62,6 +65,7 @@
|
|
|
|
|
import {
|
|
|
|
|
loginH5,
|
|
|
|
|
loginMobile,
|
|
|
|
|
loginMpByGzhCode,
|
|
|
|
|
registerVerify,
|
|
|
|
|
register,
|
|
|
|
|
// getCodeApi,
|
|
|
|
|
@ -81,6 +85,11 @@
|
|
|
|
|
import {
|
|
|
|
|
VUE_APP_API_URL
|
|
|
|
|
} from "@/utils";
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
import {
|
|
|
|
|
wxGZHAuth
|
|
|
|
|
} from "@/libs/wechat";
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
const BACK_URL = "login_back_url";
|
|
|
|
|
|
|
|
|
|
@ -106,7 +115,8 @@
|
|
|
|
|
appUserInfo: null, // 微信登录保存的用户信息
|
|
|
|
|
appleLoginStatus: false, // 苹果登录强制绑定手机号码状态
|
|
|
|
|
appleUserInfo: null,
|
|
|
|
|
appleShow: false // 苹果登录版本必须要求ios13以上的
|
|
|
|
|
appleShow: false, // 苹果登录版本必须要求ios13以上的
|
|
|
|
|
pendingGzhCode: '' // 公众号授权未绑定时,随账号密码一并提交
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch:{
|
|
|
|
|
@ -254,7 +264,7 @@
|
|
|
|
|
this.getUserInfo(res.data);
|
|
|
|
|
}
|
|
|
|
|
}).catch(res => {
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
this.$util.Tips({
|
|
|
|
|
title: res
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
@ -370,6 +380,60 @@
|
|
|
|
|
navTap: function(index) {
|
|
|
|
|
this.current = index;
|
|
|
|
|
},
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
async mpGzhWechatLogin() {
|
|
|
|
|
const that = this;
|
|
|
|
|
try {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '授权中'
|
|
|
|
|
});
|
|
|
|
|
const auth = await wxGZHAuth();
|
|
|
|
|
const code = auth && auth.code ? auth.code : '';
|
|
|
|
|
if (!code) {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: '未获取到授权码'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const res = await loginMpByGzhCode(code, that.$Cache.get('spread'));
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
const d = res.data || {};
|
|
|
|
|
if (d.token) {
|
|
|
|
|
that.pendingGzhCode = '';
|
|
|
|
|
that.$store.commit('LOGIN', {
|
|
|
|
|
token: d.token
|
|
|
|
|
});
|
|
|
|
|
that.getUserInfo({
|
|
|
|
|
uid: d.uid
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (d.needBind) {
|
|
|
|
|
that.pendingGzhCode = code;
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '当前微信未绑定账号,请使用账号密码完成绑定登录',
|
|
|
|
|
showCancel: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: d.msg || '登录失败'
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
const msg = (e && e.message) || e || '授权失败';
|
|
|
|
|
if (msg === 'MP_GZH_LOGIN_PENDING') {
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: '公众号登录接口待对接'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: typeof msg === 'string' ? msg : '授权失败'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// #endif
|
|
|
|
|
async submit() {
|
|
|
|
|
let that = this;
|
|
|
|
|
if (!that.account) return that.$util.Tips({
|
|
|
|
|
@ -381,14 +445,20 @@
|
|
|
|
|
if (!that.password) return that.$util.Tips({
|
|
|
|
|
title: '请填写密码'
|
|
|
|
|
});
|
|
|
|
|
loginH5({
|
|
|
|
|
const loginPayload = {
|
|
|
|
|
account: that.account,
|
|
|
|
|
password: that.password,
|
|
|
|
|
spread: that.$Cache.get("spread")
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
// 绑定公众号授权:字段名请与后端约定(示例 mp_gzh_oauth_code)
|
|
|
|
|
if (that.pendingGzhCode) {
|
|
|
|
|
loginPayload.mp_gzh_oauth_code = that.pendingGzhCode;
|
|
|
|
|
}
|
|
|
|
|
loginH5(loginPayload)
|
|
|
|
|
.then(({
|
|
|
|
|
data
|
|
|
|
|
}) => {
|
|
|
|
|
that.pendingGzhCode = '';
|
|
|
|
|
this.$store.commit("LOGIN", {
|
|
|
|
|
'token': data.token
|
|
|
|
|
});
|
|
|
|
|
@ -400,7 +470,7 @@
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getUserInfo(data){
|
|
|
|
|
getUserInfo(data){
|
|
|
|
|
this.$store.commit("SETUID", data.uid);
|
|
|
|
|
getUserInfo().then(res => {
|
|
|
|
|
this.$store.commit("UPDATE_USERINFO", res.data);
|
|
|
|
|
@ -603,6 +673,11 @@ getUserInfo(data){
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logon-wechat {
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
background-color: #07c160;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tips {
|
|
|
|
|
margin: 30rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
|