bug修复
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
export const assetsUrl = (name: string) => `https://img.lakeapp.cn/wx/images/${name}`;
|
||||
export const defaultAvatar = 'https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132';
|
||||
|
||||
export const defaultImage = '/static/images/ic_noimage.svg';
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const TokenKey = 'accessToken';
|
||||
const SessionKey = 'sessionKey';
|
||||
const OpenIdKey = 'openId';
|
||||
const CompanyIdKey = 'companyId';
|
||||
const ReferrerUserIdKey = 'referrerUserId';
|
||||
const RegisterStoreIdKey = 'storeId';
|
||||
@@ -22,10 +23,18 @@ function getSessionKey() {
|
||||
return uni.getStorageSync(SessionKey);
|
||||
}
|
||||
|
||||
function setSessionKey(sessionKey: string){
|
||||
function setSessionKey(sessionKey: string) {
|
||||
uni.setStorageSync(SessionKey, sessionKey);
|
||||
}
|
||||
|
||||
function getOpenId() {
|
||||
return uni.getStorageSync(OpenIdKey);
|
||||
}
|
||||
|
||||
function setOpenId(openId: string) {
|
||||
uni.setStorageSync(OpenIdKey, openId);
|
||||
}
|
||||
|
||||
function getCompanyId() {
|
||||
return uni.getStorageSync(CompanyIdKey);
|
||||
}
|
||||
@@ -63,6 +72,8 @@ export {
|
||||
setToken,
|
||||
getSessionKey,
|
||||
setSessionKey,
|
||||
getOpenId,
|
||||
setOpenId,
|
||||
getCompanyId,
|
||||
setCompanyId,
|
||||
getReferrerUserId,
|
||||
|
@@ -13,18 +13,24 @@ export class Logger {
|
||||
info(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.info(key, value);
|
||||
} else {
|
||||
console.info(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
warn(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.warn(key, value);
|
||||
}else {
|
||||
console.warn(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
error(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.error(key, value);
|
||||
}else {
|
||||
console.error(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import type { HttpError, HttpRequestConfig, HttpResponse } from 'uview-plus/libs/luch-request';
|
||||
import { getCompanyId, getToken } from '@/utils/auth';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { showMessage } from '@/utils/request/status';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
// 是否正在刷新token的标记
|
||||
let isRefreshing: boolean = false;
|
||||
@@ -22,7 +22,7 @@ function requestInterceptors() {
|
||||
const token = getToken();
|
||||
if(token && config.header) {
|
||||
config.header.token = token;
|
||||
config.header.companyid = getCompanyId();
|
||||
config.header.companyid = getApp().globalData?.companyId;
|
||||
|
||||
// config.header.contentType = "x-www-form-urlencoded"
|
||||
}
|
||||
@@ -53,7 +53,7 @@ function responseInterceptors() {
|
||||
return data;
|
||||
}
|
||||
|
||||
getApp().globalData?.logger.info('response: ', config);
|
||||
getApp().globalData?.logger.info('response: ', data);
|
||||
|
||||
// 请求成功则返回结果
|
||||
if(data.code === 200 || data?.retcode == 0) {
|
||||
@@ -61,7 +61,7 @@ function responseInterceptors() {
|
||||
}
|
||||
|
||||
// 登录状态失效,重新登录
|
||||
if(data.code === 401) {
|
||||
if(data.code === 4011) {
|
||||
// 是否在获取token中,防止重复获取
|
||||
if(!isRefreshing) {
|
||||
// 修改登录状态为true
|
||||
|
Reference in New Issue
Block a user