feat:"完成页面接口的对接"

This commit is contained in:
2026-01-29 17:58:19 +08:00
parent 2774a539bf
commit 2b69da3c15
98 changed files with 9504 additions and 592 deletions

View File

@@ -3,8 +3,8 @@ const ENV = new UTSJSONObject(
{
// 开发环境
development: new UTSJSONObject({
baseUrl: "http://localhost:3000/api",
imageBaseUrl: "http://localhost:3000"
baseUrl: "http://192.168.1.43:3000/api",
imageBaseUrl: "http://192.168.1.43:3000"
}),
// 生产环境
production: new UTSJSONObject({
@@ -46,15 +46,27 @@ const SOFA_CATEGORIES = [
new UTSJSONObject({ id: "antique", name: "古典沙发" }),
new UTSJSONObject({ id: "office", name: "办公沙发" })
];
const SERVICE_TYPES = [
[
new UTSJSONObject({ id: "repair", name: "局部修复", icon: "/static/icons/repair.png" }),
new UTSJSONObject({ id: "recolor", name: "改色翻新", icon: "/static/icons/recolor.png" }),
new UTSJSONObject({ id: "refurbish", name: "整体翻新", icon: "/static/icons/refurbish.png" }),
new UTSJSONObject({ id: "custom", name: "定制换皮", icon: "/static/icons/custom.png" })
new UTSJSONObject({ id: "refurbish", name: "整体翻新", icon: "/static/icons/refurbish.png" })
];
const getServiceTypeName = (type) => {
var _a;
const map = /* @__PURE__ */ new Map([
["leather", "真皮翻新"],
["fabric", "布艺翻新"],
["functional", "功能维修"],
["antique", "古董修复"],
["office", "办公沙发"],
["cleaning", "清洁保养"],
["repair", "维修改装"],
["custom", "定制沙发"]
]);
return (_a = UTS.mapGet(map, type)) !== null && _a !== void 0 ? _a : type;
};
exports.PAGE_SIZE = PAGE_SIZE;
exports.SERVICE_TYPES = SERVICE_TYPES;
exports.SOFA_CATEGORIES = SOFA_CATEGORIES;
exports.STORAGE_KEYS = STORAGE_KEYS;
exports.getEnvConfig = getEnvConfig;
exports.getServiceTypeName = getServiceTypeName;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/config.js.map

View File

@@ -39,7 +39,7 @@ class ResponseData extends UTS.UTSType {
return {
code: { type: Number, optional: false },
message: { type: String, optional: false },
data: { type: "Any", optional: false }
data: { type: "Any", optional: true }
};
},
name: "ResponseData"
@@ -65,17 +65,29 @@ const requestInterceptor = (options) => {
return options;
};
const responseInterceptor = (response) => {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f;
const statusCode = response["statusCode"];
const data = response["data"];
common_vendor.index.__f__("log", "at utils/request.uts:47", "响应拦截器 - statusCode:", statusCode);
common_vendor.index.__f__("log", "at utils/request.uts:48", "响应拦截器 - data:", data);
if (data == null) {
return new ResponseData({
code: statusCode,
message: "响应数据为空",
data: null
});
}
if (statusCode == 200) {
const code = (_a = data["code"]) !== null && _a !== void 0 ? _a : 0;
common_vendor.index.__f__("log", "at utils/request.uts:61", "响应拦截器 - 解析的 code:", code);
if (code == 0 || code == 200) {
return new ResponseData({
const result = new ResponseData({
code: 0,
message: "success",
data: data["data"]
message: (_b = data["message"]) !== null && _b !== void 0 ? _b : "success",
data: (_c = data["data"]) !== null && _c !== void 0 ? _c : null
});
common_vendor.index.__f__("log", "at utils/request.uts:68", "响应拦截器 - 返回成功结果:", result);
return result;
} else if (code == 401) {
common_vendor.index.removeStorageSync(utils_config.STORAGE_KEYS.TOKEN);
common_vendor.index.showToast({
@@ -84,14 +96,14 @@ const responseInterceptor = (response) => {
});
return new ResponseData({
code,
message: (_b = data["message"]) !== null && _b !== void 0 ? _b : "请重新登录",
message: (_d = data["message"]) !== null && _d !== void 0 ? _d : "请重新登录",
data: null
});
} else {
return new ResponseData({
code,
message: (_c = data["message"]) !== null && _c !== void 0 ? _c : "请求失败",
data: null
message: (_e = data["message"]) !== null && _e !== void 0 ? _e : "请求失败",
data: (_f = data["data"]) !== null && _f !== void 0 ? _f : null
});
}
} else {
@@ -113,6 +125,13 @@ const request = (options) => {
}
const config = utils_config.getEnvConfig();
const baseUrl = config["baseUrl"];
if (finalOptions.data && typeof finalOptions.data === "object") {
for (const key in finalOptions.data) {
if (finalOptions.data[key] === void 0) {
delete finalOptions.data[key];
}
}
}
common_vendor.index.request({
url: baseUrl + finalOptions.url,
method: (_c = finalOptions.method) !== null && _c !== void 0 ? _c : "GET",
@@ -122,10 +141,15 @@ const request = (options) => {
if (finalOptions.showLoading == true) {
common_vendor.index.hideLoading();
}
common_vendor.index.__f__("log", "at utils/request.uts:150", "请求成功原始响应:", res);
const result = responseInterceptor(res);
common_vendor.index.__f__("log", "at utils/request.uts:152", "拦截器处理后结果:", result);
common_vendor.index.__f__("log", "at utils/request.uts:153", "result.code 类型:", typeof result.code, "值:", result.code);
if (result.code == 0) {
common_vendor.index.__f__("log", "at utils/request.uts:155", "判断为成功resolve");
resolve(result);
} else {
common_vendor.index.__f__("log", "at utils/request.uts:158", "判断为失败,显示 toast 并 reject");
common_vendor.index.showToast({
title: result.message,
icon: "none"