优化登录的逻辑,
This commit is contained in:
@ -1,32 +1,45 @@
|
||||
// import router from "../router";
|
||||
import store from "../store";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import { isWeixin, login, getCurrentPageUrl, getCurrentPageUrlWithArgs, parseQuery, replace, handleQrCode } from "@/utils";
|
||||
import {
|
||||
isWeixin,
|
||||
login,
|
||||
replaceLogin,
|
||||
getCurrentPageUrl,
|
||||
getCurrentPageUrlWithArgs,
|
||||
parseQuery,
|
||||
replace,
|
||||
handleQrCode
|
||||
} from "@/utils";
|
||||
|
||||
export default function toLogin(push, backUrl) {
|
||||
store.commit("LOGOUT");
|
||||
if (store.getters.isAuthorization) {
|
||||
login()
|
||||
return
|
||||
}
|
||||
if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') {
|
||||
return
|
||||
}
|
||||
store.commit("LOGOUT");
|
||||
// 如果没有授权,走登录的接口重新授权
|
||||
// 授权获取失败会跳转到授权的接口
|
||||
if (store.getters.isAuthorization) {
|
||||
login()
|
||||
return
|
||||
}
|
||||
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转
|
||||
if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') {
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是不是扫描的砍价海报进来的
|
||||
if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) {
|
||||
let url = handleQrCode();
|
||||
if (url) {
|
||||
console.log(222222222)
|
||||
replace({ path: '/pages/user/Login/index', query: { redirect: `/${getCurrentPageUrl()}`, id: url.bargainId, partake: url.uid } })
|
||||
} else {
|
||||
replace({ path: '/pages/user/Login/index', query: { redirect: `/${getCurrentPageUrl()}`, ...parseQuery() } })
|
||||
}
|
||||
} else {
|
||||
console.log(222222222)
|
||||
replace({ path: '/pages/user/Login/index', query: { redirect: `/${getCurrentPageUrl()}`, ...parseQuery() } })
|
||||
}
|
||||
store.commit("UPDATE_AUTHORIZATION", false);
|
||||
store.commit("UPDATE_AUTHORIZATIONPAGE", true);
|
||||
// 判断是不是扫描的砍价海报进来的
|
||||
if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) {
|
||||
let url = handleQrCode();
|
||||
if (url) {
|
||||
replaceLogin({
|
||||
redirect: `/${getCurrentPageUrl()}`,
|
||||
id: url.bargainId,
|
||||
partake: url.uid
|
||||
})
|
||||
} else {
|
||||
replaceLogin()
|
||||
}
|
||||
} else {
|
||||
replaceLogin()
|
||||
}
|
||||
store.commit("UPDATE_AUTHORIZATION", false);
|
||||
store.commit("UPDATE_AUTHORIZATIONPAGE", true);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
export const weappPay = (option) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 吊起微信支付
|
||||
wx.requestPayment({
|
||||
uni.requestPayment({
|
||||
...option,
|
||||
timeStamp: option.timeStamp + '',
|
||||
success: (success) => {
|
||||
|
Reference in New Issue
Block a user