游客模式
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user