2025-07-15 16:18:34 +08:00
|
|
|
"use strict";
|
|
|
|
|
const common_vendor = require("../vendor.js");
|
|
|
|
|
const common_store_useWeAppAuthStore = require("../store/useWeAppAuthStore.js");
|
|
|
|
|
const http = new common_vendor.Request();
|
|
|
|
|
http.setConfig((config) => {
|
2025-10-29 13:53:05 +08:00
|
|
|
config.baseURL = "http://10.39.13.78:8001/api/";
|
2025-07-15 16:18:34 +08:00
|
|
|
config.header = {
|
|
|
|
|
...config.header
|
|
|
|
|
};
|
|
|
|
|
return config;
|
|
|
|
|
});
|
|
|
|
|
http.interceptors.request.use(
|
|
|
|
|
(config) => {
|
|
|
|
|
config.header = {
|
|
|
|
|
...config.header,
|
|
|
|
|
Authorization: "Bearer " + common_vendor.index.getStorageSync("ACCESS_TOKEN_CUSTOMER")
|
|
|
|
|
};
|
|
|
|
|
return config;
|
|
|
|
|
},
|
|
|
|
|
(config) => {
|
|
|
|
|
return Promise.reject(config);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
http.interceptors.response.use(
|
|
|
|
|
(response) => {
|
|
|
|
|
const data = response.data;
|
|
|
|
|
common_vendor.index.hideLoading();
|
|
|
|
|
if (data.success !== true) {
|
|
|
|
|
if (data.errorCode === 10001) {
|
|
|
|
|
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
|
|
|
|
|
auth.loading = false;
|
|
|
|
|
common_vendor.index.showToast({ title: data.errorMessage, icon: "none" });
|
|
|
|
|
} else {
|
|
|
|
|
common_vendor.index.showToast({ title: data.errorMessage, icon: "none" });
|
|
|
|
|
}
|
|
|
|
|
return Promise.reject(response.data);
|
|
|
|
|
}
|
|
|
|
|
return response.data;
|
|
|
|
|
},
|
|
|
|
|
(response) => {
|
|
|
|
|
console.log("error", response);
|
|
|
|
|
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
|
|
|
|
|
auth.loading = false;
|
|
|
|
|
return Promise.reject(response);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
function request(url, data) {
|
|
|
|
|
return http.post(url, data.data);
|
|
|
|
|
}
|
|
|
|
|
exports.request = request;
|