游客模式

This commit is contained in:
徐哼唧L
2023-12-06 16:26:45 +08:00
parent 52b8c4503b
commit 97ff3915c0
10 changed files with 603 additions and 405 deletions

View File

@@ -125,9 +125,11 @@ $http.requestStart = function(options) {
let storeUserInfo = store.state.userInfo;
if (!storeUserInfo.token) { // nvue页面读取不到vuex里面数据将取缓存
storeUserInfo = uni.getStorageSync("userInfo");
uni.setStorageSync('anonymous', '0000000000');
}
if (storeUserInfo.token) {
options.header['token'] = storeUserInfo.token;
uni.setStorageSync('anonymous', storeUserInfo.token);
};
return options;
}
@@ -161,8 +163,9 @@ $http.dataFactory = async function(res) {
// 返回正确的结果(then接受数据)
return Promise.resolve(httpData);
} else if (httpData.code == "401") {
console.log(uni.getStorageSync("anonymous"))
// token失效
if (uni.getStorageSync('guidePages') == 2) {
if (uni.getStorageSync('guidePages') == 2 && uni.getStorageSync("anonymous") != '0000000000') {
uni.showToast({
title: '登录失效,请重新登录',
icon: 'none'
@@ -295,7 +298,7 @@ $http.dataFactory = async function(res) {
});
} else { //其他错误提示
console.log(httpData.info || httpData.msg)
if (res.isPrompt && res.data.loadAnimate != 'none') {
if (res.isPrompt && res.data.loadAnimate != 'none') {
uni.showToast({
title: httpData.info || httpData.msg,
icon: "none",
@@ -334,4 +337,4 @@ $http.requestError = function(e) {
// });
}
}
export default $http;
export default $http;