feat: 跳转逻辑修改

This commit is contained in:
mayubo@gmail.com 2025-05-12 11:01:50 +08:00
parent 7966cfb14c
commit 2c9b9718cb
4 changed files with 15 additions and 13 deletions

View File

@ -305,7 +305,6 @@
async getUserInfo() {
const isCtoken = uni.getStorageSync('ctoken');
console.log('12313131313', isCtoken)
if (!isCtoken) return;
const res = await request(apiArr.loginInfo, 'POST', {});
const newUserInfo = {
@ -322,7 +321,6 @@
},
onShow() {
console.log('111');
this.getUserInfo();
},
}

File diff suppressed because one or more lines are too long

View File

@ -19318,11 +19318,10 @@ var NavgateTo = function NavgateTo(path) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$isLogin = options.isLogin,
isLogin = _options$isLogin === void 0 ? true : _options$isLogin;
var userId = uni.getStorageSync('userId'); // 假设这个方法存在并返回用户信息
var ctoken = uni.getStorageSync('ctoken');
if (isLogin) {
if (!userId) {
uni.navigateTo({
if (!ctoken) {
uni.redirectTo({
url: '/pages/login/login'
});
return;
@ -19396,10 +19395,13 @@ var request = function request(url) {
complete: function complete(res) {
if (res.cancel) {
uni.hideLoading();
uni.redirectTo({
url: '/pages/index/index'
});
return;
}
if (res.confirm) {
uni.navigateTo({
uni.redirectTo({
url: '/pages/login/login'
});
}

View File

@ -11,11 +11,10 @@ export const picUrl = 'https://test.hshuishang.com'; // 图片地址前缀
*/
export const NavgateTo = (path, options = {}) => {
const { isLogin = true } = options;
const userId = uni.getStorageSync('userId'); // 假设这个方法存在并返回用户信息
const ctoken = uni.getStorageSync('ctoken');
if (isLogin) {
if (!userId) {
uni.navigateTo({ url: '/pages/login/login' })
if (!ctoken) {
uni.redirectTo({ url: '/pages/login/login' })
return
} else {
uni.navigateTo({
@ -79,11 +78,14 @@ export const request = (url, method = 'POST', data = {}, options = {}) => {
complete: (res) => {
if (res.cancel) {
uni.hideLoading();
uni.redirectTo({
url: '/pages/index/index'
});
return
}
if (res.confirm) {
uni.navigateTo({
uni.redirectTo({
url: '/pages/login/login',
})
}