fix:修复登录过期不自动退出逻辑

This commit is contained in:
wangsongsole 2022-10-17 16:59:52 +08:00
parent 1e5a0b7b0b
commit 16016b9248
3 changed files with 29 additions and 12 deletions

View File

@ -346,15 +346,21 @@
} }
if (this.isLogin) { if (this.isLogin) {
/*跳转起始页面*/ this.delayedOut()
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, 3000);
} }
}, },
/* 延时自动退出 */
delayedOut (time = 1) {
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, time * 1000);
},
//兑换商品 //兑换商品
exchangeGoodsFn () { exchangeGoodsFn () {
if (this.goodsDetail.type === 1) { /* 兑换码 */ if (this.goodsDetail.type === 1) { /* 兑换码 */
@ -433,6 +439,7 @@
} else { } else {
this.openErrorDialog(res.message); this.openErrorDialog(res.message);
if (res.code == 403) { if (res.code == 403) {
this.delayedOut(3)
this.isLogin = true this.isLogin = true
} }
} }

View File

@ -156,13 +156,18 @@
/* 重定向 */ /* 重定向 */
backFunction () { backFunction () {
if (this.redirect) { if (this.redirect) {
let entryLink = localStorage.getItem('entryLink'); this.delayedOut()
setTimeout(() => {
window.location.replace(entryLink);
}, 1000);
} }
}, },
/* 延时自动退出 */
delayedOut (time = 1) {
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, time * 1000);
},
/* 请求数据 */ /* 请求数据 */
getCouponList () { getCouponList () {
const token = localStorage.getItem('token') const token = localStorage.getItem('token')
@ -179,7 +184,9 @@
this.popText = message this.popText = message
this.popStatus = 2 this.popStatus = 2
this.popShow = true this.popShow = true
return this.redirect = true this.redirect = true
this.delayedOut(3)
return
} }
if (code === 200) { if (code === 200) {
const productArray = [] const productArray = []

View File

@ -208,6 +208,7 @@
req.axiosPut(`/key/order/setPayType/${this.activeOrder.order_number}/${this.active}`).then(({ code, message }) => { req.axiosPut(`/key/order/setPayType/${this.activeOrder.order_number}/${this.active}`).then(({ code, message }) => {
if (code === 403) { if (code === 403) {
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true }) this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
this.toPage(3)
return this.redirect = true return this.redirect = true
} }
@ -226,6 +227,7 @@
req.axiosGet(`/key/coupon/createPay/${this.activeOrder.order_number}`).then(({ code, data, message }) => { req.axiosGet(`/key/coupon/createPay/${this.activeOrder.order_number}`).then(({ code, data, message }) => {
if (code === 403) { if (code === 403) {
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true }) this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
this.toPage(3)
return this.redirect = true return this.redirect = true
} }
@ -260,6 +262,7 @@
req.axiosGet(`/key/order/${token}`, { page: this.page, limit: this.limit }).then(({ data, code, message }) => { req.axiosGet(`/key/order/${token}`, { page: this.page, limit: this.limit }).then(({ data, code, message }) => {
if (code === 403) { if (code === 403) {
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true }) this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
this.toPage(3)
return this.redirect = true return this.redirect = true
} }
if (code === 200) { if (code === 200) {
@ -272,11 +275,11 @@
}, },
/*跳转起始页面*/ /*跳转起始页面*/
toPage () { toPage (time = 1) {
let entryLink = localStorage.getItem('entryLink'); let entryLink = localStorage.getItem('entryLink');
setTimeout(() => { setTimeout(() => {
window.location.replace(entryLink); window.location.replace(entryLink);
}, 1000); }, time * 1000);
}, },
/* 弹窗回调 */ /* 弹窗回调 */