优化返回页面
This commit is contained in:
31
components/VerifyLogin.js
Normal file
31
components/VerifyLogin.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function VerifyLogin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
if (res.data) {
|
||||
if (res.data.nickName) {
|
||||
resolve(true);
|
||||
} else {
|
||||
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
|
||||
uni.reLaunch({ url: "/pages/UserInformation/UserInformation" });
|
||||
resolve(false);
|
||||
}
|
||||
} else {
|
||||
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
|
||||
uni.navigateTo({ url: '/pages/login/login' });
|
||||
resolve(false);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("获取用户信息失败", err);
|
||||
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
|
||||
uni.navigateTo({ url: '/pages/login/login' });
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default VerifyLogin;
|
||||
@@ -28,6 +28,7 @@
|
||||
import request from "../../components/request.js";
|
||||
import formatDate from "../../components/formatDate.js";
|
||||
export default {
|
||||
inject: ['$global'],
|
||||
data() {
|
||||
return {
|
||||
page: 0,//页码
|
||||
@@ -50,6 +51,7 @@ export default {
|
||||
},
|
||||
})
|
||||
},
|
||||
formatDate: formatDate,
|
||||
async pkList(){
|
||||
const res = await request({
|
||||
url: "pk/pkList",
|
||||
|
||||
@@ -24,15 +24,17 @@ export default function request(urldata) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$global.lastPage = uni.page.route;
|
||||
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
|
||||
uni.reLaunch({ url: "/pages/UserInformation/UserInformation" })
|
||||
}
|
||||
} else {
|
||||
this.$global.lastPage = uni.page.route;
|
||||
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
|
||||
uni.navigateTo({ url: '/pages/login/login' })
|
||||
}
|
||||
},
|
||||
fail: function (res) {
|
||||
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
|
||||
uni.navigateTo({ url: '/pages/login/login' })
|
||||
reject(res);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user