diff --git a/src/apis.js b/src/apis.js index 0259878..82a783a 100644 --- a/src/apis.js +++ b/src/apis.js @@ -6,8 +6,8 @@ try { switch (envVersion) { case "develop": // 开发版 - // BASE_URL = "http://localhost:8000/api/shoot"; - BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot"; + BASE_URL = "http://192.168.1.30:8000/api/shoot"; + // BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot"; break; case "trial": // 体验版 BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot"; diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue index 5bc94b2..c88fa24 100644 --- a/src/pages/team-battle.vue +++ b/src/pages/team-battle.vue @@ -41,6 +41,8 @@ const showRoundTip = ref(false); const isFinalShoot = ref(false); const matchStatus = ref(undefined); const updateRemainSecond = ref(0); +/** 当前对局每人射击时间(秒),从后端 shootTime 字段动态读取,默认 15 */ +const shootTimeTotal = ref(15); /** 对战来源类型(1=好友约战,2=匹配对战),用于结算页分流 */ const battleWay = ref(0); /** 上一次处理的 ToSomeoneShoot 关键字段,用于去重过滤重复消息 */ @@ -123,6 +125,8 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => { } // redPlayer 已在上方 find() 确认:不为 null 则当前射手在红队 const targetTeam = redPlayer ? 'red' : 'blue'; + // 从后端消息读取本局射击时间,动态设置进度条满值与倒计时秒数(降级兜底 15s) + shootTimeTotal.value = battleInfo.shootTime ?? 15; if (force) { // force 模式下 start.value 刚由 null 变 true,Vue 异步调度渲染, // ShootProgress2(v-if="start")尚未挂载,update-remain 事件会被丢弃。 @@ -130,14 +134,14 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => { // onAudioEnded 驱动,需在 nextTick 后直接启动。 const elapsed = (Date.now() - battleInfo.current.startTime) / 1000; console.log(`当前轮已进行${elapsed}秒`); - if (elapsed > 0 && elapsed < 15) { - updateRemainSecond.value = 15 - elapsed - 0.2; + if (elapsed > 0 && elapsed < shootTimeTotal.value) { + updateRemainSecond.value = shootTimeTotal.value - elapsed - 0.2; } const actualRemain = updateRemainSecond.value; nextTick(() => { // 在 nextTick 内统一发送,确保 ShootProgress2 和 HeaderProgress 均已挂载 uni.$emit("update-tips", nextTips); - uni.$emit("update-remain", {reset: true, value: 15, team: targetTeam}); + uni.$emit("update-remain", {reset: true, value: shootTimeTotal.value, team: targetTeam}); // 重置动画完成后,直接启动倒计时(无需依赖音频结束回调) setTimeout(() => { uni.$emit("update-remain", {stop: false, value: actualRemain, team: targetTeam}); @@ -145,8 +149,8 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => { }); } else { // ToSomeoneShoot 到达时:若进度条仍在倒计时则瞬间清零再切换满值,确保视觉连贯 - uni.$emit("update-remain", {zeroThenReset: true, value: 15, team: targetTeam}); - updateRemainSecond.value = battleInfo.readyTime; + uni.$emit("update-remain", {zeroThenReset: true, value: shootTimeTotal.value, team: targetTeam}); + updateRemainSecond.value = shootTimeTotal.value; } } else { currentRound.value = battleInfo.current.round || 1; @@ -324,6 +328,7 @@ onShow(async () => { />