计分本配置接口接入

This commit is contained in:
kron
2025-08-04 16:28:34 +08:00
parent 54a51d2a28
commit 97d23aa731
9 changed files with 181 additions and 129 deletions

View File

@@ -15,7 +15,7 @@ function request(method, url, data = {}) {
if (res.data) {
const { code, data, message } = res.data;
if (code === 0) resolve(data);
else {
else if (message) {
if (message.indexOf("登录身份已失效") !== -1) {
uni.removeStorageSync("token");
}
@@ -38,7 +38,6 @@ function request(method, url, data = {}) {
if (message === "BIND_DEVICE") {
resolve({ binded: true });
return;
}
if (message === "ERROR_ORDER_UNPAY") {
uni.showToast({
@@ -65,17 +64,17 @@ function request(method, url, data = {}) {
// 统一的错误处理函数
function handleRequestError(err, url) {
console.log('请求失败:', { err, url });
console.log("请求失败:", { err, url });
// 根据错误类型显示不同提示
if (err.errMsg) {
if (err.errMsg.includes('timeout')) {
if (err.errMsg.includes("timeout")) {
showCustomToast("请求超时,请稍后重试", "timeout");
} else if (err.errMsg.includes('fail')) {
} else if (err.errMsg.includes("fail")) {
// 检查网络状态
uni.getNetworkType({
success: (res) => {
if (res.networkType === 'none') {
if (res.networkType === "none") {
showCustomToast("网络连接已断开,请检查网络设置", "network");
} else {
showCustomToast("服务器连接失败,请稍后重试", "server");
@@ -83,7 +82,7 @@ function handleRequestError(err, url) {
},
fail: () => {
showCustomToast("网络异常,请检查网络连接", "unknown");
}
},
});
} else {
showCustomToast("请求失败,请稍后重试", "general");
@@ -98,21 +97,21 @@ function showCustomToast(message, type) {
const config = {
title: message,
icon: "none",
duration: 3000
duration: 3000,
};
// 根据错误类型可以添加不同的处理逻辑
switch (type) {
case 'timeout':
case "timeout":
config.duration = 4000; // 超时提示显示更久
break;
case 'network':
case "network":
config.duration = 5000; // 网络问题提示显示更久
break;
default:
break;
}
uni.showToast(config);
}
@@ -364,3 +363,14 @@ export const getCurrentGameAPI = async () => {
const result = await request("GET", "/user/join/battle");
return result.currentGame || {};
};
export const getPointBookConfigAPI = async () => {
return request("GET", "/user/score/sheet/option");
};
export const getPointBookListAPI = async (page = 1, size = 10) => {
return request(
"GET",
`/user/score/sheet/list?pageNum=${page}&pageSize=${size}`
);
};