优化返回页面

This commit is contained in:
pengxiaolong
2025-05-22 22:05:55 +08:00
parent 6ca66f45d4
commit c55be10783
59 changed files with 3428 additions and 44 deletions

31
components/VerifyLogin.js Normal file
View 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;

View File

@@ -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",

View File

@@ -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);
}
});