From 97d23aa7311ebf218fee09b90e5f809f90348967 Mon Sep 17 00:00:00 2001 From: kron Date: Mon, 4 Aug 2025 16:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=86=E6=9C=AC=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis.js | 36 ++++++++----- src/components/BowTargetEdit.vue | 19 ++++++- src/components/EditOption.vue | 79 ++++++++------------------- src/components/Header.vue | 8 +-- src/pages/point-book-create.vue | 23 ++++++-- src/pages/point-book-edit.vue | 56 +++++++++++-------- src/static/bow-target2.png | Bin 19131 -> 0 bytes src/static/bow-target3.png | Bin 20700 -> 0 bytes src/util.js | 89 +++++++++++++++++++++---------- 9 files changed, 181 insertions(+), 129 deletions(-) delete mode 100644 src/static/bow-target2.png delete mode 100644 src/static/bow-target3.png diff --git a/src/apis.js b/src/apis.js index a0aa942..8d1acf5 100644 --- a/src/apis.js +++ b/src/apis.js @@ -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}` + ); +}; diff --git a/src/components/BowTargetEdit.vue b/src/components/BowTargetEdit.vue index 675a739..25830dc 100644 --- a/src/components/BowTargetEdit.vue +++ b/src/components/BowTargetEdit.vue @@ -3,6 +3,14 @@ import { ref, onMounted } from "vue"; import { getElementRect, calcRing } from "@/util"; const props = defineProps({ + id: { + type: Number, + default: 0, + }, + src: { + type: String, + default: "", + }, arrows: { type: Array, default: () => [], @@ -26,6 +34,7 @@ const onClick = async (e) => { y: e.detail.y - rect.value.top - 10, }; newArrow.ring = calcRing( + props.id, newArrow.x, newArrow.y, rect.value.width * 0.9, @@ -72,7 +81,13 @@ const onDrag = async (e) => { // 更新坐标 arrow.value.x = Math.max(0, Math.min(width, arrow.value.x + deltaX)); arrow.value.y = Math.max(0, Math.min(height, arrow.value.y + deltaY)); - arrow.value.ring = calcRing(arrow.value.x, arrow.value.y, width, height); + arrow.value.ring = calcRing( + props.id, + arrow.value.x, + arrow.value.y, + width, + height + ); // 更新拖拽起始位置 dragStartPos.value = { x: clientX, y: clientY }; @@ -96,7 +111,7 @@ onMounted(async () => { @touchmove="onDrag" @touchend="endDrag" > - + { selectedIndex.value = index; if (props.itemIndex === 0) { - props.onSelect(props.itemIndex, bowTypes[index].name); + props.onSelect(props.itemIndex, data.value[index]); } else if (props.itemIndex === 1) { props.onSelect(props.itemIndex, distances[index]); } else if (props.itemIndex === 2) { - props.onSelect(props.itemIndex, bowtargetTypes[index]); + props.onSelect(props.itemIndex, data.value[index]); } else if (props.itemIndex === 3 && secondSelectIndex.value !== -1) { props.onSelect( props.itemIndex, @@ -104,8 +66,8 @@ watch( () => props.value, (newValue) => { if (!newValue) return; - if (props.itemIndex === 0) { - bowTypes.forEach((item, index) => { + if (props.itemIndex === 0 || props.itemIndex === 2) { + data.value.forEach((item, index) => { if (item.name === newValue) { selectedIndex.value = index; } @@ -121,15 +83,19 @@ watch( } }); } - if (props.itemIndex === 2) { - bowtargetTypes.forEach((item, index) => { - if (item === newValue) { - selectedIndex.value = index; - } - }); - } } ); +onMounted(() => { + const config = uni.getStorageSync("point-book-config"); + if (config) { + if (props.itemIndex === 0) { + data.value = config.bowOption; + } else if (props.itemIndex === 2) { + data.value = config.targetOption; + } + // props.onSelect(props.itemIndex, config[props.itemIndex]); + } +});