feat: 新增拼团

This commit is contained in:
2026-09-29 10:55:30 +08:00
parent f7b9e66172
commit d9142b0ac7
36 changed files with 7689 additions and 878 deletions
+118 -68
View File
@@ -25,6 +25,50 @@ function hideLoading() {
}
}
function getCurrentPageFullPath() {
try {
// #ifdef H5
if (typeof window !== "undefined" && window.location) {
const hash = window.location.hash || "";
if (hash) {
const cleanHash = hash.replace(/^#\/?/, "/");
if (cleanHash && !cleanHash.includes("login_package/login/login")) {
return cleanHash;
}
}
}
// #endif
const pages = getCurrentPages();
if (pages && pages.length) {
const cur = pages[pages.length - 1];
if (cur) {
// #ifdef H5
if (cur.$route && cur.$route.fullPath && !cur.$route.fullPath.includes("login_package/login/login")) {
return cur.$route.fullPath;
}
// #endif
if (cur.route && !cur.route.includes("login_package/login/login")) {
let path = cur.route.startsWith("/") ? cur.route : "/" + cur.route;
const opts = cur.pageOptions || cur.options || cur.$page?.options || {};
const keys = Object.keys(opts);
if (keys.length > 0) {
const qs = keys
.map((k) => `${k}=${encodeURIComponent(opts[k])}`)
.join("&");
path += (path.includes("?") ? "&" : "?") + qs;
}
return path;
}
}
}
} catch (e) {
console.error("获取当前页面完整路径失败:", e);
}
return "";
}
function request(options) {
const {
url,
@@ -76,77 +120,83 @@ function request(options) {
reject(new Error('服务请求失败,请稍后重试'));
return;
}
if (data.status === 500) {
uni.showToast({
title: "系统异常,请稍后再试",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
mask: false, // 是否显示透明蒙层,防止触摸穿透
});
if (data.status === 500) {
uni.showToast({
title: "系统异常,请稍后再试",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
mask: false, // 是否显示透明蒙层,防止触摸穿透
});
reject(new Error('系统异常,请稍后再试'));
return;
}
// 601 微信登录没注册
if (data.bizcode === 100) {
resolve(data); // 成功时返回数据
} else if (data.bizcode === 201) {
if ([201, 200].includes(data.errcode)) {
uni.showToast({
title: "登录失效,请重新登录",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
mask: false, // 是否显示透明蒙层,防止触摸穿透
position: "middle", // 位置,可选 top/middle/bottom
});
} else {
uni.showToast({
title: data.msg,
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
mask: false, // 是否显示透明蒙层,防止触摸穿透
position: "middle", // 位置,可选 top/middle/bottom
});
}
/**
* 205:已经有账号,返回登录页面
* 200 or 201:token失效,返回登录页面
*/
if ([201, 200, 205].includes(data.errcode)) {
uni.removeStorageSync(TOKEN_NAME);
uni.removeStorageSync(USER_DATA);
let timer = setTimeout(() => {
clearTimeout(timer);
timer = null;
uni.navigateTo({
url: "/pages/login_package/login/login",
});
}, 2000);
}
}
// 601 微信登录没注册
if (data.bizcode === 100) {
resolve(data); // 成功时返回数据
} else if (data.bizcode === 201) {
if ([201, 200].includes(data.errcode)) {
uni.showToast({
title: "登录失效,请重新登录",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
mask: false, // 是否显示透明蒙层,防止触摸穿透
position: "middle", // 位置,可选 top/middle/bottom
});
} else {
uni.showToast({
title: data.msg,
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
mask: false, // 是否显示透明蒙层,防止触摸穿透
position: "middle", // 位置,可选 top/middle/bottom
});
}
/**
* 205:已经有账号,返回登录页面
* 200 or 201:token失效,返回登录页面
*/
if ([201, 200, 205].includes(data.errcode)) {
uni.removeStorageSync(TOKEN_NAME);
uni.removeStorageSync(USER_DATA);
let timer = setTimeout(() => {
clearTimeout(timer);
timer = null;
const fullPath = getCurrentPageFullPath();
if (fullPath) {
uni.setStorageSync("login_redirect_url", fullPath);
}
const redirectParam = fullPath ? "?redirect=" + encodeURIComponent(fullPath) : "";
uni.navigateTo({
url: `/pages/login_package/login/login${redirectParam}`,
});
}, 2000);
}
reject(data);
} else {
console.log("错误-1", data, url);
uni.showToast({
title: data.msg || "系统错误,请稍后再试",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
});
reject(data); // 其他错误情况返回错误信息
}
},
fail: (error) => {
console.log("错误-2", url);
if (isShowLoading) {
hideLoading();
}
uni.showToast({
title: "服务器异常,稍后再试",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
});
console.log("错误-1", data, url);
uni.showToast({
title: data.msg || "系统错误,请稍后再试",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
});
reject(data); // 其他错误情况返回错误信息
}
},
fail: (error) => {
console.log("错误-2", url);
if (isShowLoading) {
hideLoading();
}
uni.showToast({
title: "服务器异常,稍后再试",
icon: "none", // 可选 success/loading/none
duration: 2000, // 持续时长,单位ms
});
reject(error);
},
});
});
}
},
});
});
}
export default request;