更新
This commit is contained in:
parent
bea72124de
commit
a88e408682
@ -1,4 +1,5 @@
|
||||
const TokenKey = 'App-Token'
|
||||
const TenantIdKey = 'TENANT_ID'
|
||||
|
||||
export function getToken() {
|
||||
return uni.getStorageSync(TokenKey)
|
||||
@ -11,3 +12,10 @@ export function setToken(token) {
|
||||
export function removeToken() {
|
||||
return uni.removeStorageSync(TokenKey)
|
||||
}
|
||||
|
||||
export function setTenantId(TenantId) {
|
||||
return uni.setStorageSync(TenantIdKey, TenantId);
|
||||
}
|
||||
export function getTenantId(){
|
||||
return uni.getStorageSync(TenantIdKey)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import store from '@/store'
|
||||
import config from '@/config'
|
||||
import {
|
||||
getTenantId,
|
||||
getToken
|
||||
} from '@/utils/auth'
|
||||
import errorCode from '@/utils/errorCode'
|
||||
@ -28,6 +29,17 @@ const request = config => {
|
||||
url = url.slice(0, -1)
|
||||
config.url = url
|
||||
}
|
||||
// 设置租户
|
||||
const isTanantId = (config.headers || {}).isTanantId === false
|
||||
config.header = config.header || {}
|
||||
if (!config.hasOwnProperty("tenantIdFlag")) {
|
||||
//请求设置了不需要租户,不拼接,,走进这里的是没设置不需要租户的
|
||||
if (getTenantId() && !isTanantId) {
|
||||
config.header['tenant-id'] = getTenantId()
|
||||
}
|
||||
config.header['tenant-id'] = 180
|
||||
}
|
||||
console.log(config.header, 424242);
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
method: config.method || 'get',
|
||||
|
Loading…
Reference in New Issue
Block a user