Refactor(登录):登录按钮去掉判断逻辑,一直显示
This commit is contained in:
@@ -131,7 +131,7 @@
|
|||||||
<view class="v12-mt-3 v12-font-32 v12-dark-text v12-font-weight-600">发现家乡好物</view>
|
<view class="v12-mt-3 v12-font-32 v12-dark-text v12-font-weight-600">发现家乡好物</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btn-box">
|
<view class="btn-box">
|
||||||
<button class="btn-yes v12-primary" type="mini" v-if="canIUseGetUserProfile" @tap="getUserInfoProfile">快捷登录</button>
|
<button class="btn-yes v12-primary" type="mini" @tap="getUserInfoProfile">快捷登录</button>
|
||||||
<!-- <button class="btn-no" type="default" @tap="back">拒绝</button> -->
|
<!-- <button class="btn-no" type="default" @tap="back">拒绝</button> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="agree-box v12-align-center">
|
<view class="agree-box v12-align-center">
|
||||||
@@ -171,7 +171,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||||
authorize: false,
|
authorize: false,
|
||||||
canIUseGetUserProfile: false,
|
|
||||||
agreeInfo: {},
|
agreeInfo: {},
|
||||||
isAgree: [],
|
isAgree: [],
|
||||||
show: false,
|
show: false,
|
||||||
@@ -188,9 +187,6 @@ export default {
|
|||||||
...mapState(['isAuthorization', '$deviceType', 'token']),
|
...mapState(['isAuthorization', '$deviceType', 'token']),
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if (wx.getUserProfile) {
|
|
||||||
this.canIUseGetUserProfile = true
|
|
||||||
}
|
|
||||||
// 先校验用户是否授权,如果没有授权,显示授权按钮
|
// 先校验用户是否授权,如果没有授权,显示授权按钮
|
||||||
getAgree().then(({data}) => this.agreeInfo = data);
|
getAgree().then(({data}) => this.agreeInfo = data);
|
||||||
},
|
},
|
||||||
@@ -227,18 +223,19 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
doneRedirect() {
|
doneRedirect() {
|
||||||
let redirectUrl = cookie.get('redirect') || "";
|
let redirectUrl = cookie.get('redirect') || ''
|
||||||
redirectUrl = redirectUrl.replace(/\ /g, '');
|
redirectUrl = redirectUrl.replace(/\ /g, '')
|
||||||
//如果已经是授权页,跳转主页
|
// 如果已经是授权页,跳转主页
|
||||||
if (redirectUrl == '/pages/authorization/index' || redirectUrl.length === 0) {
|
if (redirectUrl == '/pages/authorization/index' || redirectUrl.length === 0) {
|
||||||
redirectUrl = '/pages/home/index';
|
redirectUrl = '/pages/home/index'
|
||||||
}
|
}
|
||||||
this.$yrouter.reLaunch({
|
this.$yrouter.reLaunch({
|
||||||
path: redirectUrl,
|
path: redirectUrl
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getUserInfoProfile() {
|
getUserInfoProfile() {
|
||||||
if (!this.isAgree[0]) {
|
const _this = this
|
||||||
|
if (!_this.isAgree[0]) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请先阅读并同意《用户服务协议及隐私政策》",
|
title: "请先阅读并同意《用户服务协议及隐私政策》",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@@ -246,33 +243,33 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
wx.getUserProfile({
|
wx.getUserProfile({
|
||||||
lang: 'zh_CN',
|
lang: 'zh_CN',
|
||||||
desc: '需要获取您的信息用来展示',
|
desc: '需要获取您的信息用来展示',
|
||||||
success: res => {
|
success: res => {
|
||||||
uni.showLoading({
|
_this.loginReq(res)
|
||||||
title: '登录中',
|
}
|
||||||
})
|
})
|
||||||
login(res).then(e => {
|
},
|
||||||
let db_nickname = e.data.nickname;
|
loginReq(res) {
|
||||||
|
uni.showLoading({
|
||||||
if (db_nickname === null || db_nickname === undefined || db_nickname === "" || db_nickname === "微信用户") {
|
title: '登录中'
|
||||||
this.showFillOut = true;
|
})
|
||||||
} else {
|
login(res).then(e => {
|
||||||
this.doneRedirect();
|
const db_nickname = e.data.nickname
|
||||||
}
|
if (db_nickname === null || db_nickname === undefined || db_nickname === '' || db_nickname === '微信用户') {
|
||||||
}).catch(error => {
|
this.showFillOut = true
|
||||||
uni.showToast({
|
} else {
|
||||||
title: error,
|
this.doneRedirect()
|
||||||
icon: 'none',
|
}
|
||||||
duration: 2000,
|
}).catch(error => {
|
||||||
})
|
uni.showToast({
|
||||||
})
|
title: error,
|
||||||
},
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
onChooseAvatar(e) {
|
onChooseAvatar(e) {
|
||||||
const {avatarUrl} = e.detail;
|
const {avatarUrl} = e.detail;
|
||||||
this.avatarUrl = avatarUrl;
|
this.avatarUrl = avatarUrl;
|
||||||
|
|||||||
+2
-2
@@ -924,10 +924,10 @@ export const handleLoginFailure = () => {
|
|||||||
|
|
||||||
store.commit("logout");
|
store.commit("logout");
|
||||||
store.commit("updateAuthorization", false);
|
store.commit("updateAuthorization", false);
|
||||||
let currentPageUrl = getCurrentPageUrl()
|
const currentPageUrl = getCurrentPageUrl()
|
||||||
// token 失效
|
// token 失效
|
||||||
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转
|
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转
|
||||||
if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') {
|
if (store.getters.isAuthorizationPage || currentPageUrl == '/pages/user/Login/index' || currentPageUrl === '/pages/authorization/index') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
store.commit("updateAuthorizationPage", true);
|
store.commit("updateAuthorizationPage", true);
|
||||||
|
|||||||
Reference in New Issue
Block a user