请求头
parent
30251f5035
commit
8743495495
|
|
@ -4,14 +4,14 @@ import { useUserStoreWithOut } from '@/store/modules/user';
|
||||||
const { apiUrl } = useGlobSetting();
|
const { apiUrl } = useGlobSetting();
|
||||||
const systemInfo = uni.getSystemInfoSync();
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
const http = new Request();
|
const http = new Request();
|
||||||
|
console.log(systemInfo);
|
||||||
http.setConfig((config) => {
|
http.setConfig((config) => {
|
||||||
config.baseURL = apiUrl;
|
config.baseURL = apiUrl;
|
||||||
config.timeout = 10000;
|
config.timeout = 10000;
|
||||||
config.header = Object.assign({
|
config.header = Object.assign({
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
// 'app-cli-os': android/ios,
|
'app-cli-os': systemInfo.platform,
|
||||||
// 'app-cli-version': 100
|
'app-cli-version': systemInfo.appVersionCode
|
||||||
}, config.header);
|
}, config.header);
|
||||||
/* 设置全局配置 */
|
/* 设置全局配置 */
|
||||||
config.validateStatus = (statusCode) => {
|
config.validateStatus = (statusCode) => {
|
||||||
|
|
@ -51,7 +51,7 @@ http.interceptors.response.use(async (response) => {
|
||||||
// 处理响应结果
|
// 处理响应结果
|
||||||
const { statusCode, data } = response
|
const { statusCode, data } = response
|
||||||
if (statusCode >= 400) {
|
if (statusCode >= 400) {
|
||||||
if(statusCode === 401) {
|
if (statusCode === 401) {
|
||||||
const userStore = useUserStoreWithOut();
|
const userStore = useUserStoreWithOut();
|
||||||
userStore.logout();
|
userStore.logout();
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue