Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75cfcd66ee | ||
|
|
7955b37ec5 | ||
|
|
9e6ad4cf50 | ||
|
|
6c55d32f90 | ||
|
|
63fb4ae85a | ||
|
|
2628a17b3f | ||
|
|
e7f073ed7c | ||
|
|
d662db9465 | ||
|
|
23655102d3 | ||
|
|
fbb2076a77 | ||
|
|
8c96a4cb73 | ||
|
|
6a78093d31 | ||
|
|
4835993639 | ||
|
|
3c45ef78ac | ||
|
|
ab70c8c78e | ||
|
|
fac2576b65 | ||
|
|
360da2a1d7 | ||
|
|
f34800798d |
@@ -28,6 +28,7 @@
|
|||||||
const {
|
const {
|
||||||
updateUser,
|
updateUser,
|
||||||
updateOnline,
|
updateOnline,
|
||||||
|
showDeviceChargingDialog,
|
||||||
clearSessionState,
|
clearSessionState,
|
||||||
clearDevice
|
clearDevice
|
||||||
} = store;
|
} = store;
|
||||||
@@ -82,6 +83,10 @@
|
|||||||
uni.setStorageSync("calibration", false);
|
uni.setStorageSync("calibration", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDeviceCharging() {
|
||||||
|
showDeviceChargingDialog();
|
||||||
|
}
|
||||||
|
|
||||||
function onDeviceShoot() {
|
function onDeviceShoot() {
|
||||||
// audioManager.play("射箭声音")
|
// audioManager.play("射箭声音")
|
||||||
}
|
}
|
||||||
@@ -119,6 +124,7 @@
|
|||||||
uni.$on("update-online", emitUpdateOnline);
|
uni.$on("update-online", emitUpdateOnline);
|
||||||
uni.$on("session-kicked-out", onSessionKickedOut);
|
uni.$on("session-kicked-out", onSessionKickedOut);
|
||||||
uni.$on("device-bind-invalid", onDeviceBindInvalid);
|
uni.$on("device-bind-invalid", onDeviceBindInvalid);
|
||||||
|
uni.$on("device-charging", onDeviceCharging);
|
||||||
if (typeof uni.offNetworkStatusChange === "function") {
|
if (typeof uni.offNetworkStatusChange === "function") {
|
||||||
uni.offNetworkStatusChange(onNetworkStatusChange);
|
uni.offNetworkStatusChange(onNetworkStatusChange);
|
||||||
}
|
}
|
||||||
@@ -144,6 +150,7 @@
|
|||||||
uni.$off("update-online", emitUpdateOnline);
|
uni.$off("update-online", emitUpdateOnline);
|
||||||
uni.$off("session-kicked-out", onSessionKickedOut);
|
uni.$off("session-kicked-out", onSessionKickedOut);
|
||||||
uni.$off("device-bind-invalid", onDeviceBindInvalid);
|
uni.$off("device-bind-invalid", onDeviceBindInvalid);
|
||||||
|
uni.$off("device-charging", onDeviceCharging);
|
||||||
if (typeof uni.offNetworkStatusChange === "function") {
|
if (typeof uni.offNetworkStatusChange === "function") {
|
||||||
uni.offNetworkStatusChange(onNetworkStatusChange);
|
uni.offNetworkStatusChange(onNetworkStatusChange);
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-9
@@ -8,7 +8,7 @@ try {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
// BASE_URL = "http://192.168.1.2:8000/api/shoot";
|
// BASE_URL = "http://192.168.1.30:8000/api/shoot";
|
||||||
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
@@ -26,7 +26,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ADDONS_BASE_URL = BASE_URL.replace(/\/api\/shoot$/, "/api/shoot");
|
const ADDONS_BASE_URL = BASE_URL.replace(/\/api\/shoot$/, "/api/shoot");
|
||||||
// 统一处理业务接口请求,包含登录态、业务错误和 WiFi 连接空响应兼容。
|
// 统一处理业务接口请求,包含登录态、业务错误和特定接口空响应兼容。
|
||||||
function request(method, url, data = {}, baseUrl = BASE_URL) {
|
function request(method, url, data = {}, baseUrl = BASE_URL) {
|
||||||
const token = uni.getStorageSync(
|
const token = uni.getStorageSync(
|
||||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||||
@@ -41,7 +41,11 @@ function request(method, url, data = {}, baseUrl = BASE_URL) {
|
|||||||
data,
|
data,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (url === "/user/hardwareBox/connectWifi" && res.statusCode === 200 && res.data && Object.keys(res.data).length === 0) {
|
const acceptsEmptyResponse = [
|
||||||
|
"/user/hardwareBox/connectWifi",
|
||||||
|
"/user/device/unbindByQrcodeId",
|
||||||
|
].includes(url);
|
||||||
|
if (acceptsEmptyResponse && res.statusCode === 200 && res.data && Object.keys(res.data).length === 0) {
|
||||||
resolve({});
|
resolve({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -186,8 +190,19 @@ export const getDailyCountAPI = () => {
|
|||||||
return request("GET", "/index/dailyCount", {}, ADDONS_BASE_URL);
|
return request("GET", "/index/dailyCount", {}, ADDONS_BASE_URL);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getHomeData = (seasonId) => {
|
export const getHomeData = async (seasonId) => {
|
||||||
return request("GET", `/user/myHome?seasonId=${seasonId}`);
|
const data = await request("GET", `/user/myHome?seasonId=${seasonId}`);
|
||||||
|
if (!data?.user) return data;
|
||||||
|
|
||||||
|
// 段位信息由 myHome 接口直接返回,统一并入用户数据供各页面展示。
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
user: {
|
||||||
|
...data.user,
|
||||||
|
rankIcon: data.rankIcon,
|
||||||
|
rankName: data.rankName,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProvinceData = () => {
|
export const getProvinceData = () => {
|
||||||
@@ -231,6 +246,12 @@ export const checkUserBindAPI = async (code) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const tempBindOrgAPI = (scene) => {
|
||||||
|
return request("POST", "/user/org/device/tempBind", {
|
||||||
|
scene,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const bindDeviceAPI = (device) => {
|
export const bindDeviceAPI = (device) => {
|
||||||
return request("POST", "/user/device/bindDevice", {
|
return request("POST", "/user/device/bindDevice", {
|
||||||
device,
|
device,
|
||||||
@@ -249,6 +270,11 @@ export const unbindDeviceAPI = (deviceId) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 测试环境根据设备二维码编号解绑设备,不校验设备归属。
|
||||||
|
export const unbindDeviceByQrcodeIdAPI = (id) => {
|
||||||
|
return request("POST", "/user/device/unbindByQrcodeId", {id});
|
||||||
|
};
|
||||||
|
|
||||||
export const getMyDevicesAPI = () => {
|
export const getMyDevicesAPI = () => {
|
||||||
// "/user/device/getBinding?deviceId=9ZF9oVXs"
|
// "/user/device/getBinding?deviceId=9ZF9oVXs"
|
||||||
return request("GET", "/user/device/getBindings");
|
return request("GET", "/user/device/getBindings");
|
||||||
@@ -285,6 +311,13 @@ export const getPractiseAPI = async (id) => {
|
|||||||
return request("GET", `/user/practice/get?id=${id}`);
|
return request("GET", `/user/practice/get?id=${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getPractiseDetailAPI = async (id) => {
|
||||||
|
return request(
|
||||||
|
"GET",
|
||||||
|
`/user/practice/detail?id=${encodeURIComponent(id)}`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const createRoomAPI = (gameType, teamSize, targetType) => {
|
export const createRoomAPI = (gameType, teamSize, targetType) => {
|
||||||
return request("POST", "/user/createroom", {
|
return request("POST", "/user/createroom", {
|
||||||
gameType,
|
gameType,
|
||||||
@@ -318,12 +351,12 @@ export const startRoomAPI = (number) => {
|
|||||||
return request("POST", "/user/room/start", {number});
|
return request("POST", "/user/room/start", {number});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPractiseResultListAPI = async (page = 1, page_size = 15) => {
|
export const getPractiseResultListAPI = async (page = 1, pageSize = 15) => {
|
||||||
const reuslt = await request(
|
const result = await request(
|
||||||
"GET",
|
"GET",
|
||||||
`/user/practice/list?page=${page}&page_size=${page_size}`
|
`/user/practice/mylist?page=${page}&pageSize=${pageSize}&status=0`
|
||||||
);
|
);
|
||||||
return reuslt.list;
|
return Array.isArray(result?.list) ? result.list : [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const matchGameAPI = (match, gameType, teamSize) => {
|
export const matchGameAPI = (match, gameType, teamSize) => {
|
||||||
@@ -502,6 +535,25 @@ export const laserAimAPI = async () => {
|
|||||||
return request("POST", "/user/device/laserAim");
|
return request("POST", "/user/device/laserAim");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 调瞄续期只负责发送请求,不等待或处理响应,避免阻塞下一次续期。
|
||||||
|
export const aimRenewAPI = () => {
|
||||||
|
const token = uni.getStorageSync(
|
||||||
|
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||||
|
);
|
||||||
|
const header = {};
|
||||||
|
if (token) header.Authorization = `Bearer ${token}`;
|
||||||
|
|
||||||
|
uni.request({
|
||||||
|
url: `${BASE_URL}/user/device/aimRenew`,
|
||||||
|
method: "POST",
|
||||||
|
header,
|
||||||
|
data: {},
|
||||||
|
timeout: 10000,
|
||||||
|
success: () => {},
|
||||||
|
fail: () => {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const laserCloseAPI = async () => {
|
export const laserCloseAPI = async () => {
|
||||||
return request("POST", "/user/device/closeAim");
|
return request("POST", "/user/device/closeAim");
|
||||||
};
|
};
|
||||||
|
|||||||
+130
-22
@@ -52,6 +52,12 @@ export const audioFils = {
|
|||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutzdrl5u0iromqhf.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutzdrl5u0iromqhf.mp3",
|
||||||
射击无效:
|
射击无效:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%E6%A3%80%E6%9F%A5%E8%B7%9D%E7%A6%BB%E5%92%8C%E9%9D%B6%E7%BA%B8.mp3",
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%E6%A3%80%E6%9F%A5%E8%B7%9D%E7%A6%BB%E5%92%8C%E9%9D%B6%E7%BA%B8.mp3",
|
||||||
|
"射箭无效,距离不足":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%EF%BC%8C%E8%B7%9D%E7%A6%BB%E4%B8%8D%E8%B6%B3.MP3",
|
||||||
|
"射箭无效,未识别到靶纸":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%EF%BC%8C%E6%9C%AA%E8%AF%86%E5%88%AB%E5%88%B0%E9%9D%B6%E7%BA%B8.MP3",
|
||||||
|
"射箭无效,靶纸错误":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E5%B0%84%E7%AE%AD%E6%97%A0%E6%95%88%EF%BC%8C%E9%9D%B6%E7%BA%B8%E9%94%99%E8%AF%AF.mp3.MP3",
|
||||||
未上靶:
|
未上靶:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3",
|
||||||
"1环":
|
"1环":
|
||||||
@@ -106,6 +112,8 @@ export const audioFils = {
|
|||||||
const AUDIO_LOAD_TIMEOUT_MS = 5000;
|
const AUDIO_LOAD_TIMEOUT_MS = 5000;
|
||||||
const AUDIO_WARM_CONCURRENCY = 3;
|
const AUDIO_WARM_CONCURRENCY = 3;
|
||||||
const AUDIO_WARM_RETRIES = 1;
|
const AUDIO_WARM_RETRIES = 1;
|
||||||
|
const AUDIO_INSTANCE_LIMIT = 24;
|
||||||
|
const AUDIO_QUEUE_COMPACT_THRESHOLD = 12;
|
||||||
const AUDIO_WARM_PRIORITY_KEYS = [
|
const AUDIO_WARM_PRIORITY_KEYS = [
|
||||||
"点击按钮",
|
"点击按钮",
|
||||||
"设备连接已断开",
|
"设备连接已断开",
|
||||||
@@ -117,6 +125,9 @@ const AUDIO_WARM_PRIORITY_KEYS = [
|
|||||||
"轮到你了",
|
"轮到你了",
|
||||||
"比赛结束",
|
"比赛结束",
|
||||||
"射击无效",
|
"射击无效",
|
||||||
|
"射箭无效,距离不足",
|
||||||
|
"射箭无效,未识别到靶纸",
|
||||||
|
"射箭无效,靶纸错误",
|
||||||
"中场休息",
|
"中场休息",
|
||||||
"下半场开始",
|
"下半场开始",
|
||||||
"决金箭轮",
|
"决金箭轮",
|
||||||
@@ -153,6 +164,8 @@ class AudioManager {
|
|||||||
this.loadingKeyPromises = new Map();
|
this.loadingKeyPromises = new Map();
|
||||||
this.pendingPlayKeys = new Set();
|
this.pendingPlayKeys = new Set();
|
||||||
this.cacheWritePromises = new Map();
|
this.cacheWritePromises = new Map();
|
||||||
|
this.audioLastUsedAt = new Map();
|
||||||
|
this.warmPriorityPromise = null;
|
||||||
this.warmAllPromise = null;
|
this.warmAllPromise = null;
|
||||||
|
|
||||||
// 连续播放队列相关属性
|
// 连续播放队列相关属性
|
||||||
@@ -244,14 +257,74 @@ class AudioManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getWarmupKeys() {
|
getWarmupKeys() {
|
||||||
return Array.from(
|
return Array.from(new Set(AUDIO_WARM_PRIORITY_KEYS));
|
||||||
new Set([...AUDIO_WARM_PRIORITY_KEYS, ...Object.keys(audioFils)])
|
}
|
||||||
);
|
|
||||||
|
getAllAudioKeys() {
|
||||||
|
return Object.keys(audioFils);
|
||||||
|
}
|
||||||
|
|
||||||
|
touchAudioKey(key) {
|
||||||
|
this.audioLastUsedAt.set(key, Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyAudioInstance(key) {
|
||||||
|
const audio = this.audioMap.get(key);
|
||||||
|
if (!audio) return false;
|
||||||
|
|
||||||
|
this.clearPlayWatchdog(key);
|
||||||
|
this.audioMap.delete(key);
|
||||||
|
this.readyMap.delete(key);
|
||||||
|
this.allowPlayMap.delete(key);
|
||||||
|
this.audioLastUsedAt.delete(key);
|
||||||
|
try {
|
||||||
|
audio.destroy();
|
||||||
|
} catch (_) {}
|
||||||
|
// destroy 可能同步触发 onStop,最后再清一次对应状态。
|
||||||
|
this.allowPlayMap.delete(key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pruneAudioInstances(preserveKey) {
|
||||||
|
while (this.audioMap.size >= AUDIO_INSTANCE_LIMIT) {
|
||||||
|
const candidate = Array.from(this.audioMap.keys())
|
||||||
|
.filter(
|
||||||
|
(key) =>
|
||||||
|
key !== preserveKey &&
|
||||||
|
key !== this.currentPlayingKey &&
|
||||||
|
!this.loadingKeyPromises.has(key)
|
||||||
|
)
|
||||||
|
.sort(
|
||||||
|
(left, right) =>
|
||||||
|
(this.audioLastUsedAt.get(left) || 0) -
|
||||||
|
(this.audioLastUsedAt.get(right) || 0)
|
||||||
|
)[0];
|
||||||
|
if (!candidate || !this.destroyAudioInstance(candidate)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compactSequenceQueue(force = false) {
|
||||||
|
if (!this.isSequenceRunning || this.sequenceIndex <= 0) return;
|
||||||
|
if (!force && this.sequenceIndex < AUDIO_QUEUE_COMPACT_THRESHOLD) return;
|
||||||
|
this.sequenceQueue = this.sequenceQueue.slice(this.sequenceIndex);
|
||||||
|
this.sequenceIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
getRuntimeStats() {
|
||||||
|
return {
|
||||||
|
audioInstanceCount: this.audioMap.size,
|
||||||
|
loadingAudioCount: this.loadingKeyPromises.size,
|
||||||
|
pendingPlayCount: this.pendingPlayKeys.size,
|
||||||
|
sequenceQueueLength: this.isSequenceRunning
|
||||||
|
? Math.max(this.sequenceQueue.length - this.sequenceIndex, 0)
|
||||||
|
: 0,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureAudio(key) {
|
ensureAudio(key) {
|
||||||
if (!audioFils[key]) return Promise.resolve(false);
|
if (!audioFils[key]) return Promise.resolve(false);
|
||||||
if (this.readyMap.get(key) && this.audioMap.has(key)) {
|
if (this.readyMap.get(key) && this.audioMap.has(key)) {
|
||||||
|
this.touchAudioKey(key);
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,23 +376,39 @@ class AudioManager {
|
|||||||
return this.warmKeys(["点击按钮"], { concurrency: 1, retries: 1 });
|
return this.warmKeys(["点击按钮"], { concurrency: 1, retries: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
warmAll() {
|
warmCommon() {
|
||||||
if (this.warmAllPromise) return this.warmAllPromise;
|
if (this.warmPriorityPromise) return this.warmPriorityPromise;
|
||||||
|
|
||||||
debugLog("开始后台分级预热全部语音");
|
debugLog("开始后台预热常用语音");
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.warmAllPromise = this.warmKeys(this.getWarmupKeys())
|
this.warmPriorityPromise = this.warmKeys(this.getWarmupKeys())
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
debugLog("后台语音预热异常", error);
|
debugLog("常用语音预热异常", error);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
debugLog("后台语音预热结束", this.getLoadProgress());
|
debugLog("常用语音预热结束", this.getRuntimeStats());
|
||||||
|
});
|
||||||
|
return this.warmPriorityPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
warmAll() {
|
||||||
|
if (this.warmAllPromise) return this.warmAllPromise;
|
||||||
|
|
||||||
|
debugLog("音频测试页开始遍历全部语音");
|
||||||
|
this.isLoading = true;
|
||||||
|
this.warmAllPromise = this.warmKeys(this.getAllAudioKeys())
|
||||||
|
.catch((error) => {
|
||||||
|
debugLog("全部语音遍历异常", error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
debugLog("全部语音遍历结束", this.getRuntimeStats());
|
||||||
});
|
});
|
||||||
return this.warmAllPromise;
|
return this.warmAllPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保留旧入口兼容测试页或其他历史调用,实际行为改为非阻塞后台预热。
|
// 音频测试页保留全量遍历;实例池会及时淘汰旧实例,避免同时常驻全部语音。
|
||||||
initAudios() {
|
initAudios() {
|
||||||
return this.warmAll();
|
return this.warmAll();
|
||||||
}
|
}
|
||||||
@@ -357,6 +446,7 @@ class AudioManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.pruneAudioInstances(key);
|
||||||
const audio = uni.createInnerAudioContext();
|
const audio = uni.createInnerAudioContext();
|
||||||
audio.autoplay = false;
|
audio.autoplay = false;
|
||||||
try {
|
try {
|
||||||
@@ -368,6 +458,7 @@ class AudioManager {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
this.allowPlayMap.set(key, false);
|
this.allowPlayMap.set(key, false);
|
||||||
audio.onPlay(() => {
|
audio.onPlay(() => {
|
||||||
|
if (this.audioMap.get(key) !== audio) return;
|
||||||
if (!this.allowPlayMap.get(key)) {
|
if (!this.allowPlayMap.get(key)) {
|
||||||
try {
|
try {
|
||||||
audio.stop();
|
audio.stop();
|
||||||
@@ -405,6 +496,7 @@ class AudioManager {
|
|||||||
}
|
}
|
||||||
this.readyMap.set(key, false);
|
this.readyMap.set(key, false);
|
||||||
this.audioMap.delete(key);
|
this.audioMap.delete(key);
|
||||||
|
this.audioLastUsedAt.delete(key);
|
||||||
try {
|
try {
|
||||||
audio.destroy();
|
audio.destroy();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@@ -437,6 +529,7 @@ class AudioManager {
|
|||||||
if (!isCurrentGeneration()) {
|
if (!isCurrentGeneration()) {
|
||||||
clearLoadTimeout();
|
clearLoadTimeout();
|
||||||
this.audioMap.delete(key);
|
this.audioMap.delete(key);
|
||||||
|
this.audioLastUsedAt.delete(key);
|
||||||
try {
|
try {
|
||||||
audio.destroy();
|
audio.destroy();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@@ -471,6 +564,7 @@ class AudioManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
audio.onEnded(() => {
|
audio.onEnded(() => {
|
||||||
|
if (this.audioMap.get(key) !== audio) return;
|
||||||
this.finishPlayback(key, {
|
this.finishPlayback(key, {
|
||||||
advanceSequence: true,
|
advanceSequence: true,
|
||||||
emitEnded: true,
|
emitEnded: true,
|
||||||
@@ -478,10 +572,12 @@ class AudioManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
audio.onStop(() => {
|
audio.onStop(() => {
|
||||||
|
if (this.audioMap.get(key) !== audio) return;
|
||||||
this.finishPlayback(key);
|
this.finishPlayback(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.audioMap.set(key, audio);
|
this.audioMap.set(key, audio);
|
||||||
|
this.touchAudioKey(key);
|
||||||
audio.src = realSrc;
|
audio.src = realSrc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -691,14 +787,7 @@ class AudioManager {
|
|||||||
const loadingPromise = this.loadingKeyPromises.get(key);
|
const loadingPromise = this.loadingKeyPromises.get(key);
|
||||||
if (loadingPromise) return loadingPromise;
|
if (loadingPromise) return loadingPromise;
|
||||||
|
|
||||||
this.clearPlayWatchdog(key);
|
this.destroyAudioInstance(key);
|
||||||
const oldAudio = this.audioMap.get(key);
|
|
||||||
if (oldAudio) {
|
|
||||||
try {
|
|
||||||
oldAudio.destroy();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
this.audioMap.delete(key);
|
|
||||||
this.readyMap.set(key, false);
|
this.readyMap.set(key, false);
|
||||||
return this.ensureAudio(key);
|
return this.ensureAudio(key);
|
||||||
}
|
}
|
||||||
@@ -745,7 +834,8 @@ class AudioManager {
|
|||||||
// 不打断当前播放:把新的队列加入到序列中,等待当前播放结束后衔接
|
// 不打断当前播放:把新的队列加入到序列中,等待当前播放结束后衔接
|
||||||
if (this.currentPlayingKey) {
|
if (this.currentPlayingKey) {
|
||||||
if (this.isSequenceRunning) {
|
if (this.isSequenceRunning) {
|
||||||
// 已有序列在跑:直接追加
|
// 已有序列在跑:先移除已消费前缀,再追加待播语音。
|
||||||
|
this.compactSequenceQueue(true);
|
||||||
this.sequenceQueue = this.sequenceQueue.concat(queue);
|
this.sequenceQueue = this.sequenceQueue.concat(queue);
|
||||||
} else {
|
} else {
|
||||||
// 没有序列但当前有正在播放的:以当前为序列的起点
|
// 没有序列但当前有正在播放的:以当前为序列的起点
|
||||||
@@ -754,6 +844,17 @@ class AudioManager {
|
|||||||
this.sequenceIndex = 0;
|
this.sequenceIndex = 0;
|
||||||
// 不触发 _playSingle,等待当前音频自然结束后由 onAudioEnded 接管
|
// 不触发 _playSingle,等待当前音频自然结束后由 onAudioEnded 接管
|
||||||
}
|
}
|
||||||
|
} else if (
|
||||||
|
this.isSequenceRunning &&
|
||||||
|
this.sequenceQueue[this.sequenceIndex]
|
||||||
|
) {
|
||||||
|
// 当前队首正在按需加载时只追加,不能覆盖已经排队的语音。
|
||||||
|
this.compactSequenceQueue(true);
|
||||||
|
this.sequenceQueue = this.sequenceQueue.concat(queue);
|
||||||
|
const pendingKey = this.sequenceQueue[this.sequenceIndex];
|
||||||
|
if (!this.pendingPlayKeys.has(pendingKey)) {
|
||||||
|
this._playSingle(pendingKey, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 当前没有播放:直接启动新的序列
|
// 当前没有播放:直接启动新的序列
|
||||||
this.sequenceQueue = queue;
|
this.sequenceQueue = queue;
|
||||||
@@ -860,6 +961,7 @@ class AudioManager {
|
|||||||
this.currentPlayingKey = key;
|
this.currentPlayingKey = key;
|
||||||
this.lastPlayKey = key;
|
this.lastPlayKey = key;
|
||||||
this.lastPlayAt = Date.now();
|
this.lastPlayAt = Date.now();
|
||||||
|
this.touchAudioKey(key);
|
||||||
this.startPlayWatchdog(key);
|
this.startPlayWatchdog(key);
|
||||||
} else {
|
} else {
|
||||||
debugLog(`音频 ${key} 尚未就绪,按需加载后播放...`);
|
debugLog(`音频 ${key} 尚未就绪,按需加载后播放...`);
|
||||||
@@ -876,7 +978,8 @@ class AudioManager {
|
|||||||
const nextIndex = this.sequenceIndex + 1;
|
const nextIndex = this.sequenceIndex + 1;
|
||||||
if (nextIndex < this.sequenceQueue.length) {
|
if (nextIndex < this.sequenceQueue.length) {
|
||||||
this.sequenceIndex = nextIndex;
|
this.sequenceIndex = nextIndex;
|
||||||
const nextKey = this.sequenceQueue[nextIndex];
|
this.compactSequenceQueue();
|
||||||
|
const nextKey = this.sequenceQueue[this.sequenceIndex];
|
||||||
this._playSingle(nextKey, false);
|
this._playSingle(nextKey, false);
|
||||||
} else {
|
} else {
|
||||||
// 队列播放完成
|
// 队列播放完成
|
||||||
@@ -960,6 +1063,7 @@ class AudioManager {
|
|||||||
reloadAll() {
|
reloadAll() {
|
||||||
debugLog("执行 reloadAll: 重置音频实例并后台恢复");
|
debugLog("执行 reloadAll: 重置音频实例并后台恢复");
|
||||||
const shouldWarmAll = this.warmAllPromise !== null;
|
const shouldWarmAll = this.warmAllPromise !== null;
|
||||||
|
const shouldWarmPriority = this.warmPriorityPromise !== null;
|
||||||
this.loadGeneration += 1;
|
this.loadGeneration += 1;
|
||||||
|
|
||||||
// 1. 停止所有播放
|
// 1. 停止所有播放
|
||||||
@@ -972,6 +1076,7 @@ class AudioManager {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
this.audioMap.clear();
|
this.audioMap.clear();
|
||||||
|
this.audioLastUsedAt.clear();
|
||||||
|
|
||||||
// 3. 重置状态
|
// 3. 重置状态
|
||||||
this.readyMap.clear();
|
this.readyMap.clear();
|
||||||
@@ -990,10 +1095,13 @@ class AudioManager {
|
|||||||
|
|
||||||
// 4. 重置后台预热状态
|
// 4. 重置后台预热状态
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
this.warmPriorityPromise = null;
|
||||||
this.warmAllPromise = null;
|
this.warmAllPromise = null;
|
||||||
|
|
||||||
// 5. 之前已启动过全量预热则继续全量恢复,否则只恢复按钮音效。
|
// 5. 按中断前使用范围恢复,产品页不再全量创建语音实例。
|
||||||
return shouldWarmAll ? this.warmAll() : this.warmButton();
|
if (shouldWarmAll) return this.warmAll();
|
||||||
|
if (shouldWarmPriority) return this.warmCommon();
|
||||||
|
return this.warmButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,13 @@ function handleTabClick(index) {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.footer {
|
.footer {
|
||||||
height: 120px;
|
/* height: 120px; */
|
||||||
|
height: 190rpx;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
position: relative;
|
/* position: relative; */
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -4,18 +4,34 @@ import { getDeviceBatteryAPI } from "@/apis";
|
|||||||
|
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
|
let disposed = false;
|
||||||
|
let requestInFlight = false;
|
||||||
|
|
||||||
|
const refreshPower = async () => {
|
||||||
|
if (disposed || requestInFlight) return;
|
||||||
|
requestInFlight = true;
|
||||||
|
try {
|
||||||
|
const data = await getDeviceBatteryAPI();
|
||||||
|
if (!disposed) power.value = data.battery;
|
||||||
|
} catch (_) {
|
||||||
|
// 电量轮询失败时等待下一轮,避免产生未处理的 Promise 拒绝。
|
||||||
|
} finally {
|
||||||
|
requestInFlight = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const data = await getDeviceBatteryAPI();
|
await refreshPower();
|
||||||
power.value = data.battery;
|
if (disposed) return;
|
||||||
timer.value = setInterval(async () => {
|
timer.value = setInterval(() => {
|
||||||
const data = await getDeviceBatteryAPI();
|
void refreshPower();
|
||||||
power.value = data.battery;
|
|
||||||
}, 1000 * 10);
|
}, 1000 * 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
disposed = true;
|
||||||
clearInterval(timer.value);
|
clearInterval(timer.value);
|
||||||
|
timer.value = null;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
viewportMode: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["complete", "impact"]);
|
const emit = defineEmits(["complete", "impact"]);
|
||||||
@@ -43,6 +47,7 @@ const activePlayKey = ref("");
|
|||||||
const animationKey = ref("");
|
const animationKey = ref("");
|
||||||
const impactEmitted = ref(false);
|
const impactEmitted = ref(false);
|
||||||
const activeShot = ref(null);
|
const activeShot = ref(null);
|
||||||
|
const activeLayout = ref(null);
|
||||||
let timers = [];
|
let timers = [];
|
||||||
|
|
||||||
const isActive = computed(() => phase.value !== "idle");
|
const isActive = computed(() => phase.value !== "idle");
|
||||||
@@ -93,6 +98,17 @@ function hasShotPoint(shot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const effectiveShot = computed(() => activeShot.value || props.shot);
|
const effectiveShot = computed(() => activeShot.value || props.shot);
|
||||||
|
const effectiveTargetSize = computed(
|
||||||
|
() => activeLayout.value?.target || safeTargetSize.value
|
||||||
|
);
|
||||||
|
const effectiveWindowSize = computed(
|
||||||
|
() => activeLayout.value?.window || getWindowSize()
|
||||||
|
);
|
||||||
|
const isViewportMode = computed(() =>
|
||||||
|
activeLayout.value
|
||||||
|
? activeLayout.value.viewportMode
|
||||||
|
: props.viewportMode === true
|
||||||
|
);
|
||||||
|
|
||||||
const shotPoint = computed(() => {
|
const shotPoint = computed(() => {
|
||||||
const x = Number(effectiveShot.value?.x);
|
const x = Number(effectiveShot.value?.x);
|
||||||
@@ -137,8 +153,40 @@ const hitPercent = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const flightPath = computed(() => {
|
const flightPath = computed(() => {
|
||||||
const size = safeTargetSize.value;
|
const size = effectiveTargetSize.value;
|
||||||
const windowSize = getWindowSize();
|
const windowSize = effectiveWindowSize.value;
|
||||||
|
|
||||||
|
if (
|
||||||
|
isViewportMode.value &&
|
||||||
|
size.width > 0 &&
|
||||||
|
size.height > 0 &&
|
||||||
|
windowSize.width > 0 &&
|
||||||
|
windowSize.height > 0
|
||||||
|
) {
|
||||||
|
const startX = windowSize.width * 0.5;
|
||||||
|
const endX =
|
||||||
|
size.left +
|
||||||
|
size.width * (hitPercent.value.left / 100) +
|
||||||
|
hitOffset.value.x;
|
||||||
|
const endY =
|
||||||
|
size.top +
|
||||||
|
size.height * (hitPercent.value.top / 100) +
|
||||||
|
hitOffset.value.y;
|
||||||
|
// 常规情况下从视口底部进入;靶面局部超出视口时仍保证起点在命中点下方。
|
||||||
|
const startY = Math.max(windowSize.height + 16, endY + 80);
|
||||||
|
const dx = endX - startX;
|
||||||
|
const dy = endY - startY;
|
||||||
|
|
||||||
|
return {
|
||||||
|
startX,
|
||||||
|
startY,
|
||||||
|
endX,
|
||||||
|
endY,
|
||||||
|
translateX: dx,
|
||||||
|
translateY: dy,
|
||||||
|
angle: Math.atan2(dx, -dy) * (180 / Math.PI),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const hasScreenCoordinates =
|
const hasScreenCoordinates =
|
||||||
size.width > 0 &&
|
size.width > 0 &&
|
||||||
@@ -161,6 +209,8 @@ const flightPath = computed(() => {
|
|||||||
return {
|
return {
|
||||||
startX,
|
startX,
|
||||||
startY,
|
startY,
|
||||||
|
endX,
|
||||||
|
endY,
|
||||||
translateX: dx,
|
translateX: dx,
|
||||||
translateY: dy,
|
translateY: dy,
|
||||||
angle: Math.atan2(dx, -dy) * (180 / Math.PI),
|
angle: Math.atan2(dx, -dy) * (180 / Math.PI),
|
||||||
@@ -178,10 +228,19 @@ function formatTargetPosition(percent, offset) {
|
|||||||
return pxOffset ? `calc(${percent}%${pxOffset})` : `${percent}%`;
|
return pxOffset ? `calc(${percent}%${pxOffset})` : `${percent}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const crackStyle = computed(() => ({
|
const crackStyle = computed(() => {
|
||||||
left: formatTargetPosition(hitPercent.value.left, hitOffset.value.x),
|
if (isViewportMode.value) {
|
||||||
top: formatTargetPosition(hitPercent.value.top, hitOffset.value.y),
|
return {
|
||||||
}));
|
left: `${flightPath.value.endX}px`,
|
||||||
|
top: `${flightPath.value.endY}px`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
left: formatTargetPosition(hitPercent.value.left, hitOffset.value.x),
|
||||||
|
top: formatTargetPosition(hitPercent.value.top, hitOffset.value.y),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
function getTargetTranslate(percent) {
|
function getTargetTranslate(percent) {
|
||||||
const absPercent = Math.abs(percent);
|
const absPercent = Math.abs(percent);
|
||||||
@@ -190,19 +249,21 @@ function getTargetTranslate(percent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const arrowMoveStyle = computed(() => {
|
const arrowMoveStyle = computed(() => {
|
||||||
const size = safeTargetSize.value;
|
const size = effectiveTargetSize.value;
|
||||||
const path = flightPath.value;
|
const path = flightPath.value;
|
||||||
let x = getTargetTranslate(hitPercent.value.left - 50);
|
let x = getTargetTranslate(hitPercent.value.left - 50);
|
||||||
let y = getTargetTranslate(hitPercent.value.top - 114);
|
let y = getTargetTranslate(hitPercent.value.top - 114);
|
||||||
|
|
||||||
if (size.width && size.height) {
|
if (isViewportMode.value || (size.width && size.height)) {
|
||||||
x = `${path.translateX}px`;
|
x = `${path.translateX}px`;
|
||||||
y = `${path.translateY}px`;
|
y = `${path.translateY}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"--shot-start-x": size.width ? `${path.startX}px` : "50%",
|
"--shot-start-x":
|
||||||
"--shot-start-y": size.height ? `${path.startY}px` : "114%",
|
isViewportMode.value || size.width ? `${path.startX}px` : "50%",
|
||||||
|
"--shot-start-y":
|
||||||
|
isViewportMode.value || size.height ? `${path.startY}px` : "114%",
|
||||||
"--shot-tx": x,
|
"--shot-tx": x,
|
||||||
"--shot-ty": y,
|
"--shot-ty": y,
|
||||||
"--shot-angle": `${path.angle}deg`,
|
"--shot-angle": `${path.angle}deg`,
|
||||||
@@ -231,6 +292,7 @@ function finish(playKey) {
|
|||||||
phase.value = "idle";
|
phase.value = "idle";
|
||||||
activePlayKey.value = "";
|
activePlayKey.value = "";
|
||||||
activeShot.value = null;
|
activeShot.value = null;
|
||||||
|
activeLayout.value = null;
|
||||||
emit("complete", playKey);
|
emit("complete", playKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +306,11 @@ function play() {
|
|||||||
animationKey.value = `${props.playKey}`;
|
animationKey.value = `${props.playKey}`;
|
||||||
impactEmitted.value = false;
|
impactEmitted.value = false;
|
||||||
activeShot.value = { ...props.shot };
|
activeShot.value = { ...props.shot };
|
||||||
|
activeLayout.value = {
|
||||||
|
target: { ...safeTargetSize.value },
|
||||||
|
window: getWindowSize(),
|
||||||
|
viewportMode: props.viewportMode === true,
|
||||||
|
};
|
||||||
phase.value = "playing";
|
phase.value = "playing";
|
||||||
|
|
||||||
queueTimer(() => {
|
queueTimer(() => {
|
||||||
@@ -278,7 +345,11 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<view
|
<view
|
||||||
v-show="isActive"
|
v-show="isActive"
|
||||||
:class="['shot-effect', `shot-effect--${phase}`]"
|
:class="[
|
||||||
|
'shot-effect',
|
||||||
|
`shot-effect--${phase}`,
|
||||||
|
{ 'shot-effect--viewport': isViewportMode },
|
||||||
|
]"
|
||||||
:style="arrowMoveStyle"
|
:style="arrowMoveStyle"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
@@ -326,6 +397,12 @@ onBeforeUnmount(() => {
|
|||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shot-effect--viewport {
|
||||||
|
position: fixed;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
.shot-arrow-track {
|
.shot-arrow-track {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: var(--shot-start-x);
|
left: var(--shot-start-x);
|
||||||
|
|||||||
+121
-35
@@ -63,6 +63,14 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 5,
|
default: 5,
|
||||||
},
|
},
|
||||||
|
stableShotEffect: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
enableShotEffect: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const pMode = ref(true);
|
const pMode = ref(true);
|
||||||
@@ -73,12 +81,14 @@ const dirTimer = ref(null);
|
|||||||
const angle = ref(null);
|
const angle = ref(null);
|
||||||
const circleColor = ref("");
|
const circleColor = ref("");
|
||||||
const shotEffect = ref(null);
|
const shotEffect = ref(null);
|
||||||
|
const pendingShotEffect = ref(null);
|
||||||
const hiddenRedLatestKey = ref("");
|
const hiddenRedLatestKey = ref("");
|
||||||
const hiddenBlueLatestKey = ref("");
|
const hiddenBlueLatestKey = ref("");
|
||||||
const targetShaking = ref(false);
|
const targetShaking = ref(false);
|
||||||
const targetRect = ref({ left: 0, top: 0, width: 0, height: 0 });
|
const targetRect = ref({ left: 0, top: 0, width: 0, height: 0 });
|
||||||
const shakeTimer = ref(null);
|
const shakeTimer = ref(null);
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
|
let shotEffectRequestGeneration = 0;
|
||||||
const ROUND_TIP_OFFSET_Y = -32;
|
const ROUND_TIP_OFFSET_Y = -32;
|
||||||
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
||||||
|
|
||||||
@@ -107,7 +117,13 @@ function hasShotPoint(shot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldPlayShotEffect(shot) {
|
function shouldPlayShotEffect(shot) {
|
||||||
return props.isSvip && !!shot && Number(shot.ring) > 0 && hasShotPoint(shot);
|
return (
|
||||||
|
props.enableShotEffect &&
|
||||||
|
props.isSvip &&
|
||||||
|
!!shot &&
|
||||||
|
Number(shot.ring) > 0 &&
|
||||||
|
hasShotPoint(shot)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearTipTimer() {
|
function clearTipTimer() {
|
||||||
@@ -135,7 +151,7 @@ function showShotTip(team, shot) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerShotEffect(team, shot, index) {
|
function triggerShotEffect(team, shot, index, viewportMode = false) {
|
||||||
const key = buildShotEffectKey(team, shot, index);
|
const key = buildShotEffectKey(team, shot, index);
|
||||||
|
|
||||||
if (shotEffect.value?.team === "red") hiddenRedLatestKey.value = "";
|
if (shotEffect.value?.team === "red") hiddenRedLatestKey.value = "";
|
||||||
@@ -149,7 +165,29 @@ function triggerShotEffect(team, shot, index) {
|
|||||||
hiddenBlueLatestKey.value = key;
|
hiddenBlueLatestKey.value = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
shotEffect.value = { key, team, shot };
|
shotEffect.value = { key, team, shot, viewportMode };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function prepareShotEffect(team, shot, index) {
|
||||||
|
const requestGeneration = ++shotEffectRequestGeneration;
|
||||||
|
const key = buildShotEffectKey(team, shot, index);
|
||||||
|
pendingShotEffect.value = { generation: requestGeneration, team, key };
|
||||||
|
clearTipTimer();
|
||||||
|
if (team === "red") latestOne.value = null;
|
||||||
|
if (team === "blue") bluelatestOne.value = null;
|
||||||
|
|
||||||
|
const viewportMode = props.stableShotEffect
|
||||||
|
? await updateTargetRect()
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (requestGeneration !== shotEffectRequestGeneration) {
|
||||||
|
if (pendingShotEffect.value?.generation === requestGeneration) {
|
||||||
|
pendingShotEffect.value = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pendingShotEffect.value = null;
|
||||||
|
triggerShotEffect(team, shot, index, viewportMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function completeShotEffect(key) {
|
function completeShotEffect(key) {
|
||||||
@@ -178,44 +216,67 @@ function shakeTarget() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTargetRect() {
|
function hasValidTargetRect(rect = targetRect.value) {
|
||||||
nextTick(() => {
|
return (
|
||||||
const query = instance?.proxy
|
Number.isFinite(Number(rect?.left)) &&
|
||||||
? uni.createSelectorQuery().in(instance.proxy)
|
Number.isFinite(Number(rect?.top)) &&
|
||||||
: uni.createSelectorQuery();
|
Number(rect?.width) > 0 &&
|
||||||
|
Number(rect?.height) > 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
query
|
async function updateTargetRect() {
|
||||||
.select(".target")
|
await nextTick();
|
||||||
.boundingClientRect((rect) => {
|
|
||||||
const left = Number(rect?.left);
|
return new Promise((resolve) => {
|
||||||
const top = Number(rect?.top);
|
let settled = false;
|
||||||
const width = Number(rect?.width);
|
const finish = (rect) => {
|
||||||
const height = Number(rect?.height);
|
if (settled) return;
|
||||||
if (
|
settled = true;
|
||||||
!Number.isFinite(left) ||
|
|
||||||
!Number.isFinite(top) ||
|
const isValid = hasValidTargetRect(rect);
|
||||||
!Number.isFinite(width) ||
|
if (isValid) {
|
||||||
!Number.isFinite(height)
|
targetRect.value = {
|
||||||
) {
|
left: Number(rect.left),
|
||||||
return;
|
top: Number(rect.top),
|
||||||
}
|
width: Number(rect.width),
|
||||||
if (width <= 0 || height <= 0) return;
|
height: Number(rect.height),
|
||||||
targetRect.value = { left, top, width, height };
|
};
|
||||||
})
|
}
|
||||||
.exec();
|
resolve(isValid);
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const query = instance?.proxy
|
||||||
|
? uni.createSelectorQuery().in(instance.proxy)
|
||||||
|
: uni.createSelectorQuery();
|
||||||
|
|
||||||
|
query
|
||||||
|
.select(".target")
|
||||||
|
.boundingClientRect()
|
||||||
|
.exec((result) => finish(Array.isArray(result) ? result[0] : null));
|
||||||
|
} catch {
|
||||||
|
finish(null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWindowResize() {
|
function handleWindowResize() {
|
||||||
updateTargetRect();
|
void updateTargetRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldHideRedHit(index) {
|
function shouldHideRedHit(index) {
|
||||||
return !!hiddenRedLatestKey.value && index === props.scores.length - 1;
|
return (
|
||||||
|
(!!hiddenRedLatestKey.value || pendingShotEffect.value?.team === "red") &&
|
||||||
|
index === props.scores.length - 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldHideBlueHit(index) {
|
function shouldHideBlueHit(index) {
|
||||||
return !!hiddenBlueLatestKey.value && index === props.blueScores.length - 1;
|
return (
|
||||||
|
(!!hiddenBlueLatestKey.value || pendingShotEffect.value?.team === "blue") &&
|
||||||
|
index === props.blueScores.length - 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -224,14 +285,18 @@ watch(
|
|||||||
if (newLen === oldLen + 1) {
|
if (newLen === oldLen + 1) {
|
||||||
const latestShot = props.scores[newLen - 1];
|
const latestShot = props.scores[newLen - 1];
|
||||||
if (shouldPlayShotEffect(latestShot)) {
|
if (shouldPlayShotEffect(latestShot)) {
|
||||||
triggerShotEffect("red", latestShot, newLen - 1);
|
void prepareShotEffect("red", latestShot, newLen - 1);
|
||||||
} else {
|
} else if (props.enableShotEffect) {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
showShotTip("red", latestShot);
|
showShotTip("red", latestShot);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newLen < oldLen) {
|
if (newLen < oldLen) {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
latestOne.value = null;
|
latestOne.value = null;
|
||||||
hiddenRedLatestKey.value = "";
|
hiddenRedLatestKey.value = "";
|
||||||
if (shotEffect.value?.team === "red") shotEffect.value = null;
|
if (shotEffect.value?.team === "red") shotEffect.value = null;
|
||||||
@@ -245,14 +310,18 @@ watch(
|
|||||||
if (newLen === oldLen + 1) {
|
if (newLen === oldLen + 1) {
|
||||||
const latestShot = props.blueScores[newLen - 1];
|
const latestShot = props.blueScores[newLen - 1];
|
||||||
if (shouldPlayShotEffect(latestShot)) {
|
if (shouldPlayShotEffect(latestShot)) {
|
||||||
triggerShotEffect("blue", latestShot, newLen - 1);
|
void prepareShotEffect("blue", latestShot, newLen - 1);
|
||||||
} else {
|
} else if (props.enableShotEffect) {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
showShotTip("blue", latestShot);
|
showShotTip("blue", latestShot);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newLen < oldLen) {
|
if (newLen < oldLen) {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
bluelatestOne.value = null;
|
bluelatestOne.value = null;
|
||||||
hiddenBlueLatestKey.value = "";
|
hiddenBlueLatestKey.value = "";
|
||||||
if (shotEffect.value?.team === "blue") shotEffect.value = null;
|
if (shotEffect.value?.team === "blue") shotEffect.value = null;
|
||||||
@@ -411,11 +480,13 @@ async function onReceiveMessage(message) {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
updateTargetRect();
|
void updateTargetRect();
|
||||||
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
if (timer.value) {
|
if (timer.value) {
|
||||||
clearTimeout(timer.value);
|
clearTimeout(timer.value);
|
||||||
timer.value = null;
|
timer.value = null;
|
||||||
@@ -521,6 +592,7 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<BowShotEffect
|
<BowShotEffect
|
||||||
|
v-if="!shotEffect || !shotEffect.viewportMode"
|
||||||
:shot="shotEffect && shotEffect.shot"
|
:shot="shotEffect && shotEffect.shot"
|
||||||
:playKey="shotEffect ? shotEffect.key : ''"
|
:playKey="shotEffect ? shotEffect.key : ''"
|
||||||
:targetRadius="safeTargetRadius"
|
:targetRadius="safeTargetRadius"
|
||||||
@@ -534,6 +606,20 @@ onBeforeUnmount(() => {
|
|||||||
/>
|
/>
|
||||||
<image src="https://static.shelingxingqiu.com/shootmini/static/bow-target.png" mode="widthFix" />
|
<image src="https://static.shelingxingqiu.com/shootmini/static/bow-target.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
|
<BowShotEffect
|
||||||
|
v-if="shotEffect && shotEffect.viewportMode"
|
||||||
|
:shot="shotEffect.shot"
|
||||||
|
:playKey="shotEffect.key"
|
||||||
|
:targetRadius="safeTargetRadius"
|
||||||
|
:targetLeft="targetRect.left"
|
||||||
|
:targetTop="targetRect.top"
|
||||||
|
:targetWidth="targetRect.width"
|
||||||
|
:targetHeight="targetRect.height"
|
||||||
|
:hitOffsetPx="currentHitRadiusPx"
|
||||||
|
:viewportMode="true"
|
||||||
|
@impact="shakeTarget"
|
||||||
|
@complete="completeShotEffect"
|
||||||
|
/>
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
<PointSwitcher
|
<PointSwitcher
|
||||||
:onChange="(val) => (pMode = val)"
|
:onChange="(val) => (pMode = val)"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import AppBackground from "@/components/AppBackground.vue";
|
|||||||
import Header from "@/components/Header.vue";
|
import Header from "@/components/Header.vue";
|
||||||
import ScreenHint from "@/components/ScreenHint.vue";
|
import ScreenHint from "@/components/ScreenHint.vue";
|
||||||
import BackToGame from "@/components/BackToGame.vue";
|
import BackToGame from "@/components/BackToGame.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
import {laserAimAPI, getBattleAPI, matchGameAPI} from "@/apis";
|
import {laserAimAPI, getBattleAPI, matchGameAPI} from "@/apis";
|
||||||
import { capsuleHeight, debounce } from "@/util";
|
import { capsuleHeight, debounce } from "@/util";
|
||||||
import { returnToBattle } from "@/utils/matchReturn";
|
import { returnToBattle } from "@/utils/matchReturn";
|
||||||
@@ -226,6 +227,7 @@ const goCalibration = async () => {
|
|||||||
<text>{{ loadingText || "加载中..." }}</text>
|
<text>{{ loadingText || "加载中..." }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<DeviceChargingDialog />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<script setup>
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
import ModalDialog from "@/components/ModalDialog.vue";
|
||||||
|
import useStore from "@/store";
|
||||||
|
|
||||||
|
const chargingNotice =
|
||||||
|
"检测到智能弓箭已开始充电,为保护电池,设备即将自动关机。\n(注意:此时拔出充电线将会重启设备。)";
|
||||||
|
|
||||||
|
const store = useStore();
|
||||||
|
const { deviceChargingDialogVisible } = storeToRefs(store);
|
||||||
|
const { hideDeviceChargingDialog } = store;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ModalDialog
|
||||||
|
:show="deviceChargingDialogVisible"
|
||||||
|
:content="chargingNotice"
|
||||||
|
:show-cancel="false"
|
||||||
|
confirm-text="我知道了"
|
||||||
|
:on-confirm="hideDeviceChargingDialog"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText, getInvalidShotAudioKey } from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -91,7 +91,7 @@ async function onReceiveMessage(message) {
|
|||||||
title: "距离不足,无效",
|
title: "距离不足,无效",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
audioManager.play("射击无效");
|
audioManager.play(getInvalidShotAudioKey(shootData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
import { ref, watch } from "vue";
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
rowCount: {
|
rowCount: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -29,42 +29,36 @@ const bgImages = [
|
|||||||
"https://static.shelingxingqiu.com/shootmini/static/complete-light1.png",
|
"https://static.shelingxingqiu.com/shootmini/static/complete-light1.png",
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/complete-light2.png",
|
"https://static.shelingxingqiu.com/shootmini/static/complete-light2.png",
|
||||||
];
|
];
|
||||||
const bgIndex = ref(0);
|
|
||||||
watch(
|
watch(
|
||||||
() => props.total,
|
() => props.total,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
items.value = new Array(newValue).fill(9);
|
items.value = new Array(newValue).fill(9);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const timer = ref(null);
|
|
||||||
onMounted(() => {
|
|
||||||
timer.value = setInterval(() => {
|
|
||||||
bgIndex.value = bgIndex.value === 0 ? 1 : 0;
|
|
||||||
}, 200);
|
|
||||||
});
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
if (timer.value) {
|
|
||||||
clearInterval(timer.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<image
|
<template v-if="total > 0 && arrows.length === total && completeEffect">
|
||||||
v-if="total > 0 && arrows.length === total && completeEffect"
|
<image
|
||||||
:src="bgImages[bgIndex]"
|
v-for="(image, index) in bgImages"
|
||||||
class="complete-light"
|
:key="image"
|
||||||
:style="{
|
:src="image"
|
||||||
width: `calc(${(100 / (rowCount + 2)) * rowCount}vw + ${
|
:class="[
|
||||||
(100 / (total * 2)) * (rowCount * 2 + (total === 12 ? 8 : 24))
|
'complete-light',
|
||||||
}px)`,
|
index === 0 ? 'complete-light--first' : 'complete-light--second',
|
||||||
height: `calc(${(100 / (rowCount + 2)) * (total / rowCount)}vw + ${
|
]"
|
||||||
(100 / (total * 2)) *
|
:style="{
|
||||||
((total / rowCount) * 2 + (total === 12 ? 7 : 24))
|
width: `calc(${(100 / (rowCount + 2)) * rowCount}vw + ${
|
||||||
}px)`,
|
(100 / (total * 2)) * (rowCount * 2 + (total === 12 ? 8 : 24))
|
||||||
top: `${total === 12 ? -2 : -3}vw`,
|
}px)`,
|
||||||
}"
|
height: `calc(${(100 / (rowCount + 2)) * (total / rowCount)}vw + ${
|
||||||
/>
|
(100 / (total * 2)) *
|
||||||
|
((total / rowCount) * 2 + (total === 12 ? 7 : 24))
|
||||||
|
}px)`,
|
||||||
|
top: `${total === 12 ? -2 : -3}vw`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
<view
|
<view
|
||||||
v-for="(_, index) in items"
|
v-for="(_, index) in items"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -121,4 +115,30 @@ onBeforeUnmount(() => {
|
|||||||
.complete-light {
|
.complete-light {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
.complete-light--first {
|
||||||
|
animation: complete-light-first 400ms steps(1, end) infinite;
|
||||||
|
}
|
||||||
|
.complete-light--second {
|
||||||
|
animation: complete-light-second 400ms steps(1, end) infinite;
|
||||||
|
}
|
||||||
|
@keyframes complete-light-first {
|
||||||
|
0%,
|
||||||
|
49.9% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
50%,
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes complete-light-second {
|
||||||
|
0%,
|
||||||
|
49.9% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
50%,
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText, getInvalidShotAudioKey } from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -174,7 +174,7 @@ async function onReceiveMessage(msg) {
|
|||||||
title: "距离不足,无效",
|
title: "距离不足,无效",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
audioManager.play("射击无效");
|
audioManager.play(getInvalidShotAudioKey(msg.shootData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ const props = defineProps({
|
|||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
onSuccess: {
|
||||||
|
type: Function,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const agree = ref(false);
|
const agree = ref(false);
|
||||||
const phone = ref("");
|
const phone = ref("");
|
||||||
@@ -127,6 +131,7 @@ async function doLogin() {
|
|||||||
clearDevice();
|
clearDevice();
|
||||||
}
|
}
|
||||||
props.onClose();
|
props.onClose();
|
||||||
|
await props.onSuccess();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("login error", error);
|
console.log("login error", error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+137
-16
@@ -1,8 +1,18 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from "vue";
|
import {
|
||||||
|
computed,
|
||||||
|
getCurrentInstance,
|
||||||
|
nextTick,
|
||||||
|
onBeforeUnmount,
|
||||||
|
onMounted,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
} from "vue";
|
||||||
|
|
||||||
const defaultCanvasSize = 300;
|
const defaultCanvasSize = 300;
|
||||||
const defaultRingCount = 10;
|
const defaultRingCount = 10;
|
||||||
|
const highlightRevealProgressFrames = [0.08, 0.2, 0.38, 0.6, 0.82, 1];
|
||||||
|
const highlightRevealFrameInterval = 60;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// canvas 唯一标识;不传时组件内部自动生成,避免多个靶面 canvas-id 冲突。
|
// canvas 唯一标识;不传时组件内部自动生成,避免多个靶面 canvas-id 冲突。
|
||||||
@@ -41,6 +51,11 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
// 每次变化时以固定低帧数重新展开当前高亮扇区;默认关闭。
|
||||||
|
highlightRefreshToken: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
showSectorLabels: {
|
showSectorLabels: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
@@ -94,6 +109,10 @@ const canvasSize = ref({
|
|||||||
width: defaultCanvasSize,
|
width: defaultCanvasSize,
|
||||||
height: defaultCanvasSize,
|
height: defaultCanvasSize,
|
||||||
});
|
});
|
||||||
|
let drawRequestGeneration = 0;
|
||||||
|
let highlightAnimationGeneration = 0;
|
||||||
|
let highlightAnimationTimer = null;
|
||||||
|
let mountDrawTimer = null;
|
||||||
|
|
||||||
// 完整靶纸默认样式,调用方可以通过 targetStyleConfig 局部覆盖。
|
// 完整靶纸默认样式,调用方可以通过 targetStyleConfig 局部覆盖。
|
||||||
const defaultTargetStyleConfig = {
|
const defaultTargetStyleConfig = {
|
||||||
@@ -238,10 +257,23 @@ const drawTargetRings = (ctx, centerX, centerY, targetRadius, config) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 高亮后端指定区域;activeRing 有效时只高亮该区域内的单个环。
|
// 高亮后端指定区域;activeRing 有效时只高亮该区域内的单个环。
|
||||||
const drawSectorHighlight = (ctx, centerX, centerY, targetRadius, config) => {
|
const drawSectorHighlight = (
|
||||||
|
ctx,
|
||||||
|
centerX,
|
||||||
|
centerY,
|
||||||
|
targetRadius,
|
||||||
|
config,
|
||||||
|
revealProgress = 1
|
||||||
|
) => {
|
||||||
const angles = getSectorAngles(props.activeSector, props.sectorCount);
|
const angles = getSectorAngles(props.activeSector, props.sectorCount);
|
||||||
if (!angles) return;
|
if (!angles) return;
|
||||||
|
|
||||||
|
const safeRevealProgress = Math.min(
|
||||||
|
Math.max(getNumber(revealProgress, 1), 0),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
if (safeRevealProgress <= 0) return;
|
||||||
|
|
||||||
const ring = getPositiveInteger(props.activeRing);
|
const ring = getPositiveInteger(props.activeRing);
|
||||||
const hasActiveRing = ring >= 1 && ring <= config.ringCount;
|
const hasActiveRing = ring >= 1 && ring <= config.ringCount;
|
||||||
const innerRadius = hasActiveRing
|
const innerRadius = hasActiveRing
|
||||||
@@ -262,7 +294,8 @@ const drawSectorHighlight = (ctx, centerX, centerY, targetRadius, config) => {
|
|||||||
innerRadius,
|
innerRadius,
|
||||||
outerRadius,
|
outerRadius,
|
||||||
angles.startAngle,
|
angles.startAngle,
|
||||||
angles.endAngle,
|
angles.startAngle +
|
||||||
|
(angles.endAngle - angles.startAngle) * safeRevealProgress,
|
||||||
style.color,
|
style.color,
|
||||||
style.strokeColor,
|
style.strokeColor,
|
||||||
Math.max(1, targetRadius * style.lineWidthRatio)
|
Math.max(1, targetRadius * style.lineWidthRatio)
|
||||||
@@ -399,12 +432,12 @@ const getDrawKey = (width, height) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 主绘制入口:根据 highlightOnly 决定画完整靶纸,还是只画透明高亮层。
|
// 主绘制入口:根据 highlightOnly 决定画完整靶纸,还是只画透明高亮层。
|
||||||
const drawTarget = () => {
|
const drawTarget = ({ force = false, highlightProgress = 1 } = {}) => {
|
||||||
const width = Math.max(getNumber(canvasSize.value.width, defaultCanvasSize), 1);
|
const width = Math.max(getNumber(canvasSize.value.width, defaultCanvasSize), 1);
|
||||||
const height = Math.max(getNumber(canvasSize.value.height, defaultCanvasSize), 1);
|
const height = Math.max(getNumber(canvasSize.value.height, defaultCanvasSize), 1);
|
||||||
const drawKey = getDrawKey(width, height);
|
const drawKey = getDrawKey(width, height);
|
||||||
|
|
||||||
if (drawKey === lastDrawKey.value) {
|
if (!force && drawKey === lastDrawKey.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +454,14 @@ const drawTarget = () => {
|
|||||||
drawTargetRings(ctx, centerX, centerY, targetRadius, config);
|
drawTargetRings(ctx, centerX, centerY, targetRadius, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawSectorHighlight(ctx, centerX, centerY, targetRadius, config);
|
drawSectorHighlight(
|
||||||
|
ctx,
|
||||||
|
centerX,
|
||||||
|
centerY,
|
||||||
|
targetRadius,
|
||||||
|
config,
|
||||||
|
highlightProgress
|
||||||
|
);
|
||||||
|
|
||||||
if (!props.highlightOnly) {
|
if (!props.highlightOnly) {
|
||||||
drawRingLines(ctx, centerX, centerY, targetRadius, config);
|
drawRingLines(ctx, centerX, centerY, targetRadius, config);
|
||||||
@@ -441,26 +481,82 @@ const drawTarget = () => {
|
|||||||
drawSectorLabels(ctx, centerX, centerY, targetRadius);
|
drawSectorLabels(ctx, centerX, centerY, targetRadius);
|
||||||
|
|
||||||
ctx.draw();
|
ctx.draw();
|
||||||
lastDrawKey.value = drawKey;
|
lastDrawKey.value = highlightProgress >= 1 ? drawKey : "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const setCanvasSizeAndDraw = async (width, height) => {
|
const cancelHighlightAnimation = () => {
|
||||||
|
highlightAnimationGeneration += 1;
|
||||||
|
if (highlightAnimationTimer) {
|
||||||
|
clearTimeout(highlightAnimationTimer);
|
||||||
|
highlightAnimationTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 固定 6 帧展开黄色扇区,避免对原生 canvas 节点做缩放导致低端机错位。
|
||||||
|
const runHighlightRevealAnimation = () => {
|
||||||
|
cancelHighlightAnimation();
|
||||||
|
const generation = highlightAnimationGeneration;
|
||||||
|
let frameIndex = 0;
|
||||||
|
|
||||||
|
const drawNextFrame = () => {
|
||||||
|
if (generation !== highlightAnimationGeneration) return;
|
||||||
|
|
||||||
|
drawTarget({
|
||||||
|
force: true,
|
||||||
|
highlightProgress: highlightRevealProgressFrames[frameIndex],
|
||||||
|
});
|
||||||
|
frameIndex += 1;
|
||||||
|
|
||||||
|
if (frameIndex < highlightRevealProgressFrames.length) {
|
||||||
|
highlightAnimationTimer = setTimeout(
|
||||||
|
drawNextFrame,
|
||||||
|
highlightRevealFrameInterval
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
highlightAnimationTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
drawNextFrame();
|
||||||
|
};
|
||||||
|
|
||||||
|
const setCanvasSizeAndDraw = async (
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
{ animateHighlight = false, requestGeneration } = {}
|
||||||
|
) => {
|
||||||
canvasSize.value = {
|
canvasSize.value = {
|
||||||
width: width > 0 ? width : defaultCanvasSize,
|
width: width > 0 ? width : defaultCanvasSize,
|
||||||
height: height > 0 ? height : width || defaultCanvasSize,
|
height: height > 0 ? height : width || defaultCanvasSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
drawTarget();
|
if (requestGeneration !== drawRequestGeneration) return;
|
||||||
|
|
||||||
|
const canAnimateHighlight =
|
||||||
|
animateHighlight &&
|
||||||
|
props.highlightOnly &&
|
||||||
|
!!getSectorAngles(props.activeSector, props.sectorCount);
|
||||||
|
|
||||||
|
if (canAnimateHighlight) {
|
||||||
|
runHighlightRevealAnimation();
|
||||||
|
} else {
|
||||||
|
cancelHighlightAnimation();
|
||||||
|
drawTarget();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 读取 canvas 实际渲染尺寸后再绘制,保证小程序真机尺寸和坐标一致。
|
// 读取 canvas 实际渲染尺寸后再绘制,保证小程序真机尺寸和坐标一致。
|
||||||
const measureAndDraw = () => {
|
const measureAndDraw = ({ animateHighlight = false } = {}) => {
|
||||||
|
const requestGeneration = ++drawRequestGeneration;
|
||||||
const propWidth = Math.round(getNumber(props.canvasWidth, 0));
|
const propWidth = Math.round(getNumber(props.canvasWidth, 0));
|
||||||
const propHeight = Math.round(getNumber(props.canvasHeight, 0));
|
const propHeight = Math.round(getNumber(props.canvasHeight, 0));
|
||||||
|
|
||||||
if (propWidth > 0 && propHeight > 0) {
|
if (propWidth > 0 && propHeight > 0) {
|
||||||
setCanvasSizeAndDraw(propWidth, propHeight);
|
setCanvasSizeAndDraw(propWidth, propHeight, {
|
||||||
|
animateHighlight,
|
||||||
|
requestGeneration,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,18 +565,23 @@ const measureAndDraw = () => {
|
|||||||
query
|
query
|
||||||
.select(`#${currentCanvasId.value}`)
|
.select(`#${currentCanvasId.value}`)
|
||||||
.boundingClientRect(async (rect) => {
|
.boundingClientRect(async (rect) => {
|
||||||
|
if (requestGeneration !== drawRequestGeneration) return;
|
||||||
|
|
||||||
const width = Math.round(getNumber(rect?.width, defaultCanvasSize));
|
const width = Math.round(getNumber(rect?.width, defaultCanvasSize));
|
||||||
const height = Math.round(getNumber(rect?.height, width || defaultCanvasSize));
|
const height = Math.round(getNumber(rect?.height, width || defaultCanvasSize));
|
||||||
|
|
||||||
await setCanvasSizeAndDraw(width, height);
|
await setCanvasSizeAndDraw(width, height, {
|
||||||
|
animateHighlight,
|
||||||
|
requestGeneration,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.exec();
|
.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 等待 Vue 完成 DOM 更新后重新测量和绘制。
|
// 等待 Vue 完成 DOM 更新后重新测量和绘制。
|
||||||
const scheduleDraw = async () => {
|
const scheduleDraw = async ({ animateHighlight = false } = {}) => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
measureAndDraw();
|
measureAndDraw({ animateHighlight });
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -491,6 +592,7 @@ watch(
|
|||||||
props.sectorCount,
|
props.sectorCount,
|
||||||
props.activeSector,
|
props.activeSector,
|
||||||
props.activeRing,
|
props.activeRing,
|
||||||
|
props.highlightRefreshToken,
|
||||||
props.showSectorLabels,
|
props.showSectorLabels,
|
||||||
props.highlightOnly,
|
props.highlightOnly,
|
||||||
props.canvasWidth,
|
props.canvasWidth,
|
||||||
@@ -501,14 +603,33 @@ watch(
|
|||||||
props.sectorLabelStyle,
|
props.sectorLabelStyle,
|
||||||
props.highlightStyle,
|
props.highlightStyle,
|
||||||
],
|
],
|
||||||
scheduleDraw,
|
(currentValues, previousValues = []) => {
|
||||||
|
const refreshTokenIndex = 6;
|
||||||
|
const refreshToken = Number(currentValues[refreshTokenIndex]);
|
||||||
|
const previousRefreshToken = Number(previousValues[refreshTokenIndex]);
|
||||||
|
const animateHighlight =
|
||||||
|
Number.isFinite(refreshToken) &&
|
||||||
|
refreshToken > 0 &&
|
||||||
|
refreshToken !== previousRefreshToken;
|
||||||
|
|
||||||
|
return scheduleDraw({ animateHighlight });
|
||||||
|
},
|
||||||
{
|
{
|
||||||
deep: true,
|
deep: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(measureAndDraw, 30);
|
mountDrawTimer = setTimeout(measureAndDraw, 30);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
drawRequestGeneration += 1;
|
||||||
|
cancelHighlightAnimation();
|
||||||
|
if (mountDrawTimer) {
|
||||||
|
clearTimeout(mountDrawTimer);
|
||||||
|
mountDrawTimer = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ onBeforeUnmount(() => {
|
|||||||
<view v-if="isBattle" class="ready-timer">
|
<view v-if="isBattle" class="ready-timer">
|
||||||
<image src="https://static.shelingxingqiu.com/shootmini/static/test-tip.png" mode="widthFix" />
|
<image src="https://static.shelingxingqiu.com/shootmini/static/test-tip.png" mode="widthFix" />
|
||||||
<view v-if="count >= 0">
|
<view v-if="count >= 0">
|
||||||
<text>具体正式比赛还有</text>
|
<text>距离正式比赛还有</text>
|
||||||
<text>{{ count }}</text>
|
<text>{{ count }}</text>
|
||||||
<text>秒</text>
|
<text>秒</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ const props = defineProps({
|
|||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const count = ref(props.countdown);
|
const count = ref(props.countdown);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
|
const showTimer = ref(null);
|
||||||
const updateTimer = (value) => {
|
const updateTimer = (value) => {
|
||||||
count.value = Math.round(value);
|
count.value = Math.round(value);
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
showTimer.value = setTimeout(() => {
|
||||||
|
showTimer.value = null;
|
||||||
show.value = true;
|
show.value = true;
|
||||||
timer.value = setInterval(() => {
|
timer.value = setInterval(() => {
|
||||||
if (count.value === 0) {
|
if (count.value === 0) {
|
||||||
@@ -27,7 +29,10 @@ onMounted(() => {
|
|||||||
uni.$on("update-timer", updateTimer);
|
uni.$on("update-timer", updateTimer);
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
if (showTimer.value) clearTimeout(showTimer.value);
|
||||||
|
showTimer.value = null;
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
timer.value = null;
|
||||||
uni.$off("update-timer", updateTimer);
|
uni.$off("update-timer", updateTimer);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed } from "vue";
|
||||||
|
|
||||||
|
const MAX_VISIBLE_SCORE_CARDS = 60;
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
arrows: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
total: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
trainingType: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
recordMode: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const getDisplayText = (arrow = {}) => {
|
||||||
|
if (!arrow) return "";
|
||||||
|
if (!arrow.ring) return "0";
|
||||||
|
return arrow.ringX ? "X" : String(arrow.ring);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isFailed = (arrow = {}) => {
|
||||||
|
if (!arrow) return false;
|
||||||
|
if (props.recordMode && props.trainingType !== "precision") return false;
|
||||||
|
return arrow.ok !== true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const hiddenScoreCount = computed(() =>
|
||||||
|
props.recordMode
|
||||||
|
? 0
|
||||||
|
: Math.max(props.arrows.length - MAX_VISIBLE_SCORE_CARDS, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
const displayArrows = computed(() => {
|
||||||
|
const list = props.recordMode
|
||||||
|
? [...props.arrows]
|
||||||
|
: props.arrows.slice(-MAX_VISIBLE_SCORE_CARDS);
|
||||||
|
// total 是达标箭数,不是实际射箭上限;训练中始终预留下一箭空框。
|
||||||
|
if (!props.recordMode) list.push(null);
|
||||||
|
return list;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view v-if="displayArrows.length" class="score-panel">
|
||||||
|
<text v-if="hiddenScoreCount" class="score-window-tip">
|
||||||
|
已省略前 {{ hiddenScoreCount }} 支,仅显示最近
|
||||||
|
{{ MAX_VISIBLE_SCORE_CARDS }} 支
|
||||||
|
</text>
|
||||||
|
<view class="score-grid">
|
||||||
|
<view
|
||||||
|
v-for="(arrow, index) in displayArrows"
|
||||||
|
:key="index"
|
||||||
|
class="score-card"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
class="score-card-bg"
|
||||||
|
:src="
|
||||||
|
isFailed(arrow)
|
||||||
|
? 'https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/block-gray.png'
|
||||||
|
: 'https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/block-gold.png'
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<image
|
||||||
|
v-if="trainingType === 'precision' && arrow"
|
||||||
|
class="score-result-icon"
|
||||||
|
:src="
|
||||||
|
arrow.ok === true
|
||||||
|
? 'https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/gou.png'
|
||||||
|
: 'https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/cha.png'
|
||||||
|
"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
<text
|
||||||
|
v-else
|
||||||
|
class="score-value"
|
||||||
|
:class="{ 'score-value--low': isFailed(arrow) }"
|
||||||
|
>
|
||||||
|
{{ getDisplayText(arrow) }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.score-panel {
|
||||||
|
width: 100%;
|
||||||
|
padding: 30rpx 40rpx 0 40rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-window-tip {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 18rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 22rpx;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-card {
|
||||||
|
position: relative;
|
||||||
|
width: 100rpx;
|
||||||
|
height: 56rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-right: 14rpx;
|
||||||
|
margin-bottom: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-card:nth-child(6n) {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-card-bg {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100rpx;
|
||||||
|
height: 56rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-result-icon {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-value {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
min-width: 28rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 34rpx;
|
||||||
|
line-height: 1;
|
||||||
|
font-weight: 700;
|
||||||
|
font-style: italic;
|
||||||
|
color: #f6e3b2;
|
||||||
|
text-shadow: 0 2rpx 0 rgba(36, 36, 48, 0.5);
|
||||||
|
margin-left: -10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-value--low {
|
||||||
|
color: #cfcfcf;
|
||||||
|
text-shadow: 0 2rpx 0 rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -10,6 +10,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
fullNickname: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
onSignin: {
|
onSignin: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
@@ -61,7 +65,13 @@ watch(
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="container" :style="{ width: containerWidth }">
|
<view
|
||||||
|
:class="[
|
||||||
|
'container',
|
||||||
|
fullNickname ? 'container--full-nickname' : '',
|
||||||
|
]"
|
||||||
|
:style="{ width: containerWidth }"
|
||||||
|
>
|
||||||
<block v-if="user.id">
|
<block v-if="user.id">
|
||||||
<Avatar
|
<Avatar
|
||||||
:rankLvl="user.rankLvl"
|
:rankLvl="user.rankLvl"
|
||||||
@@ -83,11 +93,11 @@ watch(
|
|||||||
user.nickName
|
user.nickName
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
<image
|
<!-- <image
|
||||||
class="user-name-image"
|
class="user-name-image"
|
||||||
src="../static/vip1.png"
|
src="../static/vip1.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="user-stats">
|
<view class="user-stats">
|
||||||
<text class="level-tag level-tag-first">段位积分</text>
|
<text class="level-tag level-tag-first">段位积分</text>
|
||||||
@@ -165,6 +175,19 @@ watch(
|
|||||||
max-width: 180rpx;
|
max-width: 180rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container--full-nickname .user-details {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container--full-nickname .user-name {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container--full-nickname .user-name .member-nickname {
|
||||||
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
.user-name .member-nickname__text,
|
.user-name .member-nickname__text,
|
||||||
.user-name .member-nickname__shine {
|
.user-name .member-nickname__shine {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export const MESSAGETYPES = {
|
|||||||
DeviceOnline: 4168086626,
|
DeviceOnline: 4168086626,
|
||||||
DeviceOffline: 4168086627,
|
DeviceOffline: 4168086627,
|
||||||
SomeoneIsReady: 4168086628,
|
SomeoneIsReady: 4168086628,
|
||||||
|
DeviceCharging: 4168086631, // 设备充电中
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MESSAGETYPESV2 = {
|
export const MESSAGETYPESV2 = {
|
||||||
|
|||||||
+30
-3
@@ -9,7 +9,7 @@ import {
|
|||||||
getServerMessageTypeName,
|
getServerMessageTypeName,
|
||||||
} from "@/utils/matchProtocol";
|
} from "@/utils/matchProtocol";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText, getInvalidShotAudioKey } from "@/util";
|
||||||
import {
|
import {
|
||||||
normalizeId,
|
normalizeId,
|
||||||
normalizeMatchInfo,
|
normalizeMatchInfo,
|
||||||
@@ -41,6 +41,27 @@ const LIVENESS_TIMEOUT_MS = 30000;
|
|||||||
const RECONNECT_DELAYS_MS = [1000, 2000, 4000, 8000, 15000];
|
const RECONNECT_DELAYS_MS = [1000, 2000, 4000, 8000, 15000];
|
||||||
const ROUND_AUDIO_NAMES = ["一", "二", "三", "四", "五"];
|
const ROUND_AUDIO_NAMES = ["一", "二", "三", "四", "五"];
|
||||||
const MATCH_STATUS_HALF_REST = 3;
|
const MATCH_STATUS_HALF_REST = 3;
|
||||||
|
const ENABLE_REALTIME_MESSAGE_LOG = (() => {
|
||||||
|
try {
|
||||||
|
return uni.getAccountInfoSync().miniProgram.envVersion !== "release";
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
function getServerMessageLogSummary(message = {}) {
|
||||||
|
const practiceInfo = message.practice_info || message.practiceInfo || {};
|
||||||
|
const matchInfo = message.match_info || message.matchInfo || {};
|
||||||
|
return {
|
||||||
|
type: message.type,
|
||||||
|
matchId: normalizeId(pickField(message, "matchId", "match_id")),
|
||||||
|
sequence: message.sequence,
|
||||||
|
practiceDetailCount: Array.isArray(practiceInfo.details)
|
||||||
|
? practiceInfo.details.length
|
||||||
|
: 0,
|
||||||
|
roundCount: Array.isArray(matchInfo.rounds) ? matchInfo.rounds.length : 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// 比赛服消息类型先映射成项目里已有的 V2 业务消息,页面仍然复用原来的 socket-inbox 流程。
|
// 比赛服消息类型先映射成项目里已有的 V2 业务消息,页面仍然复用原来的 socket-inbox 流程。
|
||||||
const BUSINESS_TYPE_BY_SERVER_TYPE = {
|
const BUSINESS_TYPE_BY_SERVER_TYPE = {
|
||||||
@@ -378,7 +399,7 @@ function getAckAudioKeys(message, businessMessage) {
|
|||||||
case ServerMessageType.SERVER_MSG_CHECK:
|
case ServerMessageType.SERVER_MSG_CHECK:
|
||||||
return getTestDistanceAudioKeys(businessMessage?.shootData);
|
return getTestDistanceAudioKeys(businessMessage?.shootData);
|
||||||
case ServerMessageType.SERVER_MSG_NOT_ENOUGH_DISTANCE:
|
case ServerMessageType.SERVER_MSG_NOT_ENOUGH_DISTANCE:
|
||||||
return ["射击无效"];
|
return [getInvalidShotAudioKey(businessMessage?.shootData)];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -785,7 +806,13 @@ function handleMessage(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const typeName = getServerMessageTypeName(message.type);
|
const typeName = getServerMessageTypeName(message.type);
|
||||||
console.log("收到比赛服 WebSocket 消息", typeName, message);
|
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||||
|
console.log(
|
||||||
|
"收到比赛服 WebSocket 消息",
|
||||||
|
typeName,
|
||||||
|
getServerMessageLogSummary(message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const decodedMatchId = normalizeId(pickField(message, "matchId", "match_id"));
|
const decodedMatchId = normalizeId(pickField(message, "matchId", "match_id"));
|
||||||
if (message.type === ServerMessageType.SERVER_MSG_SYNC_PRACTICE_INFO) {
|
if (message.type === ServerMessageType.SERVER_MSG_SYNC_PRACTICE_INFO) {
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
// 首页一周打卡展示数据,直接对应顶部 7 个日期卡片。
|
|
||||||
export const trainingHomeWeekSchedule = [
|
|
||||||
{
|
|
||||||
key: "mon",
|
|
||||||
label: "周一",
|
|
||||||
status: "done",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "tue",
|
|
||||||
label: "周二",
|
|
||||||
status: "done",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "wed",
|
|
||||||
label: "周三",
|
|
||||||
status: "missed",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/missed.png",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "thu",
|
|
||||||
label: "周四",
|
|
||||||
status: "missed",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/missed.png",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "fri",
|
|
||||||
label: "周五",
|
|
||||||
status: "done",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "sat",
|
|
||||||
label: "周六",
|
|
||||||
status: "done",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/done.png",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "sun",
|
|
||||||
label: "周日",
|
|
||||||
status: "missed",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/missed.png",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
// 首页统计卡数据,按设计稿从左到右展示。
|
|
||||||
export const trainingHomeStats = [
|
|
||||||
{ key: "days", value: "12", unit: "天", label: "共训练" },
|
|
||||||
{ key: "shots", value: "112", unit: "支", label: "累计射箭" },
|
|
||||||
{ key: "hitRate", value: "30", unit: "%", label: "命中率" },
|
|
||||||
{ key: "endurance", value: "6", unit: "支/分钟", label: "耐力射击" },
|
|
||||||
{ key: "calories", value: "31W", unit: "卡路里", label: "共消耗" },
|
|
||||||
];
|
|
||||||
|
|
||||||
// 雷达图区文案与数值配置。
|
|
||||||
export const trainingHomeRadar = {
|
|
||||||
labels: ["基础", "精准", "力量", "节奏", "耐力"],
|
|
||||||
values: [5.5, 6.3, 10, 4.5, 6],
|
|
||||||
maxValue: 10,
|
|
||||||
surpassValue: '80%'
|
|
||||||
};
|
|
||||||
|
|
||||||
// 首页主推荐训练卡数据。
|
|
||||||
export const trainingHomeFeatured = {
|
|
||||||
title: "基础训练",
|
|
||||||
progressText: "当前进度 LV7 >",
|
|
||||||
};
|
|
||||||
|
|
||||||
// 首页四个训练入口卡片数据。
|
|
||||||
export const trainingHomeModes = [
|
|
||||||
{
|
|
||||||
key: "endurance",
|
|
||||||
title: "耐力训练",
|
|
||||||
progressText: "当前进度 LV5 >",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_3.png",
|
|
||||||
recommended: true,
|
|
||||||
disabled: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "precision",
|
|
||||||
title: "精准训练",
|
|
||||||
progressText: "当前进度 LV3 >",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_4.png",
|
|
||||||
recommended: false,
|
|
||||||
disabled: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "rhythm",
|
|
||||||
title: "节奏训练",
|
|
||||||
progressText: "当前进度 LV6 >",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_5.png",
|
|
||||||
recommended: false,
|
|
||||||
disabled: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "power",
|
|
||||||
title: "力量训练",
|
|
||||||
progressText: "Coming! LV10",
|
|
||||||
icon: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_6.png",
|
|
||||||
recommended: false,
|
|
||||||
disabled: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
// 难度页当前用于保存“开始训练前上下文”的本地存储 key。
|
|
||||||
export const trainingDifficultyStorageKey = "training-selection";
|
|
||||||
|
|
||||||
// 当前是页面联调用的模拟数据:
|
|
||||||
// 1. 总难度 20 级
|
|
||||||
// 2. 已解锁到 Lv3
|
|
||||||
// 3. 前三关展示不同完成进度
|
|
||||||
const totalDifficultyLevel = 20;
|
|
||||||
const mockedUnlockedDifficultyId = "lv3";
|
|
||||||
const mockedDifficultyProgressMap = {
|
|
||||||
lv1: 100,
|
|
||||||
lv2: 90,
|
|
||||||
lv3: 70,
|
|
||||||
};
|
|
||||||
|
|
||||||
const modeList = [
|
|
||||||
{
|
|
||||||
key: "endurance",
|
|
||||||
title: "耐力训练",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "precision",
|
|
||||||
title: "精准训练",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "rhythm",
|
|
||||||
title: "节奏训练",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "basic",
|
|
||||||
title: "基础训练",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "power",
|
|
||||||
title: "力量训练",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "focus",
|
|
||||||
title: "专注训练",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const createDifficultyId = (level) => `lv${level}`;
|
|
||||||
|
|
||||||
const createDifficultyLabel = (level) => `Lv${level}`;
|
|
||||||
|
|
||||||
// 根据等级生成模拟文案,方便一次性扩展到更多关卡。
|
|
||||||
const createDifficultySummary = (level) => {
|
|
||||||
return [
|
|
||||||
`箭靶划分为${Math.min(1 + Math.floor((level - 1) / 5), 4)}个区域`,
|
|
||||||
`需${4 + level}次命中目标`,
|
|
||||||
`${100 + Math.floor((level - 1) / 2) * 10}秒内完成所有射击`,
|
|
||||||
"需使用20CM全环靶",
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
// 难度页的节点位置已经在页面内统一计算,
|
|
||||||
// 这里保留最核心的 id / label 即可,不再维护无效的 left / top / style 字段。
|
|
||||||
const createDifficultyNode = (level) => {
|
|
||||||
return {
|
|
||||||
id: createDifficultyId(level),
|
|
||||||
label: createDifficultyLabel(level),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const createDifficultyDetail = (level) => {
|
|
||||||
const id = createDifficultyId(level);
|
|
||||||
const label = createDifficultyLabel(level);
|
|
||||||
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
label,
|
|
||||||
title: `${label}难度`,
|
|
||||||
summary: createDifficultySummary(level),
|
|
||||||
startText: "开始",
|
|
||||||
targetPaperType: "20CM全环靶",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// 所有训练模式当前共用同一套难度定义。
|
|
||||||
const sharedDifficultyNodes = Array.from(
|
|
||||||
{ length: totalDifficultyLevel },
|
|
||||||
(_, index) => createDifficultyNode(index + 1)
|
|
||||||
);
|
|
||||||
|
|
||||||
const sharedDifficultyDetails = Object.fromEntries(
|
|
||||||
Array.from({ length: totalDifficultyLevel }, (_, index) => {
|
|
||||||
const detail = createDifficultyDetail(index + 1);
|
|
||||||
return [detail.id, detail];
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const createModeConfig = ({ key, title, reward = null }) => {
|
|
||||||
return {
|
|
||||||
key,
|
|
||||||
title,
|
|
||||||
nodes: sharedDifficultyNodes,
|
|
||||||
details: sharedDifficultyDetails,
|
|
||||||
activeDifficultyId: mockedUnlockedDifficultyId,
|
|
||||||
progressMap: mockedDifficultyProgressMap,
|
|
||||||
reward,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// 难度页数据源入口:
|
|
||||||
// 页面通过 getTrainingDifficultyModeConfig(modeKey) 获取当前模式完整配置。
|
|
||||||
export const trainingDifficultyModeMap = Object.fromEntries(
|
|
||||||
modeList.map((mode) => [mode.key, createModeConfig(mode)])
|
|
||||||
);
|
|
||||||
|
|
||||||
export const getTrainingDifficultyModeConfig = (modeKey) => {
|
|
||||||
return trainingDifficultyModeMap[modeKey] || trainingDifficultyModeMap.precision;
|
|
||||||
};
|
|
||||||
+20
-9
@@ -1,11 +1,14 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"path": "pages/index"
|
"path": "pages/index"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/friend-battle"
|
"path": "pages/org-bind"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/friend-battle"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/point-book"
|
"path": "pages/point-book"
|
||||||
},
|
},
|
||||||
@@ -129,9 +132,17 @@
|
|||||||
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
|
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subPackages": [
|
"subPackages": [
|
||||||
{
|
{
|
||||||
"root": "pages/member",
|
"root": "pages/device",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "unbind-device"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"root": "pages/member",
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"path": "orders"
|
"path": "orders"
|
||||||
|
|||||||
@@ -9,17 +9,23 @@ const playAudio = (key) => {
|
|||||||
audioManager.play(key);
|
audioManager.play(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onAudioLoaded = (key) => {
|
||||||
|
loaded.value = {
|
||||||
|
...loaded.value,
|
||||||
|
[key]: true,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const loadedAudioKeys = uni.getStorageSync("loadedAudioKeys") || {};
|
const loadedAudioKeys = uni.getStorageSync("loadedAudioKeys") || {};
|
||||||
loaded.value = loadedAudioKeys;
|
loaded.value = loadedAudioKeys;
|
||||||
|
|
||||||
uni.$on("audioLoaded", (key) => {
|
uni.$on("audioLoaded", onAudioLoaded);
|
||||||
loaded.value[key] = true;
|
void audioManager.initAudios();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
uni.$off("audioLoaded");
|
uni.$off("audioLoaded", onAudioLoaded);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -40,8 +46,10 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
<view v-for="key in Object.keys(audioFils)" :key="key">
|
<view v-for="key in Object.keys(audioFils)" :key="key">
|
||||||
<text>{{ key }}</text>
|
<text>{{ key }}</text>
|
||||||
<text v-if="!loaded[key]">未加载</text>
|
<text>{{ loaded[key] ? "已加载" : "未加载" }}</text>
|
||||||
<button v-else hover-class="none" @click="playAudio(key)">播放</button>
|
<button hover-class="none" @click="playAudio(key)">
|
||||||
|
{{ loaded[key] ? "播放" : "加载并播放" }}
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ref, computed, onMounted } from "vue";
|
|||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import UserUpgrade from "@/components/UserUpgrade.vue";
|
import UserUpgrade from "@/components/UserUpgrade.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
import { getBattleAPI } from "@/apis";
|
import { getBattleAPI } from "@/apis";
|
||||||
import { topThreeColors, getBattleResultTips } from "@/constants";
|
import { topThreeColors, getBattleResultTips } from "@/constants";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
@@ -287,6 +288,7 @@ const checkBowData = () => {
|
|||||||
<view @click="exit">返回</view>
|
<view @click="exit">返回</view>
|
||||||
</view>
|
</view>
|
||||||
<UserUpgrade />
|
<UserUpgrade />
|
||||||
|
<DeviceChargingDialog />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
import { onShow, onHide } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
|
|
||||||
import { laserAimAPI, laserCloseAPI } from "@/apis";
|
import { aimRenewAPI, laserAimAPI, laserCloseAPI } from "@/apis";
|
||||||
import { MESSAGETYPES } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
// import audioManager from "@/audioManager";
|
// import audioManager from "@/audioManager";
|
||||||
|
|
||||||
@@ -23,8 +24,56 @@ const guides = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const done = ref(true);
|
const done = ref(true);
|
||||||
|
let aimRenewTimer = null;
|
||||||
|
let pageMounted = false;
|
||||||
|
let pageVisible = false;
|
||||||
|
let aimSessionVersion = 0;
|
||||||
|
|
||||||
|
const stopAimRenew = () => {
|
||||||
|
if (!aimRenewTimer) return;
|
||||||
|
clearInterval(aimRenewTimer);
|
||||||
|
aimRenewTimer = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const startAimRenew = () => {
|
||||||
|
stopAimRenew();
|
||||||
|
aimRenewTimer = setInterval(() => {
|
||||||
|
aimRenewAPI();
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openAimSession = async (sessionVersion) => {
|
||||||
|
try {
|
||||||
|
await laserAimAPI();
|
||||||
|
} catch (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!pageMounted ||
|
||||||
|
!pageVisible ||
|
||||||
|
sessionVersion !== aimSessionVersion
|
||||||
|
) {
|
||||||
|
void laserCloseAPI().catch(() => {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
startAimRenew();
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopAimSession = (closeLaser = true) => {
|
||||||
|
const wasVisible = pageVisible;
|
||||||
|
pageVisible = false;
|
||||||
|
aimSessionVersion += 1;
|
||||||
|
stopAimRenew();
|
||||||
|
|
||||||
|
if (closeLaser && wasVisible) {
|
||||||
|
void laserCloseAPI().catch(() => {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onComplete = async () => {
|
const onComplete = async () => {
|
||||||
|
stopAimSession(false);
|
||||||
await laserCloseAPI();
|
await laserCloseAPI();
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
};
|
};
|
||||||
@@ -39,14 +88,26 @@ function onReceiveMessage(messages = []) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onShow(() => {
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
pageVisible = true;
|
||||||
await laserAimAPI();
|
const sessionVersion = ++aimSessionVersion;
|
||||||
|
if (pageMounted) void openAimSession(sessionVersion);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(async () => {
|
onHide(() => {
|
||||||
|
stopAimSession();
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
|
pageMounted = true;
|
||||||
|
if (pageVisible) void openAimSession(aimSessionVersion);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
pageMounted = false;
|
||||||
|
stopAimSession();
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
await laserCloseAPI();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
|
|
||||||
import { capsuleHeight } from "@/util";
|
import { capsuleHeight } from "@/util";
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ const onScrollView = (e) => {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
<DeviceChargingDialog />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import ModalDialog from "@/components/ModalDialog.vue";
|
||||||
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import { unbindDeviceByQrcodeIdAPI } from "@/apis";
|
||||||
|
|
||||||
|
const deviceQrcodeId = ref("");
|
||||||
|
const showConfirmDialog = ref(false);
|
||||||
|
const isSubmitting = ref(false);
|
||||||
|
const isTestEnvironment = ref(false);
|
||||||
|
|
||||||
|
// 提交前移除用户输入中的所有空白字符,兼容复制粘贴的设备编号。
|
||||||
|
const normalizeDeviceQrcodeId = () =>
|
||||||
|
String(deviceQrcodeId.value ?? "").replace(/\s+/g, "");
|
||||||
|
|
||||||
|
const getEnvVersion = () => {
|
||||||
|
try {
|
||||||
|
return uni.getAccountInfoSync?.().miniProgram?.envVersion || "develop";
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取小程序环境失败", error);
|
||||||
|
return "develop";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const validateDeviceQrcodeId = () => {
|
||||||
|
const normalizedId = normalizeDeviceQrcodeId();
|
||||||
|
deviceQrcodeId.value = normalizedId;
|
||||||
|
const numericId = Number(normalizedId);
|
||||||
|
|
||||||
|
if (!/^\d+$/.test(normalizedId) || !Number.isSafeInteger(numericId) || numericId <= 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请输入正确的设备编号",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numericId;
|
||||||
|
};
|
||||||
|
|
||||||
|
const openConfirmDialog = () => {
|
||||||
|
if (!isTestEnvironment.value || validateDeviceQrcodeId() === null) return;
|
||||||
|
showConfirmDialog.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeConfirmDialog = () => {
|
||||||
|
if (isSubmitting.value) return;
|
||||||
|
showConfirmDialog.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmUnbind = async () => {
|
||||||
|
if (isSubmitting.value) return;
|
||||||
|
const id = validateDeviceQrcodeId();
|
||||||
|
if (id === null) {
|
||||||
|
showConfirmDialog.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSubmitting.value = true;
|
||||||
|
try {
|
||||||
|
await unbindDeviceByQrcodeIdAPI(id);
|
||||||
|
showConfirmDialog.value = false;
|
||||||
|
deviceQrcodeId.value = "";
|
||||||
|
uni.showToast({
|
||||||
|
title: "解绑成功",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("测试解绑设备失败", error);
|
||||||
|
} finally {
|
||||||
|
isSubmitting.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
if (getEnvVersion() !== "release") {
|
||||||
|
isTestEnvironment.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: "该功能仅用于测试环境",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack();
|
||||||
|
}, 1200);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container title="解绑设备" :scroll="false">
|
||||||
|
<view v-if="isTestEnvironment" class="unbind-page">
|
||||||
|
<view class="unbind-form">
|
||||||
|
<input
|
||||||
|
v-model="deviceQrcodeId"
|
||||||
|
class="device-input"
|
||||||
|
type="number"
|
||||||
|
placeholder="请输入设备编号"
|
||||||
|
placeholder-class="device-input-placeholder"
|
||||||
|
/>
|
||||||
|
<SButton
|
||||||
|
width="100%"
|
||||||
|
:rounded="40"
|
||||||
|
:onClick="openConfirmDialog"
|
||||||
|
>解绑</SButton>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
|
||||||
|
<ModalDialog
|
||||||
|
:show="showConfirmDialog"
|
||||||
|
content="是否解绑该设备(仅用于测试环境)"
|
||||||
|
cancelText="取消"
|
||||||
|
confirmText="解绑"
|
||||||
|
:onCancel="closeConfirmDialog"
|
||||||
|
:onConfirm="confirmUnbind"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.unbind-page {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0 72rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unbind-form {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 36rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.device-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 88rpx;
|
||||||
|
padding: 0 32rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.12);
|
||||||
|
border: 2rpx solid rgba(255, 255, 255, 0.28);
|
||||||
|
border-radius: 44rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.device-input-placeholder) {
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -195,7 +195,7 @@ const onClickShare = debounce(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void audioManager.warmAll();
|
void audioManager.warmCommon();
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
|
|||||||
+126
-51
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {onMounted, onUnmounted, ref} from "vue";
|
import {onMounted, onUnmounted, ref, watch} from "vue";
|
||||||
import {onShareAppMessage, onShareTimeline, onShow} from "@dcloudio/uni-app";
|
import {onShareAppMessage, onShareTimeline, onShow} from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import AppFooter from "@/components/AppFooter.vue";
|
import AppFooter from "@/components/AppFooter.vue";
|
||||||
@@ -52,20 +52,41 @@ const otaInfo = ref({
|
|||||||
forceUpdate: false,
|
forceUpdate: false,
|
||||||
});
|
});
|
||||||
const isStartingOta = ref(false);
|
const isStartingOta = ref(false);
|
||||||
|
let isCheckingOta = false;
|
||||||
|
let otaCheckQueuedForOnline = false;
|
||||||
let otaProgressTimer = null;
|
let otaProgressTimer = null;
|
||||||
let otaStatusTimer = null;
|
let otaStatusTimer = null;
|
||||||
let otaTimeoutTimer = null;
|
let otaTimeoutTimer = null;
|
||||||
|
let otaResultTimer = null;
|
||||||
|
let otaStatusPollCount = 0;
|
||||||
|
let otaUpdateRunId = 0;
|
||||||
|
// 首页 OTA 轮询采用请求次数和总时长双重兜底,避免更新中状态长期卡住。
|
||||||
|
const OTA_TASK_STATUS_POLL_INTERVAL = 2000;
|
||||||
|
const OTA_TASK_STATUS_MAX_POLL_COUNT = 15;
|
||||||
|
const OTA_TASK_STATUS_TIMEOUT = 30000;
|
||||||
|
|
||||||
// 清理首页 OTA 更新定时器,避免弹窗关闭或页面卸载后继续轮询。
|
// 清理首页 OTA 更新定时器,避免弹窗关闭或页面卸载后继续轮询。
|
||||||
const clearOtaUpdateTimers = () => {
|
const clearOtaUpdateTimers = () => {
|
||||||
clearInterval(otaProgressTimer);
|
clearInterval(otaProgressTimer);
|
||||||
clearTimeout(otaStatusTimer);
|
clearTimeout(otaStatusTimer);
|
||||||
clearTimeout(otaTimeoutTimer);
|
clearTimeout(otaTimeoutTimer);
|
||||||
|
clearTimeout(otaResultTimer);
|
||||||
otaProgressTimer = null;
|
otaProgressTimer = null;
|
||||||
otaStatusTimer = null;
|
otaStatusTimer = null;
|
||||||
otaTimeoutTimer = null;
|
otaTimeoutTimer = null;
|
||||||
|
otaResultTimer = null;
|
||||||
|
otaStatusPollCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 使当前 OTA 运行失效,确保旧请求返回后不会继续轮询或覆盖新状态。
|
||||||
|
const invalidateOtaUpdateRun = () => {
|
||||||
|
otaUpdateRunId += 1;
|
||||||
|
clearOtaUpdateTimers();
|
||||||
|
};
|
||||||
|
|
||||||
|
const isOtaUpdateRunActive = (runId) =>
|
||||||
|
runId === otaUpdateRunId && otaState.value === "update_progress";
|
||||||
|
|
||||||
// 启动首页 OTA 本地进度动画,最终成功失败以后端任务状态为准。
|
// 启动首页 OTA 本地进度动画,最终成功失败以后端任务状态为准。
|
||||||
const startOtaProgressAnimation = () => {
|
const startOtaProgressAnimation = () => {
|
||||||
clearInterval(otaProgressTimer);
|
clearInterval(otaProgressTimer);
|
||||||
@@ -91,21 +112,51 @@ const applyOtaVersionInfo = (versionInfo) => {
|
|||||||
|
|
||||||
// 检查当前设备盒子是否存在可升级版本。
|
// 检查当前设备盒子是否存在可升级版本。
|
||||||
const checkOtaUpdate = async () => {
|
const checkOtaUpdate = async () => {
|
||||||
let versionInfo;
|
if (isCheckingOta || otaVisible.value) return;
|
||||||
|
isCheckingOta = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
versionInfo = await getHardwareBoxVersionAPI();
|
let deviceStatus;
|
||||||
} catch (err) {
|
try {
|
||||||
|
deviceStatus = await getDeviceBatteryAPI();
|
||||||
|
} catch (err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceStatus?.online !== true || otaVisible.value) return;
|
||||||
|
|
||||||
|
let versionInfo;
|
||||||
|
try {
|
||||||
|
versionInfo = await getHardwareBoxVersionAPI();
|
||||||
|
} catch (err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!versionInfo?.needUpdate || otaVisible.value) return;
|
||||||
|
applyOtaVersionInfo(versionInfo);
|
||||||
|
|
||||||
|
const dismissedAt = uni.getStorageSync("ota_dismissed_at");
|
||||||
|
const now = Date.now();
|
||||||
|
if (!otaInfo.value.forceUpdate && dismissedAt && now - dismissedAt < 24 * 60 * 60 * 1000) return;
|
||||||
|
otaState.value = "new_version";
|
||||||
|
otaVisible.value = true;
|
||||||
|
} finally {
|
||||||
|
isCheckingOta = false;
|
||||||
|
const shouldRecheckForOnline = otaCheckQueuedForOnline;
|
||||||
|
otaCheckQueuedForOnline = false;
|
||||||
|
if (shouldRecheckForOnline && !otaVisible.value) {
|
||||||
|
void checkOtaUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 设备由 WS 通知上线时补查 OTA;已显示任何 OTA 弹窗时保留当前流程和结果。
|
||||||
|
watch(online, (nextOnline, previousOnline) => {
|
||||||
|
if (previousOnline !== false || nextOnline !== true || otaVisible.value) return;
|
||||||
|
if (isCheckingOta) {
|
||||||
|
otaCheckQueuedForOnline = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!versionInfo?.needUpdate) return;
|
void checkOtaUpdate();
|
||||||
applyOtaVersionInfo(versionInfo);
|
});
|
||||||
|
|
||||||
const dismissedAt = uni.getStorageSync("ota_dismissed_at");
|
|
||||||
const now = Date.now();
|
|
||||||
if (!otaInfo.value.forceUpdate && dismissedAt && now - dismissedAt < 24 * 60 * 60 * 1000) return;
|
|
||||||
otaState.value = "new_version";
|
|
||||||
otaVisible.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 拼接 OTA WiFi 页参数,让未连 WiFi 的设备继续使用同一份版本信息。
|
// 拼接 OTA WiFi 页参数,让未连 WiFi 的设备继续使用同一份版本信息。
|
||||||
const getOtaWifiUrl = () => {
|
const getOtaWifiUrl = () => {
|
||||||
@@ -125,61 +176,78 @@ const handleOtaDismiss = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 将首页 OTA 直连更新流程标记为失败。
|
// 将首页 OTA 直连更新流程标记为失败。
|
||||||
const failHomeOtaUpdate = () => {
|
const failHomeOtaUpdate = (runId) => {
|
||||||
clearOtaUpdateTimers();
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
|
invalidateOtaUpdateRun();
|
||||||
isStartingOta.value = false;
|
isStartingOta.value = false;
|
||||||
otaState.value = "update_failure";
|
otaState.value = "update_failure";
|
||||||
otaVisible.value = true;
|
otaVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 将首页 OTA 直连更新流程标记为成功。
|
// 将首页 OTA 直连更新流程标记为成功。
|
||||||
const completeHomeOtaUpdate = () => {
|
const completeHomeOtaUpdate = (runId) => {
|
||||||
clearOtaUpdateTimers();
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
|
invalidateOtaUpdateRun();
|
||||||
isStartingOta.value = false;
|
isStartingOta.value = false;
|
||||||
otaProgress.value = 100;
|
otaProgress.value = 100;
|
||||||
setTimeout(() => {
|
const completedRunId = otaUpdateRunId;
|
||||||
|
otaResultTimer = setTimeout(() => {
|
||||||
|
otaResultTimer = null;
|
||||||
|
if (completedRunId !== otaUpdateRunId) return;
|
||||||
otaState.value = "update_success";
|
otaState.value = "update_success";
|
||||||
otaVisible.value = true;
|
otaVisible.value = true;
|
||||||
}, 300);
|
}, 300);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 轮询首页直接发起的 OTA 更新任务状态。
|
// 轮询首页直接发起的 OTA 更新任务状态。
|
||||||
const pollHomeOtaTaskStatus = (taskId) => {
|
const pollHomeOtaTaskStatus = async (taskId, runId) => {
|
||||||
clearTimeout(otaStatusTimer);
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
otaStatusTimer = setTimeout(async () => {
|
|
||||||
try {
|
otaStatusPollCount += 1;
|
||||||
const taskStatus = await getHardwareBoxTaskStatusAPI(taskId);
|
try {
|
||||||
const status = Number(taskStatus?.status);
|
const taskStatus = await getHardwareBoxTaskStatusAPI(taskId);
|
||||||
if (status === 2) {
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
completeHomeOtaUpdate();
|
|
||||||
return;
|
const status = Number(taskStatus?.status);
|
||||||
}
|
if (status === 2) {
|
||||||
if (status === 3) {
|
completeHomeOtaUpdate(runId);
|
||||||
failHomeOtaUpdate();
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (status === 0 || status === 1) {
|
|
||||||
pollHomeOtaTaskStatus(taskId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
failHomeOtaUpdate();
|
|
||||||
} catch (err) {
|
|
||||||
failHomeOtaUpdate();
|
|
||||||
}
|
}
|
||||||
}, 3000);
|
if (status === 3) {
|
||||||
|
failHomeOtaUpdate(runId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (status === 0 || status === 1) {
|
||||||
|
if (otaStatusPollCount >= OTA_TASK_STATUS_MAX_POLL_COUNT) {
|
||||||
|
failHomeOtaUpdate(runId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
otaStatusTimer = setTimeout(() => {
|
||||||
|
otaStatusTimer = null;
|
||||||
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
|
void pollHomeOtaTaskStatus(taskId, runId);
|
||||||
|
}, OTA_TASK_STATUS_POLL_INTERVAL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
failHomeOtaUpdate(runId);
|
||||||
|
} catch (err) {
|
||||||
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
|
failHomeOtaUpdate(runId);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 设备盒子已连 WiFi 时,从首页直接传空 WiFi 信息发起 OTA 更新。
|
// 设备盒子已连 WiFi 时,从首页直接传空 WiFi 信息发起 OTA 更新。
|
||||||
const startHomeOtaUpdate = async () => {
|
const startHomeOtaUpdate = async () => {
|
||||||
|
invalidateOtaUpdateRun();
|
||||||
|
const runId = otaUpdateRunId;
|
||||||
otaState.value = "update_progress";
|
otaState.value = "update_progress";
|
||||||
otaVisible.value = true;
|
otaVisible.value = true;
|
||||||
otaProgress.value = 0;
|
otaProgress.value = 0;
|
||||||
startOtaProgressAnimation();
|
startOtaProgressAnimation();
|
||||||
otaTimeoutTimer = setTimeout(() => {
|
otaTimeoutTimer = setTimeout(() => {
|
||||||
if (otaState.value === "update_progress") {
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
failHomeOtaUpdate();
|
failHomeOtaUpdate(runId);
|
||||||
}
|
}, OTA_TASK_STATUS_TIMEOUT);
|
||||||
}, 5 * 60 * 1000);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const updateResult = await sendHardwareBoxUpdateAPI({
|
const updateResult = await sendHardwareBoxUpdateAPI({
|
||||||
@@ -188,13 +256,15 @@ const startHomeOtaUpdate = async () => {
|
|||||||
wifiPassword: "",
|
wifiPassword: "",
|
||||||
resourceUrl: otaInfo.value.resourceUrl,
|
resourceUrl: otaInfo.value.resourceUrl,
|
||||||
});
|
});
|
||||||
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
if (!updateResult?.taskId) {
|
if (!updateResult?.taskId) {
|
||||||
failHomeOtaUpdate();
|
failHomeOtaUpdate(runId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pollHomeOtaTaskStatus(updateResult.taskId);
|
void pollHomeOtaTaskStatus(updateResult.taskId, runId);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failHomeOtaUpdate();
|
if (!isOtaUpdateRunActive(runId)) return;
|
||||||
|
failHomeOtaUpdate(runId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -240,6 +310,7 @@ const handleOtaDone = () => {
|
|||||||
|
|
||||||
// 处理 OTA 更新失败后的重试按钮,重新走立即更新判断流程。
|
// 处理 OTA 更新失败后的重试按钮,重新走立即更新判断流程。
|
||||||
const handleOtaRetry = () => {
|
const handleOtaRetry = () => {
|
||||||
|
invalidateOtaUpdateRun();
|
||||||
handleOtaUpdate();
|
handleOtaUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -351,7 +422,7 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clearOtaUpdateTimers();
|
invalidateOtaUpdateRun();
|
||||||
});
|
});
|
||||||
|
|
||||||
onShareAppMessage(() => {
|
onShareAppMessage(() => {
|
||||||
@@ -511,6 +582,7 @@ onShareTimeline(() => {
|
|||||||
</view>
|
</view>
|
||||||
<Signin :show="showModal" :onClose="() => (showModal = false)"/>
|
<Signin :show="showModal" :onClose="() => (showModal = false)"/>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="foot-space"></view>
|
||||||
<AppFooter/>
|
<AppFooter/>
|
||||||
</Container>
|
</Container>
|
||||||
</template>
|
</template>
|
||||||
@@ -518,9 +590,12 @@ onShareTimeline(() => {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.container {
|
.container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100% - 120px);
|
/* height: calc(100% + 240rpx); */
|
||||||
|
}
|
||||||
|
.foot-space{
|
||||||
|
width: 100%;
|
||||||
|
height: 200rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.feature-grid {
|
.feature-grid {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -680,7 +755,7 @@ onShareTimeline(() => {
|
|||||||
|
|
||||||
.my-data > view:nth-child(2) {
|
.my-data > view:nth-child(2) {
|
||||||
width: 68%;
|
width: 68%;
|
||||||
font-size: 12px;
|
font-size: 24rpx;
|
||||||
color: #fff6;
|
color: #fff6;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ onLoad(async (options) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void audioManager.warmAll();
|
void audioManager.warmCommon();
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import BattleHeader from "@/components/BattleHeader.vue";
|
|||||||
import PlayerScore from "@/components/PlayerScore.vue";
|
import PlayerScore from "@/components/PlayerScore.vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import BowPower from "@/components/BowPower.vue";
|
||||||
import ScreenHint from "@/components/ScreenHint.vue";
|
import ScreenHint from "@/components/ScreenHint.vue";
|
||||||
import TestDistance from "@/components/TestDistance.vue";
|
import TestDistance from "@/components/TestDistance.vue";
|
||||||
import SModal from "@/components/SModal.vue";
|
import SModal from "@/components/SModal.vue";
|
||||||
@@ -489,8 +490,8 @@ onShow(() => {
|
|||||||
:totalRound="12"
|
:totalRound="12"
|
||||||
:scores="playersScores.map((r) => r[user.id]).flat()"
|
:scores="playersScores.map((r) => r[user.id]).flat()"
|
||||||
:isSvip="isCurrentUserSvip"
|
:isSvip="isCurrentUserSvip"
|
||||||
:missAsZero="true"
|
|
||||||
:stop="halfRest"
|
:stop="halfRest"
|
||||||
|
stable-shot-effect
|
||||||
/>
|
/>
|
||||||
<view :style="{ paddingBottom: '20px' }">
|
<view :style="{ paddingBottom: '20px' }">
|
||||||
<PlayerScore
|
<PlayerScore
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const memberTypes = [
|
|||||||
heroBadge: "../../static/vip/normal-hero-badge.png",
|
heroBadge: "../../static/vip/normal-hero-badge.png",
|
||||||
buttonClass: "activate-btn--normal",
|
buttonClass: "activate-btn--normal",
|
||||||
benefits: [
|
benefits: [
|
||||||
{ label: "专属会员标识", icon: "../../static/vip/vip-badge.png" },
|
{ label: "黄金昵称", icon: "../../static/vip/vip-badge.png" },
|
||||||
{ label: "教练点评", icon: "../../static/vip/vip-comment.png" },
|
{ label: "教练点评", icon: "../../static/vip/vip-comment.png" },
|
||||||
{ label: "专享VIP客服", icon: "../../static/vip/vip-service.png" },
|
{ label: "专享VIP客服", icon: "../../static/vip/vip-service.png" },
|
||||||
{ label: "排位赛\n每日+20次", icon: "../../static/vip/vip-rank.png" },
|
{ label: "排位赛\n每日+20次", icon: "../../static/vip/vip-rank.png" },
|
||||||
@@ -59,7 +59,7 @@ const memberTypes = [
|
|||||||
{ label: "专属落点标识", icon: "../../static/vip/svip-point.png" },
|
{ label: "专属落点标识", icon: "../../static/vip/svip-point.png" },
|
||||||
{ label: "专属命中效果", icon: "../../static/vip/svip-hit.png" },
|
{ label: "专属命中效果", icon: "../../static/vip/svip-hit.png" },
|
||||||
{ label: "专属射箭效果", icon: "../../static/vip/svip-arrow.png" },
|
{ label: "专属射箭效果", icon: "../../static/vip/svip-arrow.png" },
|
||||||
{ label: "专属会员标识", icon: "../../static/vip/svip-badge.png" },
|
{ label: "炫彩昵称", icon: "../../static/vip/svip-badge.png" },
|
||||||
{ label: "教练点评", icon: "../../static/vip/svip-comment.png" },
|
{ label: "教练点评", icon: "../../static/vip/svip-comment.png" },
|
||||||
{ label: "约战无限制", icon: "../../static/vip/svip-battle.png" },
|
{ label: "约战无限制", icon: "../../static/vip/svip-battle.png" },
|
||||||
{ label: "排位赛无限制", icon: "../../static/vip/svip-rank.png" },
|
{ label: "排位赛无限制", icon: "../../static/vip/svip-rank.png" },
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ import Container from "@/components/Container.vue";
|
|||||||
<view class="table-row">
|
<view class="table-row">
|
||||||
<text class="table-cell table-cell--feature">昵称美化</text>
|
<text class="table-cell table-cell--feature">昵称美化</text>
|
||||||
<text class="table-cell">无</text>
|
<text class="table-cell">无</text>
|
||||||
<text class="table-cell">专享</text>
|
<text class="table-cell">黄金</text>
|
||||||
<text class="table-cell">专享</text>
|
<text class="table-cell">炫彩</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="table-row">
|
<view class="table-row">
|
||||||
<text class="table-cell table-cell--feature">专属客服</text>
|
<text class="table-cell table-cell--feature">专属客服</text>
|
||||||
|
|||||||
+82
-16
@@ -1,25 +1,70 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
import ScorePanel from "@/components/ScorePanel.vue";
|
import ScorePanel2 from "@/components/TrainingScorePanel.vue";
|
||||||
import { getPractiseAPI } from "@/apis";
|
import { getPractiseDetailAPI } from "@/apis";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user } = storeToRefs(store);
|
const { user } = storeToRefs(store);
|
||||||
const arrows = ref([]);
|
const arrows = ref([]);
|
||||||
const isSvip = ref(false);
|
const isSvip = ref(false);
|
||||||
const total = ref(0);
|
const practiseDetail = ref({});
|
||||||
|
const trainingTypeNameMap = Object.freeze({
|
||||||
|
base: "基础训练",
|
||||||
|
endurance: "耐力训练",
|
||||||
|
precision: "精准训练",
|
||||||
|
rhythm: "节奏训练",
|
||||||
|
});
|
||||||
|
|
||||||
|
const trainingType = computed(() =>
|
||||||
|
String(practiseDetail.value.trainingType || "").trim().toLowerCase()
|
||||||
|
);
|
||||||
|
const trainingTypeName = computed(
|
||||||
|
() => trainingTypeNameMap[trainingType.value] || "自由训练"
|
||||||
|
);
|
||||||
|
const targetTypeText = computed(() => {
|
||||||
|
const targetType = Number(practiseDetail.value.targetType);
|
||||||
|
return targetType > 0 ? `${targetType}CM靶` : "";
|
||||||
|
});
|
||||||
|
const difficultyText = computed(() => {
|
||||||
|
const difficultyLevel = Number(practiseDetail.value.difficultyLevel);
|
||||||
|
return Number.isInteger(difficultyLevel) && difficultyLevel > 0
|
||||||
|
? `LV${difficultyLevel}`
|
||||||
|
: "";
|
||||||
|
});
|
||||||
|
const totalRings = computed(() => {
|
||||||
|
const interpretationTotal = Number(
|
||||||
|
practiseDetail.value.interpretation?.totalRings
|
||||||
|
);
|
||||||
|
if (Number.isFinite(interpretationTotal)) return interpretationTotal;
|
||||||
|
return arrows.value.reduce(
|
||||||
|
(total, arrow) => total + (Number(arrow.ring) || 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const normalizeArrow = (arrow = {}) => ({
|
||||||
|
...arrow,
|
||||||
|
ring: Number(arrow.ring) || 0,
|
||||||
|
ringX:
|
||||||
|
arrow.ringX === true ||
|
||||||
|
Number(arrow.ringX) === 1 ||
|
||||||
|
Number(arrow.ifX) === 1,
|
||||||
|
ok: arrow.ok === true || Number(arrow.ok) === 1,
|
||||||
|
});
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (!options.id) return;
|
if (!options.id) return;
|
||||||
const result = await getPractiseAPI(options.id || 176);
|
const result = (await getPractiseDetailAPI(options.id)) || {};
|
||||||
arrows.value = result.details;
|
practiseDetail.value = result;
|
||||||
isSvip.value = result.sVip === true;
|
arrows.value = Array.isArray(result.details)
|
||||||
total.value = result.details.length;
|
? result.details.map(normalizeArrow)
|
||||||
|
: [];
|
||||||
|
isSvip.value = result.sVip === true || user.value?.sVip === true;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -35,22 +80,29 @@ onLoad(async (options) => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
|
<view v-if="practiseDetail.id" class="practice-meta">
|
||||||
|
<text v-if="targetTypeText">{{ targetTypeText }}</text>
|
||||||
|
<text>{{ trainingTypeName }}</text>
|
||||||
|
<text v-if="difficultyText">{{ difficultyText }}</text>
|
||||||
|
</view>
|
||||||
<view :style="{ marginBottom: '20px' }">
|
<view :style="{ marginBottom: '20px' }">
|
||||||
<BowTarget :scores="arrows" :isSvip="isSvip" />
|
<BowTarget
|
||||||
|
:scores="arrows"
|
||||||
|
:isSvip="isSvip"
|
||||||
|
:enableShotEffect="false"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="desc">
|
<view class="desc">
|
||||||
<text>{{ arrows.length }}</text>
|
<text>{{ arrows.length }}</text>
|
||||||
<text>支箭,共</text>
|
<text>支箭,共</text>
|
||||||
<text>{{ arrows.reduce((a, b) => a + b.ring, 0) }}</text>
|
<text>{{ totalRings }}</text>
|
||||||
<text>环</text>
|
<text>环</text>
|
||||||
</view>
|
</view>
|
||||||
<ScorePanel
|
<ScorePanel2
|
||||||
:completeEffect="false"
|
|
||||||
:rowCount="total === 12 ? 6 : 9"
|
|
||||||
:total="total"
|
|
||||||
:arrows="arrows"
|
:arrows="arrows"
|
||||||
:margin="arrows.length === 12 ? 4 : 1"
|
:total="arrows.length"
|
||||||
:fontSize="arrows.length === 12 ? 25 : 22"
|
:trainingType="trainingType"
|
||||||
|
recordMode
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</Container>
|
</Container>
|
||||||
@@ -63,6 +115,20 @@ onLoad(async (options) => {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
.practice-meta {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 40rpx;
|
||||||
|
padding: 16rpx 0;
|
||||||
|
}
|
||||||
|
.practice-meta > text + text {
|
||||||
|
margin-left: 24rpx;
|
||||||
|
}
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
+22
-3
@@ -15,6 +15,25 @@ const selectedIndex = ref(0);
|
|||||||
const matchList = ref([]);
|
const matchList = ref([]);
|
||||||
const battleList = ref([]);
|
const battleList = ref([]);
|
||||||
const practiseList = ref([]);
|
const practiseList = ref([]);
|
||||||
|
const trainingTypeNameMap = Object.freeze({
|
||||||
|
base: "基础训练",
|
||||||
|
endurance: "耐力训练",
|
||||||
|
precision: "精准训练",
|
||||||
|
rhythm: "节奏训练",
|
||||||
|
});
|
||||||
|
|
||||||
|
const getTrainingTypeName = (trainingType) => {
|
||||||
|
const normalizedType = String(trainingType || "").trim().toLowerCase();
|
||||||
|
return trainingTypeNameMap[normalizedType] || "自由训练";
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatPractiseTime = (value) => {
|
||||||
|
const normalizedTime = String(value || "").trim();
|
||||||
|
const matchedTime = normalizedTime.match(
|
||||||
|
/^(\d{4}-\d{2}-\d{2})[T\s](\d{2}:\d{2}:\d{2})/
|
||||||
|
);
|
||||||
|
return matchedTime ? `${matchedTime[1]} ${matchedTime[2]}` : normalizedTime;
|
||||||
|
};
|
||||||
|
|
||||||
const toMatchDetail = (id) => {
|
const toMatchDetail = (id) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@@ -81,7 +100,7 @@ onLoad((options) => {
|
|||||||
<Container title="我的成长脚印" :scroll="false">
|
<Container title="我的成长脚印" :scroll="false">
|
||||||
<view class="tabs">
|
<view class="tabs">
|
||||||
<view
|
<view
|
||||||
v-for="(rankType, index) in ['排位赛', '好友约战', '个人练习']"
|
v-for="(rankType, index) in ['排位赛', '好友约战', '个人训练']"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="{
|
:style="{
|
||||||
color: index === selectedIndex ? '#000' : '#fff',
|
color: index === selectedIndex ? '#000' : '#fff',
|
||||||
@@ -153,8 +172,8 @@ onLoad((options) => {
|
|||||||
@click="() => getPractiseDetail(item.id)"
|
@click="() => getPractiseDetail(item.id)"
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
>{{ item.completed_arrows === 36 ? "耐力挑战" : "单组练习" }}
|
>{{ getTrainingTypeName(item.trainingType) }}
|
||||||
{{ item.createTime }}</text
|
{{ formatPractiseTime(item.createTime) }}</text
|
||||||
>
|
>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -0,0 +1,179 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Signin from "@/components/Signin.vue";
|
||||||
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
|
import { tempBindOrgAPI } from "@/apis";
|
||||||
|
|
||||||
|
const scene = ref("");
|
||||||
|
const status = ref("idle");
|
||||||
|
const errorMessage = ref("");
|
||||||
|
const showSignin = ref(false);
|
||||||
|
const binding = ref(false);
|
||||||
|
|
||||||
|
const getToken = () => {
|
||||||
|
try {
|
||||||
|
const env = uni.getAccountInfoSync().miniProgram.envVersion;
|
||||||
|
return uni.getStorageSync(`${env}_token`);
|
||||||
|
} catch (error) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const openSignin = () => {
|
||||||
|
showSignin.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeSignin = () => {
|
||||||
|
showSignin.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const bindOrg = async () => {
|
||||||
|
if (binding.value || !scene.value) return;
|
||||||
|
|
||||||
|
if (!getToken()) {
|
||||||
|
status.value = "login";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.value = true;
|
||||||
|
status.value = "binding";
|
||||||
|
errorMessage.value = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
await tempBindOrgAPI(scene.value);
|
||||||
|
status.value = "success";
|
||||||
|
} catch (error) {
|
||||||
|
if (error?.type === "AUTH_INVALID") {
|
||||||
|
status.value = "login";
|
||||||
|
errorMessage.value = "登录已失效,请重新登录后完成绑定。";
|
||||||
|
} else {
|
||||||
|
status.value = "failed";
|
||||||
|
errorMessage.value = error?.message || "网络异常,请稍后重试。";
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
binding.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLoginSuccess = async () => {
|
||||||
|
await bindOrg();
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
try {
|
||||||
|
const value = decodeURIComponent(String(options?.scene || ""));
|
||||||
|
if (!/^org_\d+$/.test(value)) {
|
||||||
|
status.value = "invalid";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scene.value = value;
|
||||||
|
if (getToken()) {
|
||||||
|
void bindOrg();
|
||||||
|
} else {
|
||||||
|
status.value = "login";
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
status.value = "invalid";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="page">
|
||||||
|
<view class="content">
|
||||||
|
<text class="title">机构设备绑定</text>
|
||||||
|
|
||||||
|
<view v-if="status === 'idle' || status === 'binding'" class="state">
|
||||||
|
<text class="state-title">正在绑定</text>
|
||||||
|
<text class="description">正在绑定机构设备,请稍候……</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="status === 'login'" class="state">
|
||||||
|
<text class="state-title">请先登录</text>
|
||||||
|
<text class="description">
|
||||||
|
{{
|
||||||
|
errorMessage ||
|
||||||
|
"登录后即可绑定当前机构设备。关闭登录窗口后,也可以再次点击下方按钮继续。"
|
||||||
|
}}
|
||||||
|
</text>
|
||||||
|
<SButton width="560rpx" :rounded="20" :onClick="openSignin">
|
||||||
|
<text>立即登录</text>
|
||||||
|
</SButton>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="status === 'success'" class="state">
|
||||||
|
<text class="state-title">绑定成功</text>
|
||||||
|
<text class="description">
|
||||||
|
您的账号已成功绑定机构设备,请返回 iPad 继续操作。
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="status === 'failed'" class="state">
|
||||||
|
<text class="state-title">绑定失败</text>
|
||||||
|
<text class="description">{{ errorMessage }}</text>
|
||||||
|
<SButton width="560rpx" :rounded="20" :onClick="bindOrg">
|
||||||
|
<text>重新绑定</text>
|
||||||
|
</SButton>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else class="state">
|
||||||
|
<text class="state-title">二维码无效</text>
|
||||||
|
<text class="description">请重新扫描机构设备上的小程序码。</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<Signin
|
||||||
|
:show="showSignin"
|
||||||
|
:onClose="closeSignin"
|
||||||
|
:onSuccess="handleLoginSuccess"
|
||||||
|
/>
|
||||||
|
<DeviceChargingDialog />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.page {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: calc(var(--status-bar-height) + 120rpx) 48rpx 80rpx;
|
||||||
|
background-color: #000;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 44rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.state {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 120rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.state-title {
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
max-width: 600rpx;
|
||||||
|
margin: 32rpx 0 64rpx;
|
||||||
|
color: #b8b8b8;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.8;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -5,6 +5,7 @@ import SButton from "@/components/SButton.vue";
|
|||||||
import BowTargetEdit from "@/components/BowTargetEdit.vue";
|
import BowTargetEdit from "@/components/BowTargetEdit.vue";
|
||||||
import ScreenHint2 from "@/components/ScreenHint2.vue";
|
import ScreenHint2 from "@/components/ScreenHint2.vue";
|
||||||
import RingBarChart from "@/components/RingBarChart.vue";
|
import RingBarChart from "@/components/RingBarChart.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
import { getPointBookDetailAPI, getPointBookConfigAPI } from "@/apis";
|
import { getPointBookDetailAPI, getPointBookConfigAPI } from "@/apis";
|
||||||
|
|
||||||
const selectedIndex = ref(0);
|
const selectedIndex = ref(0);
|
||||||
@@ -238,6 +239,7 @@ const targetTypeName = computed(() => {
|
|||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</ScreenHint2>
|
</ScreenHint2>
|
||||||
|
<DeviceChargingDialog />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ onShow(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
void audioManager.warmAll();
|
void audioManager.warmCommon();
|
||||||
// audioManager.play("第一轮");
|
// audioManager.play("第一轮");
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
@@ -466,6 +466,7 @@ onBeforeUnmount(() => {
|
|||||||
:currentRound="scores.length % 3"
|
:currentRound="scores.length % 3"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
:isSvip="isSvip"
|
:isSvip="isSvip"
|
||||||
|
stable-shot-effect
|
||||||
/>
|
/>
|
||||||
<ScorePanel2 :arrows="scores" />
|
<ScorePanel2 :arrows="scores" />
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ onShow(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
void audioManager.warmAll();
|
void audioManager.warmCommon();
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
|
|||||||
+344
-105
@@ -1,5 +1,61 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
|
|
||||||
|
const LEVEL_ICON_BASE_URL = "https://static.shelingxingqiu.com/levelicon";
|
||||||
|
|
||||||
|
const rankRows = [
|
||||||
|
{
|
||||||
|
name: "倔强青铜",
|
||||||
|
levels: ["倔强青铜1", "倔强青铜2", "倔强青铜3"],
|
||||||
|
picNames: ["青铜1", "青铜2", "青铜3"],
|
||||||
|
score: "每个小段位需要满3颗星才能晋升到下一个段位,共9颗星。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "秩序白银",
|
||||||
|
levels: ["秩序白银1", "秩序白银2", "秩序白银3"],
|
||||||
|
picNames: ["白银1", "白银2", "白银3"],
|
||||||
|
score: "每个小段位需要满3颗星才能晋升到下一个段位,共9颗星。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "荣耀黄金",
|
||||||
|
levels: ["荣耀黄金1", "荣耀黄金2", "荣耀黄金3", "荣耀黄金4"],
|
||||||
|
picNames: ["黄金1", "黄金2", "黄金3", "黄金4"],
|
||||||
|
score: "每个小段位需要满4颗星才能晋升到下一个段位,共16颗星。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "永恒钻石",
|
||||||
|
levels: ["永恒钻石1", "永恒钻石2", "永恒钻石3", "永恒钻石4", "永恒钻石5"],
|
||||||
|
picNames: ["钻石1", "钻石2", "钻石3", "钻石4", "钻石5"],
|
||||||
|
score: "每个小段位需要满5颗星才能晋升到下一个段位,共25颗星。",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const kingRankRows = [
|
||||||
|
{ name: "最强王者", score: "0-9" },
|
||||||
|
{ name: "非凡王者", score: "10-19" },
|
||||||
|
{ name: "无双王者", score: "20-29" },
|
||||||
|
{ name: "绝世王者", score: "30-39" },
|
||||||
|
{ name: "至圣王者", score: "40-49" },
|
||||||
|
{ name: "荣耀王者", score: "50-99" },
|
||||||
|
{ name: "传奇王者", score: "100+" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const meleeScoreTables = [
|
||||||
|
{
|
||||||
|
title: "5人大乱斗",
|
||||||
|
rankings: [1, 2, 3, 4, 5],
|
||||||
|
scores: [150, 75, 0, -100, -100],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "10人大乱斗",
|
||||||
|
rankings: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||||
|
scores: [200, 125, 75, 0, 0, 0, -50, -100, -100, -100],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 图片文件名与段位名称一致,统一在这里拼接远程地址。
|
||||||
|
const getLevelIcon = (levelName) =>
|
||||||
|
`${LEVEL_ICON_BASE_URL}/${levelName}.png`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -22,25 +78,89 @@ import Container from "@/components/Container.vue";
|
|||||||
|
|
||||||
<view class="sub-section">
|
<view class="sub-section">
|
||||||
<view class="sub-title">(一)基本规则</view>
|
<view class="sub-title">(一)基本规则</view>
|
||||||
<view class="rule-item">
|
<view class="rule-mode">
|
||||||
<text class="rule-label">重一局:</text>
|
<view class="rule-mode-title">1V1、2V2、3V3对抗模式:</view>
|
||||||
<text class="rule-value">+100积分</text>
|
<view class="rule-item">
|
||||||
|
<text class="rule-bullet">●</text>
|
||||||
|
<text class="rule-content"
|
||||||
|
>每胜一局,胜方每人+100积分;每负一局,负方每人-100积分</text
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<view class="rule-item">
|
||||||
|
<text class="rule-bullet">●</text>
|
||||||
|
<text class="rule-content"
|
||||||
|
>2V2模式:胜方队伍中,总成绩最高且箭均成绩≥7环者,为本局MVP,额外获得40积分。</text
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<view class="rule-item">
|
||||||
|
<text class="rule-bullet">●</text>
|
||||||
|
<text class="rule-content"
|
||||||
|
>3V3模式:胜方队伍中,总成绩最高且箭均成绩≥7环者,为本局MVP,额外获得60积分。</text
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<view class="rule-item">
|
||||||
|
<text class="rule-bullet">●</text>
|
||||||
|
<text class="rule-content"
|
||||||
|
>在1V1/2V2/3V3三种模式中,连续获得五连胜(三类模式一起算),则从第五场开始,每场胜利可额外再加15分,直至结束连胜。(仅限对抗模式,不含大乱斗模式。)</text
|
||||||
|
>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="rule-item">
|
|
||||||
<text class="rule-label">输一局:</text>
|
<view class="rule-mode">
|
||||||
<text class="rule-value">-100积分</text>
|
<view class="rule-mode-title">5人、10人大乱斗模式:</view>
|
||||||
</view>
|
<view class="rule-paragraph">
|
||||||
<view class="rule-item">
|
5人大乱斗和10人大乱斗按个人总环数成绩排序,排名从高到低依次设置系统默认奖励/扣除积分,默认初始排名和积分规则具体如下:
|
||||||
<text class="rule-label">全场MVP(2v2):</text>
|
</view>
|
||||||
<text class="rule-value">额外+40积分</text>
|
|
||||||
</view>
|
<view class="melee-score-table">
|
||||||
<view class="rule-item">
|
<view
|
||||||
<text class="rule-label">全场MVP(3v3):</text>
|
v-for="table in meleeScoreTables"
|
||||||
<text class="rule-value">额外+60积分</text>
|
:key="table.title"
|
||||||
</view>
|
class="melee-table-section"
|
||||||
<view class="rule-item">
|
>
|
||||||
<text class="rule-label">五连胜:</text>
|
<view class="melee-table-title">{{ table.title }}</view>
|
||||||
<text class="rule-value">每局额外+15积分</text>
|
<scroll-view
|
||||||
|
class="melee-table-scroll"
|
||||||
|
scroll-x
|
||||||
|
:enhanced="true"
|
||||||
|
:show-scrollbar="false"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
:class="[
|
||||||
|
'melee-table-body',
|
||||||
|
table.rankings.length > 5
|
||||||
|
? 'melee-table-body--wide'
|
||||||
|
: '',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<view class="melee-table-row">
|
||||||
|
<text class="melee-table-cell melee-table-label"
|
||||||
|
>排名</text
|
||||||
|
>
|
||||||
|
<text
|
||||||
|
v-for="ranking in table.rankings"
|
||||||
|
:key="ranking"
|
||||||
|
class="melee-table-cell"
|
||||||
|
>
|
||||||
|
{{ ranking }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="melee-table-row">
|
||||||
|
<text class="melee-table-cell melee-table-label"
|
||||||
|
>积分</text
|
||||||
|
>
|
||||||
|
<text
|
||||||
|
v-for="(score, index) in table.scores"
|
||||||
|
:key="index"
|
||||||
|
class="melee-table-cell"
|
||||||
|
>
|
||||||
|
{{ score }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -55,77 +175,57 @@ import Container from "@/components/Container.vue";
|
|||||||
<view class="section">
|
<view class="section">
|
||||||
<view class="title">三、(表格)</view>
|
<view class="title">三、(表格)</view>
|
||||||
<view class="rank-table">
|
<view class="rank-table">
|
||||||
<view class="table-row">
|
<view class="table-row table-header">
|
||||||
<text>大段位</text>
|
<text class="table-cell major-column">大段位</text>
|
||||||
<text>小段位</text>
|
<text class="table-cell minor-column">小段位</text>
|
||||||
<text>积分(100积分=1星)</text>
|
<text class="table-cell score-column">积分(100积分=1星)</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="table-row">
|
|
||||||
<text>倔强青铜</text>
|
<view
|
||||||
<view>
|
v-for="rank in rankRows"
|
||||||
<text>青铜1</text>
|
:key="rank.name"
|
||||||
<text>青铜2</text>
|
class="table-row rank-group-row"
|
||||||
<text>青铜3</text>
|
>
|
||||||
|
<view class="table-cell major-column major-rank-cell">
|
||||||
|
<image
|
||||||
|
class="rank-icon"
|
||||||
|
:src="getLevelIcon(rank.picNames[0])"
|
||||||
|
mode="aspectFit"
|
||||||
|
lazy-load
|
||||||
|
/>
|
||||||
|
<text class="major-rank-name">{{ rank.name }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text>每个小段位需要满 3星才能晋升到下一个段位,共9颗星。</text>
|
|
||||||
</view>
|
<view class="minor-column minor-rank-cell">
|
||||||
<view class="table-row">
|
<text
|
||||||
<text>秩序白银</text>
|
v-for="level in rank.levels"
|
||||||
<view>
|
:key="level"
|
||||||
<text>白铜1</text>
|
class="table-cell minor-rank-item"
|
||||||
<text>白铜2</text>
|
>
|
||||||
<text>白铜3</text>
|
{{ level }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text>每个小段位需要满 3颗星才能晋升到下一个段位,共9颗星。</text>
|
|
||||||
|
<text class="table-cell score-column score-text">
|
||||||
|
{{ rank.score }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="table-row">
|
|
||||||
<text>荣耀黄金</text>
|
<view
|
||||||
<view>
|
v-for="rank in kingRankRows"
|
||||||
<text>黄金1</text>
|
:key="rank.name"
|
||||||
<text>黄金2</text>
|
class="table-row king-rank-row"
|
||||||
<text>黄金3</text>
|
>
|
||||||
<text>黄金4</text>
|
<view class="table-cell king-rank-cell">
|
||||||
|
<image
|
||||||
|
class="rank-icon"
|
||||||
|
:src="getLevelIcon(rank.name)"
|
||||||
|
mode="aspectFit"
|
||||||
|
lazy-load
|
||||||
|
/>
|
||||||
|
<text class="major-rank-name">{{ rank.name }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text>每个小段位需要满4颗星才能晋升到下一个段位,共16颗星。</text>
|
<text class="table-cell king-score-cell">{{ rank.score }}</text>
|
||||||
</view>
|
|
||||||
<view class="table-row">
|
|
||||||
<text>永恒钻石</text>
|
|
||||||
<view>
|
|
||||||
<text>钻石1</text>
|
|
||||||
<text>钻石2</text>
|
|
||||||
<text>钻石3</text>
|
|
||||||
<text>钻石4</text>
|
|
||||||
<text>钻石5</text>
|
|
||||||
</view>
|
|
||||||
<text>每个小段位需要满5颗星才能晋升到下一个段位,共25颗星。</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>最强王者</text>
|
|
||||||
<text>0-9</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>非凡王者</text>
|
|
||||||
<text>10-19</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>无双王者</text>
|
|
||||||
<text>20-29</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>绝世王者</text>
|
|
||||||
<text>30-39</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>至圣王者</text>
|
|
||||||
<text>40-49</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>荣耀王者</text>
|
|
||||||
<text>50-99</text>
|
|
||||||
</view>
|
|
||||||
<view class="table-row2">
|
|
||||||
<text>传奇王者</text>
|
|
||||||
<text>100+</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -181,17 +281,103 @@ import Container from "@/components/Container.vue";
|
|||||||
|
|
||||||
.rule-item {
|
.rule-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 8px;
|
align-items: flex-start;
|
||||||
}
|
margin-bottom: 16rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
.rule-label {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #666666;
|
color: #666666;
|
||||||
|
line-height: 1.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rule-value {
|
.rule-mode {
|
||||||
font-size: 14px;
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-mode:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-mode-title {
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-bullet {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
font-size: 20rpx;
|
||||||
|
line-height: 2.38;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-content {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-paragraph {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666666;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-score-table {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
border: $uni-border;
|
||||||
|
color: #333333;
|
||||||
|
font-size: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-section + .melee-table-section {
|
||||||
|
border-top: $uni-border;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-title {
|
||||||
|
padding: 14rpx 16rpx;
|
||||||
|
background-color: #f5f6f7;
|
||||||
|
color: #e53935;
|
||||||
|
font-weight: 600;
|
||||||
|
border-bottom: $uni-border;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-scroll {
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-body {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-body--wide {
|
||||||
|
width: 900rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-row {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-row + .melee-table-row {
|
||||||
|
border-top: $uni-border;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-cell {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 72rpx;
|
||||||
|
padding: 10rpx 12rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-left: $uni-border;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-cell:first-child {
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.melee-table-label {
|
||||||
|
flex: 0 0 86rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rank-table {
|
.rank-table {
|
||||||
@@ -201,41 +387,94 @@ import Container from "@/components/Container.vue";
|
|||||||
width: calc(100vw - 20px);
|
width: calc(100vw - 20px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rank-table > view {
|
.table-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rank-table > view > text:last-child {
|
.table-cell {
|
||||||
margin-left: -1rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rank-table text {
|
|
||||||
padding: 10rpx 20rpx;
|
padding: 10rpx 20rpx;
|
||||||
border: $uni-border;
|
border: $uni-border;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: inline-block;
|
|
||||||
margin-top: -1rpx;
|
margin-top: -1rpx;
|
||||||
|
margin-left: -1rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-row text {
|
.major-column,
|
||||||
|
.minor-column {
|
||||||
width: 25%;
|
width: 25%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-row > view {
|
.score-column {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-header .table-cell {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.major-rank-cell,
|
||||||
|
.minor-rank-cell {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 25%;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-row > view > text {
|
.minor-rank-item {
|
||||||
|
min-height: 70rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.major-rank-cell {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 12rpx 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rank-icon {
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.major-rank-name {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 1.4;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minor-rank-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 10rpx;
|
||||||
|
border-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-row > text:nth-child(3) {
|
.score-text {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.king-rank-cell,
|
||||||
|
.king-score-cell {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-row2 > text {
|
.king-rank-cell {
|
||||||
width: 50%;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 210rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.king-score-cell {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { computed, nextTick, onMounted, ref } from "vue";
|
import { computed, nextTick, onMounted, ref } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
import {
|
import {
|
||||||
getMvpRankList,
|
getMvpRankList,
|
||||||
getMyMvpRank,
|
getMyMvpRank,
|
||||||
@@ -524,6 +525,7 @@ const measureTabsMetrics = () => {
|
|||||||
{{ getRankUnit() }}
|
{{ getRankUnit() }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
<DeviceChargingDialog />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,34 @@ import { getDeviceBatteryAPI } from "@/apis";
|
|||||||
|
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
|
let disposed = false;
|
||||||
|
let requestInFlight = false;
|
||||||
|
|
||||||
|
const refreshPower = async () => {
|
||||||
|
if (disposed || requestInFlight) return;
|
||||||
|
requestInFlight = true;
|
||||||
|
try {
|
||||||
|
const data = await getDeviceBatteryAPI();
|
||||||
|
if (!disposed) power.value = data.battery;
|
||||||
|
} catch (_) {
|
||||||
|
// 电量轮询失败时等待下一轮,避免产生未处理的 Promise 拒绝。
|
||||||
|
} finally {
|
||||||
|
requestInFlight = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const data = await getDeviceBatteryAPI();
|
await refreshPower();
|
||||||
power.value = data.battery;
|
if (disposed) return;
|
||||||
timer.value = setInterval(async () => {
|
timer.value = setInterval(() => {
|
||||||
const data = await getDeviceBatteryAPI();
|
void refreshPower();
|
||||||
power.value = data.battery;
|
|
||||||
}, 1000 * 10);
|
}, 1000 * 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
disposed = true;
|
||||||
clearInterval(timer.value);
|
clearInterval(timer.value);
|
||||||
|
timer.value = null;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 5,
|
default: 5,
|
||||||
},
|
},
|
||||||
|
stableShotEffect: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const pMode = ref(true);
|
const pMode = ref(true);
|
||||||
@@ -77,12 +81,14 @@ const dirTimer = ref(null);
|
|||||||
const angle = ref(null);
|
const angle = ref(null);
|
||||||
const circleColor = ref("");
|
const circleColor = ref("");
|
||||||
const shotEffect = ref(null);
|
const shotEffect = ref(null);
|
||||||
|
const pendingShotEffect = ref(null);
|
||||||
const hiddenRedLatestKey = ref("");
|
const hiddenRedLatestKey = ref("");
|
||||||
const hiddenBlueLatestKey = ref("");
|
const hiddenBlueLatestKey = ref("");
|
||||||
const targetShaking = ref(false);
|
const targetShaking = ref(false);
|
||||||
const targetRect = ref({ left: 0, top: 0, width: 0, height: 0 });
|
const targetRect = ref({ left: 0, top: 0, width: 0, height: 0 });
|
||||||
const shakeTimer = ref(null);
|
const shakeTimer = ref(null);
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
|
let shotEffectRequestGeneration = 0;
|
||||||
const ROUND_TIP_OFFSET_Y = -32;
|
const ROUND_TIP_OFFSET_Y = -32;
|
||||||
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
||||||
|
|
||||||
@@ -137,7 +143,7 @@ function showShotTip(team, shootData) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerShotEffect(team, shot, fallbackKey = "") {
|
function triggerShotEffect(team, shot, fallbackKey = "", viewportMode = false) {
|
||||||
const key = buildShotEffectKey(team, shot, fallbackKey);
|
const key = buildShotEffectKey(team, shot, fallbackKey);
|
||||||
|
|
||||||
if (shotEffect.value?.team === "red") hiddenRedLatestKey.value = "";
|
if (shotEffect.value?.team === "red") hiddenRedLatestKey.value = "";
|
||||||
@@ -151,7 +157,29 @@ function triggerShotEffect(team, shot, fallbackKey = "") {
|
|||||||
hiddenBlueLatestKey.value = key;
|
hiddenBlueLatestKey.value = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
shotEffect.value = { key, team, shot };
|
shotEffect.value = { key, team, shot, viewportMode };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function prepareShotEffect(team, shot, fallbackKey = "") {
|
||||||
|
const requestGeneration = ++shotEffectRequestGeneration;
|
||||||
|
const key = buildShotEffectKey(team, shot, fallbackKey);
|
||||||
|
pendingShotEffect.value = { generation: requestGeneration, team, key };
|
||||||
|
clearTipTimer();
|
||||||
|
if (team === "red") latestOne.value = null;
|
||||||
|
if (team === "blue") bluelatestOne.value = null;
|
||||||
|
|
||||||
|
const viewportMode = props.stableShotEffect
|
||||||
|
? await updateTargetRect()
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (requestGeneration !== shotEffectRequestGeneration) {
|
||||||
|
if (pendingShotEffect.value?.generation === requestGeneration) {
|
||||||
|
pendingShotEffect.value = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pendingShotEffect.value = null;
|
||||||
|
triggerShotEffect(team, shot, fallbackKey, viewportMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function completeShotEffect(key) {
|
function completeShotEffect(key) {
|
||||||
@@ -180,49 +208,74 @@ function shakeTarget() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTargetRect() {
|
function hasValidTargetRect(rect = targetRect.value) {
|
||||||
nextTick(() => {
|
return (
|
||||||
const query = instance?.proxy
|
Number.isFinite(Number(rect?.left)) &&
|
||||||
? uni.createSelectorQuery().in(instance.proxy)
|
Number.isFinite(Number(rect?.top)) &&
|
||||||
: uni.createSelectorQuery();
|
Number(rect?.width) > 0 &&
|
||||||
|
Number(rect?.height) > 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
query
|
async function updateTargetRect() {
|
||||||
.select(".target")
|
await nextTick();
|
||||||
.boundingClientRect((rect) => {
|
|
||||||
const left = Number(rect?.left);
|
return new Promise((resolve) => {
|
||||||
const top = Number(rect?.top);
|
let settled = false;
|
||||||
const width = Number(rect?.width);
|
const finish = (rect) => {
|
||||||
const height = Number(rect?.height);
|
if (settled) return;
|
||||||
if (
|
settled = true;
|
||||||
!Number.isFinite(left) ||
|
|
||||||
!Number.isFinite(top) ||
|
const isValid = hasValidTargetRect(rect);
|
||||||
!Number.isFinite(width) ||
|
if (isValid) {
|
||||||
!Number.isFinite(height)
|
targetRect.value = {
|
||||||
) {
|
left: Number(rect.left),
|
||||||
return;
|
top: Number(rect.top),
|
||||||
}
|
width: Number(rect.width),
|
||||||
if (width <= 0 || height <= 0) return;
|
height: Number(rect.height),
|
||||||
targetRect.value = { left, top, width, height };
|
};
|
||||||
})
|
}
|
||||||
.exec();
|
resolve(isValid);
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const query = instance?.proxy
|
||||||
|
? uni.createSelectorQuery().in(instance.proxy)
|
||||||
|
: uni.createSelectorQuery();
|
||||||
|
|
||||||
|
query
|
||||||
|
.select(".target")
|
||||||
|
.boundingClientRect()
|
||||||
|
.exec((result) => finish(Array.isArray(result) ? result[0] : null));
|
||||||
|
} catch {
|
||||||
|
finish(null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWindowResize() {
|
function handleWindowResize() {
|
||||||
updateTargetRect();
|
void updateTargetRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldHideRedHit(index) {
|
function shouldHideRedHit(index) {
|
||||||
return !!hiddenRedLatestKey.value && index === props.scores.length - 1;
|
return (
|
||||||
|
(!!hiddenRedLatestKey.value || pendingShotEffect.value?.team === "red") &&
|
||||||
|
index === props.scores.length - 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldHideBlueHit(index) {
|
function shouldHideBlueHit(index) {
|
||||||
return !!hiddenBlueLatestKey.value && index === props.blueScores.length - 1;
|
return (
|
||||||
|
(!!hiddenBlueLatestKey.value || pendingShotEffect.value?.team === "blue") &&
|
||||||
|
index === props.blueScores.length - 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showShotFlash(flash) {
|
function showShotFlash(flash) {
|
||||||
const shootData = flash?.shootData;
|
const shootData = flash?.shootData;
|
||||||
if (!shootData) {
|
if (!shootData) {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
hiddenRedLatestKey.value = "";
|
hiddenRedLatestKey.value = "";
|
||||||
hiddenBlueLatestKey.value = "";
|
hiddenBlueLatestKey.value = "";
|
||||||
shotEffect.value = null;
|
shotEffect.value = null;
|
||||||
@@ -231,10 +284,12 @@ function showShotFlash(flash) {
|
|||||||
|
|
||||||
const team = flash.team === "red" ? "red" : "blue";
|
const team = flash.team === "red" ? "red" : "blue";
|
||||||
if (shouldPlayShotEffect(shootData, team)) {
|
if (shouldPlayShotEffect(shootData, team)) {
|
||||||
triggerShotEffect(team, shootData, flash.key);
|
void prepareShotEffect(team, shootData, flash.key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
showShotTip(team, shootData);
|
showShotTip(team, shootData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +305,8 @@ watch(
|
|||||||
() => props.scores.length,
|
() => props.scores.length,
|
||||||
(newLen, oldLen) => {
|
(newLen, oldLen) => {
|
||||||
if (newLen > oldLen) return;
|
if (newLen > oldLen) return;
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
latestOne.value = null;
|
latestOne.value = null;
|
||||||
hiddenRedLatestKey.value = "";
|
hiddenRedLatestKey.value = "";
|
||||||
if (shotEffect.value?.team === "red") shotEffect.value = null;
|
if (shotEffect.value?.team === "red") shotEffect.value = null;
|
||||||
@@ -260,6 +317,8 @@ watch(
|
|||||||
() => props.blueScores.length,
|
() => props.blueScores.length,
|
||||||
(newLen, oldLen) => {
|
(newLen, oldLen) => {
|
||||||
if (newLen > oldLen) return;
|
if (newLen > oldLen) return;
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
bluelatestOne.value = null;
|
bluelatestOne.value = null;
|
||||||
hiddenBlueLatestKey.value = "";
|
hiddenBlueLatestKey.value = "";
|
||||||
if (shotEffect.value?.team === "blue") shotEffect.value = null;
|
if (shotEffect.value?.team === "blue") shotEffect.value = null;
|
||||||
@@ -417,11 +476,13 @@ async function onReceiveMessage(message) {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
updateTargetRect();
|
void updateTargetRect();
|
||||||
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
if (timer.value) {
|
if (timer.value) {
|
||||||
clearTimeout(timer.value);
|
clearTimeout(timer.value);
|
||||||
timer.value = null;
|
timer.value = null;
|
||||||
@@ -539,6 +600,7 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<BowShotEffect
|
<BowShotEffect
|
||||||
|
v-if="!shotEffect || !shotEffect.viewportMode"
|
||||||
:shot="shotEffect && shotEffect.shot"
|
:shot="shotEffect && shotEffect.shot"
|
||||||
:playKey="shotEffect ? shotEffect.key : ''"
|
:playKey="shotEffect ? shotEffect.key : ''"
|
||||||
:targetRadius="safeTargetRadius"
|
:targetRadius="safeTargetRadius"
|
||||||
@@ -552,6 +614,20 @@ onBeforeUnmount(() => {
|
|||||||
/>
|
/>
|
||||||
<image src="https://static.shelingxingqiu.com/shootmini/static/bow-target.png" mode="widthFix" />
|
<image src="https://static.shelingxingqiu.com/shootmini/static/bow-target.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
|
<BowShotEffect
|
||||||
|
v-if="shotEffect && shotEffect.viewportMode"
|
||||||
|
:shot="shotEffect.shot"
|
||||||
|
:playKey="shotEffect.key"
|
||||||
|
:targetRadius="safeTargetRadius"
|
||||||
|
:targetLeft="targetRect.left"
|
||||||
|
:targetTop="targetRect.top"
|
||||||
|
:targetWidth="targetRect.width"
|
||||||
|
:targetHeight="targetRect.height"
|
||||||
|
:hitOffsetPx="currentHitRadiusPx"
|
||||||
|
:viewportMode="true"
|
||||||
|
@impact="shakeTarget"
|
||||||
|
@complete="completeShotEffect"
|
||||||
|
/>
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
<PointSwitcher
|
<PointSwitcher
|
||||||
:onChange="(val) => (pMode = val)"
|
:onChange="(val) => (pMode = val)"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import AppBackground from "./AppBackground.vue";
|
|||||||
import Header from "./Header.vue";
|
import Header from "./Header.vue";
|
||||||
import ScreenHint from "./ScreenHint.vue";
|
import ScreenHint from "./ScreenHint.vue";
|
||||||
import BackToGame from "./BackToGame.vue";
|
import BackToGame from "./BackToGame.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
import {laserAimAPI, getBattleAPI, matchGameAPI} from "@/apis";
|
import {laserAimAPI, getBattleAPI, matchGameAPI} from "@/apis";
|
||||||
import { capsuleHeight, debounce } from "@/util";
|
import { capsuleHeight, debounce } from "@/util";
|
||||||
import { returnToBattle } from "@/utils/matchReturn";
|
import { returnToBattle } from "@/utils/matchReturn";
|
||||||
@@ -204,6 +205,7 @@ const goCalibration = async () => {
|
|||||||
<text>{{ loadingText || "加载中..." }}</text>
|
<text>{{ loadingText || "加载中..." }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<DeviceChargingDialog />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ onBeforeUnmount(() => {
|
|||||||
<view v-if="isBattle" class="ready-timer">
|
<view v-if="isBattle" class="ready-timer">
|
||||||
<image src="https://static.shelingxingqiu.com/shootmini/static/test-tip.png" mode="widthFix" />
|
<image src="https://static.shelingxingqiu.com/shootmini/static/test-tip.png" mode="widthFix" />
|
||||||
<view v-if="count >= 0">
|
<view v-if="count >= 0">
|
||||||
<text>具体正式比赛还有</text>
|
<text>距离正式比赛还有</text>
|
||||||
<text>{{ count }}</text>
|
<text>{{ count }}</text>
|
||||||
<text>秒</text>
|
<text>秒</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
MATCH_WS_STATE_EVENT,
|
MATCH_WS_STATE_EVENT,
|
||||||
} from "@/matchWebsocket";
|
} from "@/matchWebsocket";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText, getInvalidShotAudioKey } from "@/util";
|
||||||
import { takeMatchReturnSnapshot } from "@/utils/matchReturn";
|
import { takeMatchReturnSnapshot } from "@/utils/matchReturn";
|
||||||
import audioManager, {
|
import audioManager, {
|
||||||
AUDIO_INTERRUPTION_BEGIN_EVENT,
|
AUDIO_INTERRUPTION_BEGIN_EVENT,
|
||||||
@@ -1136,7 +1136,9 @@ async function runInvalidShotTask(task, runId) {
|
|||||||
title: "距离不足,无效",
|
title: "距离不足,无效",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
await playAudioKeys("射击无效", { interrupt: false });
|
await playAudioKeys(getInvalidShotAudioKey(task.message?.shootData), {
|
||||||
|
interrupt: false,
|
||||||
|
});
|
||||||
notifyMatchAudioAck(task);
|
notifyMatchAudioAck(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1417,6 +1419,7 @@ onShow(() => {
|
|||||||
:latestShotFlash="latestShotFlash"
|
:latestShotFlash="latestShotFlash"
|
||||||
:redTeam="redTeam"
|
:redTeam="redTeam"
|
||||||
:blueTeam="blueTeam"
|
:blueTeam="blueTeam"
|
||||||
|
stable-shot-effect
|
||||||
/>
|
/>
|
||||||
<BattleFooter
|
<BattleFooter
|
||||||
v-if="start"
|
v-if="start"
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
highlightRefreshToken: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
mode: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "solo", // solo 单排,team 双排
|
default: "solo", // solo 单排,team 双排
|
||||||
@@ -84,6 +88,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
stableShotEffect: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["shot-effect-complete"]);
|
const emit = defineEmits(["shot-effect-complete"]);
|
||||||
@@ -91,21 +99,35 @@ const emit = defineEmits(["shot-effect-complete"]);
|
|||||||
const pMode = ref(true);
|
const pMode = ref(true);
|
||||||
const latestOne = ref(null);
|
const latestOne = ref(null);
|
||||||
const bluelatestOne = ref(null);
|
const bluelatestOne = ref(null);
|
||||||
const prevScores = ref([]);
|
|
||||||
const prevBlueScores = ref([]);
|
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
const dirTimer = ref(null);
|
const dirTimer = ref(null);
|
||||||
const angle = ref(null);
|
const angle = ref(null);
|
||||||
const circleColor = ref("");
|
const circleColor = ref("");
|
||||||
const shotEffect = ref(null);
|
const shotEffect = ref(null);
|
||||||
|
const pendingShotEffect = ref(null);
|
||||||
const hiddenLatestKey = ref("");
|
const hiddenLatestKey = ref("");
|
||||||
const targetShaking = ref(false);
|
const targetShaking = ref(false);
|
||||||
const targetRect = ref({ left: 0, top: 0, width: 0, height: 0 });
|
const targetRect = ref({ left: 0, top: 0, width: 0, height: 0 });
|
||||||
const shakeTimer = ref(null);
|
const shakeTimer = ref(null);
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
|
let shotEffectRequestGeneration = 0;
|
||||||
|
const MAX_VISIBLE_TARGET_SHOTS = 12;
|
||||||
const ROUND_TIP_OFFSET_Y = -32;
|
const ROUND_TIP_OFFSET_Y = -32;
|
||||||
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
||||||
|
|
||||||
|
// 长时训练只保留最近一组命中点在靶面上,完整成绩仍由父页面保存并用于结算。
|
||||||
|
const getVisibleScoreEntries = (scores = []) => {
|
||||||
|
const startIndex = Math.max(scores.length - MAX_VISIBLE_TARGET_SHOTS, 0);
|
||||||
|
return scores.slice(startIndex).map((shot, offset) => ({
|
||||||
|
shot,
|
||||||
|
index: startIndex + offset,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
const visibleScoreEntries = computed(() => getVisibleScoreEntries(props.scores));
|
||||||
|
const visibleBlueScoreEntries = computed(() =>
|
||||||
|
getVisibleScoreEntries(props.blueScores)
|
||||||
|
);
|
||||||
|
|
||||||
const getNumber = (value, fallback = 0) => {
|
const getNumber = (value, fallback = 0) => {
|
||||||
const numberValue = Number(value);
|
const numberValue = Number(value);
|
||||||
return Number.isFinite(numberValue) ? numberValue : fallback;
|
return Number.isFinite(numberValue) ? numberValue : fallback;
|
||||||
@@ -245,7 +267,7 @@ function buildShotEffectKey(shot, index) {
|
|||||||
].join("-");
|
].join("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerShotEffect(shot, index) {
|
function triggerShotEffect(shot, index, viewportMode = false) {
|
||||||
const key = buildShotEffectKey(shot, index);
|
const key = buildShotEffectKey(shot, index);
|
||||||
clearTipTimer();
|
clearTipTimer();
|
||||||
latestOne.value = null;
|
latestOne.value = null;
|
||||||
@@ -254,9 +276,31 @@ function triggerShotEffect(shot, index) {
|
|||||||
key,
|
key,
|
||||||
shot,
|
shot,
|
||||||
token: props.shotEffectToken,
|
token: props.shotEffectToken,
|
||||||
|
viewportMode,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function prepareShotEffect(shot, index) {
|
||||||
|
const requestGeneration = ++shotEffectRequestGeneration;
|
||||||
|
const key = buildShotEffectKey(shot, index);
|
||||||
|
pendingShotEffect.value = { generation: requestGeneration, key };
|
||||||
|
clearTipTimer();
|
||||||
|
latestOne.value = null;
|
||||||
|
|
||||||
|
const viewportMode = props.stableShotEffect
|
||||||
|
? await updateTargetRect()
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (requestGeneration !== shotEffectRequestGeneration) {
|
||||||
|
if (pendingShotEffect.value?.generation === requestGeneration) {
|
||||||
|
pendingShotEffect.value = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pendingShotEffect.value = null;
|
||||||
|
triggerShotEffect(shot, index, viewportMode);
|
||||||
|
}
|
||||||
|
|
||||||
function completeShotEffect(key) {
|
function completeShotEffect(key) {
|
||||||
if (!shotEffect.value || shotEffect.value.key !== key) return;
|
if (!shotEffect.value || shotEffect.value.key !== key) return;
|
||||||
|
|
||||||
@@ -272,7 +316,10 @@ function completeShotEffect(key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldHideLatestHit(index) {
|
function shouldHideLatestHit(index) {
|
||||||
return !!hiddenLatestKey.value && index === props.scores.length - 1;
|
return (
|
||||||
|
(!!hiddenLatestKey.value || !!pendingShotEffect.value) &&
|
||||||
|
index === props.scores.length - 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shakeTarget() {
|
function shakeTarget() {
|
||||||
@@ -291,53 +338,68 @@ function shakeTarget() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTargetRect() {
|
function hasValidTargetRect(rect = targetRect.value) {
|
||||||
nextTick(() => {
|
return (
|
||||||
const query = instance?.proxy
|
Number.isFinite(Number(rect?.left)) &&
|
||||||
? uni.createSelectorQuery().in(instance.proxy)
|
Number.isFinite(Number(rect?.top)) &&
|
||||||
: uni.createSelectorQuery();
|
Number(rect?.width) > 0 &&
|
||||||
|
Number(rect?.height) > 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
query
|
async function updateTargetRect() {
|
||||||
.select(".target")
|
await nextTick();
|
||||||
.boundingClientRect((rect) => {
|
|
||||||
const left = Number(rect?.left);
|
return new Promise((resolve) => {
|
||||||
const top = Number(rect?.top);
|
let settled = false;
|
||||||
const width = Number(rect?.width);
|
const finish = (rect) => {
|
||||||
const height = Number(rect?.height);
|
if (settled) return;
|
||||||
if (
|
settled = true;
|
||||||
!Number.isFinite(left) ||
|
|
||||||
!Number.isFinite(top) ||
|
const isValid = hasValidTargetRect(rect);
|
||||||
!Number.isFinite(width) ||
|
if (isValid) {
|
||||||
!Number.isFinite(height)
|
targetRect.value = {
|
||||||
) {
|
left: Number(rect.left),
|
||||||
return;
|
top: Number(rect.top),
|
||||||
}
|
width: Number(rect.width),
|
||||||
if (width <= 0 || height <= 0) return;
|
height: Number(rect.height),
|
||||||
targetRect.value = { left, top, width, height };
|
};
|
||||||
})
|
}
|
||||||
.exec();
|
resolve(isValid);
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const query = instance?.proxy
|
||||||
|
? uni.createSelectorQuery().in(instance.proxy)
|
||||||
|
: uni.createSelectorQuery();
|
||||||
|
|
||||||
|
query
|
||||||
|
.select(".target")
|
||||||
|
.boundingClientRect()
|
||||||
|
.exec((result) => finish(Array.isArray(result) ? result[0] : null));
|
||||||
|
} catch {
|
||||||
|
finish(null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWindowResize() {
|
function handleWindowResize() {
|
||||||
updateTargetRect();
|
void updateTargetRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.scores,
|
() => props.scores.length,
|
||||||
(newVal) => {
|
(newLength, oldLength = 0) => {
|
||||||
if (newVal.length - prevScores.value.length === 1) {
|
if (newLength - oldLength === 1) {
|
||||||
showShotTip(newVal[newVal.length - 1]);
|
showShotTip(props.scores[newLength - 1]);
|
||||||
} else if (newVal.length < prevScores.value.length) {
|
} else if (newLength < oldLength) {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
clearTipTimer();
|
clearTipTimer();
|
||||||
latestOne.value = null;
|
latestOne.value = null;
|
||||||
hiddenLatestKey.value = "";
|
hiddenLatestKey.value = "";
|
||||||
shotEffect.value = null;
|
shotEffect.value = null;
|
||||||
}
|
}
|
||||||
prevScores.value = [...newVal];
|
|
||||||
},
|
|
||||||
{
|
|
||||||
deep: true,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -349,25 +411,24 @@ watch(
|
|||||||
const latestIndex = props.scores.length - 1;
|
const latestIndex = props.scores.length - 1;
|
||||||
const latestShot = props.scores[latestIndex];
|
const latestShot = props.scores[latestIndex];
|
||||||
if (shouldPlayShotEffect(latestShot)) {
|
if (shouldPlayShotEffect(latestShot)) {
|
||||||
triggerShotEffect(latestShot, latestIndex);
|
void prepareShotEffect(latestShot, latestIndex);
|
||||||
|
} else {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.blueScores,
|
() => props.blueScores.length,
|
||||||
(newVal) => {
|
(newLength, oldLength = 0) => {
|
||||||
if (newVal.length - prevBlueScores.value.length === 1) {
|
if (newLength - oldLength === 1) {
|
||||||
bluelatestOne.value = newVal[newVal.length - 1];
|
bluelatestOne.value = props.blueScores[newLength - 1];
|
||||||
if (timer.value) clearTimeout(timer.value);
|
if (timer.value) clearTimeout(timer.value);
|
||||||
timer.value = setTimeout(() => {
|
timer.value = setTimeout(() => {
|
||||||
bluelatestOne.value = null;
|
bluelatestOne.value = null;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
prevBlueScores.value = [...newVal];
|
|
||||||
},
|
|
||||||
{
|
|
||||||
deep: true,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -431,11 +492,13 @@ async function onReceiveMessage(message) {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
updateTargetRect();
|
void updateTargetRect();
|
||||||
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
shotEffectRequestGeneration += 1;
|
||||||
|
pendingShotEffect.value = null;
|
||||||
clearTipTimer();
|
clearTipTimer();
|
||||||
if (dirTimer.value) {
|
if (dirTimer.value) {
|
||||||
clearTimeout(dirTimer.value);
|
clearTimeout(dirTimer.value);
|
||||||
@@ -475,6 +538,7 @@ onBeforeUnmount(() => {
|
|||||||
:sectorCount="sectorCount"
|
:sectorCount="sectorCount"
|
||||||
:activeSector="activeSector"
|
:activeSector="activeSector"
|
||||||
:activeRing="activeRing"
|
:activeRing="activeRing"
|
||||||
|
:highlightRefreshToken="highlightRefreshToken"
|
||||||
:showSectorLabels="showSectorLabels"
|
:showSectorLabels="showSectorLabels"
|
||||||
/>
|
/>
|
||||||
<view v-if="angle !== null" class="arrow-dir" :style="arrowStyle">
|
<view v-if="angle !== null" class="arrow-dir" :style="arrowStyle">
|
||||||
@@ -520,41 +584,49 @@ onBeforeUnmount(() => {
|
|||||||
>{{ bluelatestOne.ringX ? "X" : bluelatestOne.ring || "未上靶"
|
>{{ bluelatestOne.ringX ? "X" : bluelatestOne.ring || "未上靶"
|
||||||
}}<text v-if="bluelatestOne.ring">环</text></view
|
}}<text v-if="bluelatestOne.ring">环</text></view
|
||||||
>
|
>
|
||||||
<block v-for="(bow, index) in scores" :key="index">
|
<block v-for="entry in visibleScoreEntries" :key="entry.index">
|
||||||
<image
|
<image
|
||||||
v-if="pMode && isSvip && bow.ring > 0 && !shouldHideLatestHit(index)"
|
v-if="
|
||||||
|
pMode &&
|
||||||
|
isSvip &&
|
||||||
|
entry.shot.ring > 0 &&
|
||||||
|
!shouldHideLatestHit(entry.index)
|
||||||
|
"
|
||||||
class="svip-hit-bg"
|
class="svip-hit-bg"
|
||||||
src="../../../static/vip/svip-xuan.png"
|
src="../../../static/vip/svip-xuan.png"
|
||||||
:style="getSvipHitBgStyle(bow)"
|
:style="getSvipHitBgStyle(entry.shot)"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
v-if="bow.ring > 0 && !shouldHideLatestHit(index)"
|
v-if="entry.shot.ring > 0 && !shouldHideLatestHit(entry.index)"
|
||||||
:class="`hit ${pMode ? 'b' : 's'}-point ${
|
:class="`hit ${pMode ? 'b' : 's'}-point ${
|
||||||
index === scores.length - 1 && latestOne ? 'pump-in' : ''
|
entry.index === scores.length - 1 && latestOne ? 'pump-in' : ''
|
||||||
}`"
|
}`"
|
||||||
:style="{
|
:style="{
|
||||||
...getHitStyle(bow),
|
...getHitStyle(entry.shot),
|
||||||
backgroundColor: mode === 'solo' ? '#00bf04' : '#FF0000',
|
backgroundColor: mode === 'solo' ? '#00bf04' : '#FF0000',
|
||||||
}"
|
}"
|
||||||
><text v-if="pMode">{{ index + 1 }}</text></view
|
><text v-if="pMode">{{ entry.index + 1 }}</text></view
|
||||||
>
|
>
|
||||||
</block>
|
</block>
|
||||||
<block v-for="(bow, index) in blueScores" :key="index">
|
<block v-for="entry in visibleBlueScoreEntries" :key="entry.index">
|
||||||
<view
|
<view
|
||||||
v-if="bow.ring > 0"
|
v-if="entry.shot.ring > 0"
|
||||||
:class="`hit ${pMode ? 'b' : 's'}-point ${
|
:class="`hit ${pMode ? 'b' : 's'}-point ${
|
||||||
index === blueScores.length - 1 && bluelatestOne ? 'pump-in' : ''
|
entry.index === blueScores.length - 1 && bluelatestOne
|
||||||
|
? 'pump-in'
|
||||||
|
: ''
|
||||||
}`"
|
}`"
|
||||||
:style="{
|
:style="{
|
||||||
...getHitStyle(bow),
|
...getHitStyle(entry.shot),
|
||||||
backgroundColor: '#1840FF',
|
backgroundColor: '#1840FF',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<text v-if="pMode">{{ index + 1 }}</text>
|
<text v-if="pMode">{{ entry.index + 1 }}</text>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<BowShotEffect
|
<BowShotEffect
|
||||||
|
v-if="!shotEffect || !shotEffect.viewportMode"
|
||||||
:shot="shotEffect && shotEffect.shot"
|
:shot="shotEffect && shotEffect.shot"
|
||||||
:playKey="shotEffect ? shotEffect.key : ''"
|
:playKey="shotEffect ? shotEffect.key : ''"
|
||||||
:targetRadius="safeTargetRadius"
|
:targetRadius="safeTargetRadius"
|
||||||
@@ -567,6 +639,20 @@ onBeforeUnmount(() => {
|
|||||||
@complete="completeShotEffect"
|
@complete="completeShotEffect"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
<BowShotEffect
|
||||||
|
v-if="shotEffect && shotEffect.viewportMode"
|
||||||
|
:shot="shotEffect.shot"
|
||||||
|
:playKey="shotEffect.key"
|
||||||
|
:targetRadius="safeTargetRadius"
|
||||||
|
:targetLeft="targetRect.left"
|
||||||
|
:targetTop="targetRect.top"
|
||||||
|
:targetWidth="targetRect.width"
|
||||||
|
:targetHeight="targetRect.height"
|
||||||
|
:hitOffsetPx="currentHitRadiusPx"
|
||||||
|
:viewportMode="true"
|
||||||
|
@impact="shakeTarget"
|
||||||
|
@complete="completeShotEffect"
|
||||||
|
/>
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
<PointSwitcher
|
<PointSwitcher
|
||||||
:onChange="(val) => (pMode = val)"
|
:onChange="(val) => (pMode = val)"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
import { ref, watch } from "vue";
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
rowCount: {
|
rowCount: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -27,8 +27,6 @@ const bgImages = [
|
|||||||
"../static/complete-light1.png",
|
"../static/complete-light1.png",
|
||||||
"../static/complete-light2.png",
|
"../static/complete-light2.png",
|
||||||
];
|
];
|
||||||
const bgIndex = ref(0);
|
|
||||||
|
|
||||||
const getDisplayText = (arrow) => {
|
const getDisplayText = (arrow) => {
|
||||||
if (!arrow) return "-";
|
if (!arrow) return "-";
|
||||||
if (arrow.ringX) return "X";
|
if (arrow.ringX) return "X";
|
||||||
@@ -47,35 +45,30 @@ watch(
|
|||||||
items.value = new Array(newValue).fill(9);
|
items.value = new Array(newValue).fill(9);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const timer = ref(null);
|
|
||||||
onMounted(() => {
|
|
||||||
timer.value = setInterval(() => {
|
|
||||||
bgIndex.value = bgIndex.value === 0 ? 1 : 0;
|
|
||||||
}, 200);
|
|
||||||
});
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
if (timer.value) {
|
|
||||||
clearInterval(timer.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<image
|
<template v-if="total > 0 && arrows.length === total && completeEffect">
|
||||||
v-if="total > 0 && arrows.length === total && completeEffect"
|
<image
|
||||||
:src="bgImages[bgIndex]"
|
v-for="(image, index) in bgImages"
|
||||||
class="complete-light"
|
:key="image"
|
||||||
:style="{
|
:src="image"
|
||||||
width: `calc(${(100 / (rowCount + 2)) * rowCount}vw + ${
|
:class="[
|
||||||
(100 / (total * 2)) * (rowCount * 2 + (total === 12 ? 8 : 24))
|
'complete-light',
|
||||||
}px)`,
|
index === 0 ? 'complete-light--first' : 'complete-light--second',
|
||||||
height: `calc(${(100 / (rowCount + 2)) * (total / rowCount)}vw + ${
|
]"
|
||||||
(100 / (total * 2)) *
|
:style="{
|
||||||
((total / rowCount) * 2 + (total === 12 ? 7 : 24))
|
width: `calc(${(100 / (rowCount + 2)) * rowCount}vw + ${
|
||||||
}px)`,
|
(100 / (total * 2)) * (rowCount * 2 + (total === 12 ? 8 : 24))
|
||||||
top: `${total === 12 ? -2 : -3}vw`,
|
}px)`,
|
||||||
}"
|
height: `calc(${(100 / (rowCount + 2)) * (total / rowCount)}vw + ${
|
||||||
/>
|
(100 / (total * 2)) *
|
||||||
|
((total / rowCount) * 2 + (total === 12 ? 7 : 24))
|
||||||
|
}px)`,
|
||||||
|
top: `${total === 12 ? -2 : -3}vw`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
<view
|
<view
|
||||||
v-for="(_, index) in items"
|
v-for="(_, index) in items"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -154,4 +147,30 @@ onBeforeUnmount(() => {
|
|||||||
.complete-light {
|
.complete-light {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
.complete-light--first {
|
||||||
|
animation: complete-light-first 400ms steps(1, end) infinite;
|
||||||
|
}
|
||||||
|
.complete-light--second {
|
||||||
|
animation: complete-light-second 400ms steps(1, end) infinite;
|
||||||
|
}
|
||||||
|
@keyframes complete-light-first {
|
||||||
|
0%,
|
||||||
|
49.9% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
50%,
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes complete-light-second {
|
||||||
|
0%,
|
||||||
|
49.9% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
50%,
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed } from "vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
arrows: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
total: {
|
|
||||||
type: Number,
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const getDisplayText = (arrow = {}) => {
|
|
||||||
if (!arrow) return "";
|
|
||||||
if (!arrow.ring) return "-";
|
|
||||||
return arrow.ringX ? "X" : String(arrow.ring);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isLowScore = (arrow = {}) => {
|
|
||||||
if (!arrow || arrow.ringX) return false;
|
|
||||||
return Number(arrow.ring) < 6;
|
|
||||||
};
|
|
||||||
|
|
||||||
const displayArrows = computed(() => {
|
|
||||||
const list = [...props.arrows];
|
|
||||||
// total 是达标箭数,不是实际射箭上限;训练中始终预留下一箭空框。
|
|
||||||
list.push(null);
|
|
||||||
return list;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view v-if="displayArrows.length" class="score-panel">
|
|
||||||
<view class="score-grid">
|
|
||||||
<view
|
|
||||||
v-for="(arrow, index) in displayArrows"
|
|
||||||
:key="index"
|
|
||||||
class="score-card"
|
|
||||||
>
|
|
||||||
<image class="score-card-bg" :src="isLowScore(arrow)?'https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/block-gray.png':'https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/block-gold.png'"></image>
|
|
||||||
<text
|
|
||||||
class="score-value"
|
|
||||||
:class="{ 'score-value--low': isLowScore(arrow) }"
|
|
||||||
>
|
|
||||||
{{ getDisplayText(arrow) }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.score-panel {
|
|
||||||
width: 100%;
|
|
||||||
padding: 30rpx 40rpx 0 40rpx;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.score-grid {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.score-card {
|
|
||||||
position: relative;
|
|
||||||
width: 100rpx;
|
|
||||||
height: 56rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-right: 14rpx;
|
|
||||||
margin-bottom: 14rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.score-card:nth-child(6n) {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.score-card-bg {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100rpx;
|
|
||||||
height: 56rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.score-value {
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
min-width: 28rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 34rpx;
|
|
||||||
line-height: 1;
|
|
||||||
font-weight: 700;
|
|
||||||
font-style: italic;
|
|
||||||
color: #f6e3b2;
|
|
||||||
text-shadow: 0 2rpx 0 rgba(36, 36, 48, 0.5);
|
|
||||||
margin-left: -10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.score-value--low {
|
|
||||||
color: #cfcfcf;
|
|
||||||
text-shadow: 0 2rpx 0 rgba(0, 0, 0, 0.5);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText, getInvalidShotAudioKey } from "@/util";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -241,7 +241,7 @@ async function onReceiveMessage(msg) {
|
|||||||
title: "距离不足,无效",
|
title: "距离不足,无效",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
audioManager.play("射击无效");
|
audioManager.play(getInvalidShotAudioKey(msg.shootData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,13 @@ onBeforeUnmount(() => {
|
|||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(msg) {
|
||||||
if (Array.isArray(msg)) return;
|
if (Array.isArray(msg)) return;
|
||||||
if (msg.type === MESSAGETYPESV2.TestDistance) {
|
if (msg.type === MESSAGETYPESV2.TestDistance) {
|
||||||
distance.value = Number((msg.shootData.distance / 100).toFixed(2));
|
const rawDistance = Number(msg.shootData?.distance);
|
||||||
if (distance.value >= 5) audioManager.play("距离合格");
|
distance.value = Number.isFinite(rawDistance)
|
||||||
|
? Number((rawDistance / 100).toFixed(2))
|
||||||
|
: 0;
|
||||||
|
if (rawDistance === 0) {
|
||||||
|
audioManager.play("未发现靶纸,请瞄准靶纸射箭");
|
||||||
|
} else if (distance.value >= 5) audioManager.play("距离合格");
|
||||||
else audioManager.play("距离不足");
|
else audioManager.play("距离不足");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +99,7 @@ onBeforeUnmount(() => {
|
|||||||
模拟射箭
|
模拟射箭
|
||||||
</button>
|
</button>
|
||||||
<view class="warnning-text">
|
<view class="warnning-text">
|
||||||
<view class="target-tip">当前靶子为<text class="text-yellow">{{ targetType }}cm</text>全环靶,请更换靶子</view>
|
<view class="target-tip">当前靶纸为<text class="text-yellow">{{ targetType }}cm</text>全环靶</view>
|
||||||
<block v-if="distance > 0">
|
<block v-if="distance > 0">
|
||||||
<text>当前距离<text class="text-yellow">{{ distance }}</text>米</text>
|
<text>当前距离<text class="text-yellow">{{ distance }}</text>米</text>
|
||||||
<text v-if="distance >= 5">已达到距离要求</text>
|
<text v-if="distance >= 5">已达到距离要求</text>
|
||||||
@@ -112,7 +117,7 @@ onBeforeUnmount(() => {
|
|||||||
<view v-if="isBattle" class="ready-timer">
|
<view v-if="isBattle" class="ready-timer">
|
||||||
<image src="../../../static/test-tip.png" mode="widthFix" />
|
<image src="../../../static/test-tip.png" mode="widthFix" />
|
||||||
<view v-if="count >= 0">
|
<view v-if="count >= 0">
|
||||||
<text>具体正式比赛还有</text>
|
<text>距离正式比赛还有</text>
|
||||||
<text>{{ count }}</text>
|
<text>{{ count }}</text>
|
||||||
<text>秒</text>
|
<text>秒</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -107,30 +107,27 @@ const createDifficultySummary = (item = {}) => {
|
|||||||
const timeLimit = toNumber(item.time_limit);
|
const timeLimit = toNumber(item.time_limit);
|
||||||
const hitReq = toNumber(item.hit_req);
|
const hitReq = toNumber(item.hit_req);
|
||||||
const totalReq = toNumber(item.total_req);
|
const totalReq = toNumber(item.total_req);
|
||||||
const blocks = toNumber(item.blocks);
|
|
||||||
const promoteCnt = toNumber(item.promote_cnt);
|
const promoteCnt = toNumber(item.promote_cnt);
|
||||||
const timeText = timeLimit > 0 ? `${timeLimit}秒内完成` : "不限时完成";
|
const shootingTimeText =
|
||||||
|
timeLimit > 0 ? `在${timeLimit}秒内进行射箭` : "不限时进行射箭";
|
||||||
|
const enduranceTimeText =
|
||||||
|
timeLimit > 0
|
||||||
|
? `在${timeLimit}秒内完成${arrows}箭`
|
||||||
|
: `不限时完成${arrows}箭`;
|
||||||
const promoteText = promoteCnt > 0 ? `完成${promoteCnt}次晋级` : "";
|
const promoteText = promoteCnt > 0 ? `完成${promoteCnt}次晋级` : "";
|
||||||
|
|
||||||
const summaryMap = {
|
const summaryMap = {
|
||||||
base: [
|
base: [
|
||||||
desc || (hitReq > 0 ? `每箭命中${hitReq}环以上` : "上靶即可"),
|
shootingTimeText,
|
||||||
[`${arrows}箭`, promoteText].filter(Boolean).join(" · "),
|
`需要有${arrows}箭命中${hitReq}环内`,
|
||||||
],
|
],
|
||||||
endurance: [
|
endurance: [
|
||||||
desc || `${timeText}${arrows}箭`,
|
enduranceTimeText,
|
||||||
[`累计${totalReq}环`, promoteText].filter(Boolean).join(" · "),
|
`且累计环数大于${totalReq}环`,
|
||||||
],
|
],
|
||||||
precision: [
|
precision: [
|
||||||
desc || `命中${blocks}个指定区域`,
|
shootingTimeText,
|
||||||
[
|
`需要有${arrows}箭命中高亮区域`,
|
||||||
`${arrows}箭`,
|
|
||||||
timeText,
|
|
||||||
getDifficultyModeText(item.mode),
|
|
||||||
promoteText,
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(" · "),
|
|
||||||
],
|
],
|
||||||
rhythm: [
|
rhythm: [
|
||||||
desc || `间隔${timeLimit}秒射击`,
|
desc || `间隔${timeLimit}秒射击`,
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ const createDefaultTrainingData = () => ({
|
|||||||
stats: {
|
stats: {
|
||||||
total_training_days: 0,
|
total_training_days: 0,
|
||||||
total_arrows: 0,
|
total_arrows: 0,
|
||||||
hit_rate: 0,
|
target_rate: 0,
|
||||||
endurance_shoot_speed: 0,
|
ten_ring_count: 0,
|
||||||
total_calories: 0,
|
total_calories: 0,
|
||||||
},
|
},
|
||||||
beat_percent: 0,
|
beat_percent: 0,
|
||||||
@@ -286,8 +286,8 @@ const loadPersonalTrainingData = async () => {
|
|||||||
stats: {
|
stats: {
|
||||||
total_training_days: result?.stats?.total_training_days ?? 0,
|
total_training_days: result?.stats?.total_training_days ?? 0,
|
||||||
total_arrows: result?.stats?.total_arrows ?? 0,
|
total_arrows: result?.stats?.total_arrows ?? 0,
|
||||||
hit_rate: result?.stats?.hit_rate ?? 0,
|
target_rate: result?.stats?.target_rate ?? 0,
|
||||||
endurance_shoot_speed: result?.stats?.endurance_shoot_speed ?? 0,
|
ten_ring_count: result?.stats?.ten_ring_count ?? 0,
|
||||||
total_calories: result?.stats?.total_calories ?? 0,
|
total_calories: result?.stats?.total_calories ?? 0,
|
||||||
},
|
},
|
||||||
beat_percent: result?.beat_percent ?? 0,
|
beat_percent: result?.beat_percent ?? 0,
|
||||||
@@ -431,26 +431,26 @@ onShow(async () => {
|
|||||||
<view class="stats-value-row">
|
<view class="stats-value-row">
|
||||||
<view class="stats-value-group">
|
<view class="stats-value-group">
|
||||||
<text class="stats-value">
|
<text class="stats-value">
|
||||||
{{ formatValue(trainingData.stats.hit_rate) }}
|
{{ formatValue(trainingData.stats.target_rate) }}
|
||||||
</text>
|
</text>
|
||||||
<text class="stats-unit">%</text>
|
<text class="stats-unit">%</text>
|
||||||
<view class="stats-value-decoration"></view>
|
<view class="stats-value-decoration"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="stats-label">命中率</text>
|
<text class="stats-label">上靶率</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="stats-item">
|
<view class="stats-item">
|
||||||
<view class="stats-value-row">
|
<view class="stats-value-row">
|
||||||
<view class="stats-value-group">
|
<view class="stats-value-group">
|
||||||
<text class="stats-value">
|
<text class="stats-value">
|
||||||
{{ formatValue(trainingData.stats.endurance_shoot_speed, 0) }}
|
{{ formatValue(trainingData.stats.ten_ring_count, 0) }}
|
||||||
</text>
|
</text>
|
||||||
<text class="stats-unit">支/分钟</text>
|
<text class="stats-unit">支</text>
|
||||||
<view class="stats-value-decoration"></view>
|
<view class="stats-value-decoration"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="stats-label">耐力射击</text>
|
<text class="stats-label">10环数</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="stats-item">
|
<view class="stats-item">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { onHide, onLoad, onShow, onUnload } from "@dcloudio/uni-app";
|
|||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import ShootProgress from "./components/ShootProgress.vue";
|
import ShootProgress from "./components/ShootProgress.vue";
|
||||||
import BowTarget from "./components/BowTarget.vue";
|
import BowTarget from "./components/BowTarget.vue";
|
||||||
import ScorePanel2 from "./components/ScorePanel2.vue";
|
import ScorePanel2 from "@/components/TrainingScorePanel.vue";
|
||||||
import ScoreResult from "./components/ScoreResult.vue";
|
import ScoreResult from "./components/ScoreResult.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import BowPower from "@/components/BowPower.vue";
|
import BowPower from "@/components/BowPower.vue";
|
||||||
@@ -48,6 +48,8 @@ const pageStage = ref(pageStages.LOADING);
|
|||||||
const scores = ref([]);
|
const scores = ref([]);
|
||||||
// 只在实时 ShootResult 新增一箭时递增,避免同步快照重播飞箭特效。
|
// 只在实时 ShootResult 新增一箭时递增,避免同步快照重播飞箭特效。
|
||||||
const shotEffectToken = ref(0);
|
const shotEffectToken = ref(0);
|
||||||
|
// 可见区域每次正式提交都递增,同一区域连续刷新也能触发动效。
|
||||||
|
const precisionTargetRefreshToken = ref(0);
|
||||||
const defaultTotal = 12;
|
const defaultTotal = 12;
|
||||||
const defaultTargetType = 1;
|
const defaultTargetType = 1;
|
||||||
const total = ref(defaultTotal);
|
const total = ref(defaultTotal);
|
||||||
@@ -97,6 +99,8 @@ const SHOT_EFFECT_WAIT_TIMEOUT_MS = 1200;
|
|||||||
const AUDIO_TIMEOUT_BASE = 3500;
|
const AUDIO_TIMEOUT_BASE = 3500;
|
||||||
const AUDIO_TIMEOUT_PER_KEY = 2600;
|
const AUDIO_TIMEOUT_PER_KEY = 2600;
|
||||||
const AUDIO_TIMEOUT_MAX = 12000;
|
const AUDIO_TIMEOUT_MAX = 12000;
|
||||||
|
const RUNTIME_DIAGNOSTIC_INTERVAL_MS = 60000;
|
||||||
|
let lastRuntimeDiagnosticAt = 0;
|
||||||
|
|
||||||
const env = computed(() => {
|
const env = computed(() => {
|
||||||
try {
|
try {
|
||||||
@@ -106,6 +110,19 @@ const env = computed(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const maybeLogRuntimeStats = () => {
|
||||||
|
if (env.value !== "develop" && env.value !== "trial") return;
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - lastRuntimeDiagnosticAt < RUNTIME_DIAGNOSTIC_INTERVAL_MS) return;
|
||||||
|
lastRuntimeDiagnosticAt = now;
|
||||||
|
console.log("[training-runtime]", {
|
||||||
|
scoreCount: scores.value.length,
|
||||||
|
renderedTargetShotCount: Math.min(scores.value.length, 12),
|
||||||
|
renderedScoreCardCount: Math.min(scores.value.length, 60) + 1,
|
||||||
|
...audioManager.getRuntimeStats(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const isDistanceStage = computed(() => pageStage.value === pageStages.DISTANCE);
|
const isDistanceStage = computed(() => pageStage.value === pageStages.DISTANCE);
|
||||||
const isShootingStage = computed(() => pageStage.value === pageStages.SHOOTING);
|
const isShootingStage = computed(() => pageStage.value === pageStages.SHOOTING);
|
||||||
const hasPractiseResult = computed(() => !!practiseResult.value?.details);
|
const hasPractiseResult = computed(() => !!practiseResult.value?.details);
|
||||||
@@ -253,17 +270,23 @@ const trainingCopy = computed(() => {
|
|||||||
practiceInfo.value.hitReq,
|
practiceInfo.value.hitReq,
|
||||||
trainingParams.value.hitReq
|
trainingParams.value.hitReq
|
||||||
);
|
);
|
||||||
const arrowsLeft = getPracticeNumber(
|
const targetArrows = getPositiveInteger(total.value);
|
||||||
practiceInfo.value.arrowsLeft,
|
const arrowsLeft = Math.min(
|
||||||
total.value
|
targetArrows,
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
getPracticeNumber(practiceInfo.value.arrowsLeft, targetArrows)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
const completedArrows = targetArrows - arrowsLeft;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: `每箭命中${hitReq}环之上`,
|
inline: true,
|
||||||
details: [
|
details: [
|
||||||
{ text: "剩余" },
|
{ text: "计时结束前需要有" },
|
||||||
{ text: arrowsLeft, highlight: true },
|
{ text: `(${completedArrows}/${targetArrows})`, highlight: true },
|
||||||
{ text: "箭达到条件" },
|
{ text: "箭命中" },
|
||||||
|
{ text: `${hitReq}环`, highlight: true },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -281,35 +304,33 @@ const trainingCopy = computed(() => {
|
|||||||
const currentRings = getPracticeNumber(practiceInfo.value.currentRings);
|
const currentRings = getPracticeNumber(practiceInfo.value.currentRings);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: `完成${targetArrows}箭并累计${targetRings}环`,
|
inline: true,
|
||||||
details: [
|
details: [
|
||||||
{ text: "已完成" },
|
{ text: "计时结束前完成" },
|
||||||
{ text: currentArrows, highlight: true },
|
{ text: `(${currentArrows}/${targetArrows})`, highlight: true },
|
||||||
{ text: "箭,累计" },
|
{ text: "箭且累计命中" },
|
||||||
{ text: currentRings, highlight: true },
|
{ text: `(${currentRings}/${targetRings})`, highlight: true },
|
||||||
{ text: "环" },
|
{ text: "环" },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trainingType.value === "precision") {
|
if (trainingType.value === "precision") {
|
||||||
const block = precisionRandomBlock.value;
|
const targetArrows = getPositiveInteger(total.value);
|
||||||
const ring = precisionRandomRingArea.value;
|
const arrowsLeft = Math.min(
|
||||||
const arrowsLeft = getPracticeNumber(
|
targetArrows,
|
||||||
practiceInfo.value.arrowsLeft,
|
Math.max(
|
||||||
total.value
|
0,
|
||||||
|
getPracticeNumber(practiceInfo.value.arrowsLeft, targetArrows)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
const title = block
|
const completedArrows = targetArrows - arrowsLeft;
|
||||||
? ring
|
|
||||||
? `请命中区域${block}的${ring}环`
|
|
||||||
: `请命中区域${block}`
|
|
||||||
: "等待目标区域";
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
inline: true,
|
||||||
details: [
|
details: [
|
||||||
{ text: "剩余" },
|
{ text: "射箭命中高亮区域需完成" },
|
||||||
{ text: arrowsLeft, highlight: true },
|
{ text: `(${completedArrows}/${targetArrows})`, highlight: true },
|
||||||
{ text: "箭" },
|
{ text: "箭" },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -563,7 +584,10 @@ const commitPrecisionTargetAfterPresentation = async ({
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
visiblePrecisionTarget.value = target;
|
applyVisiblePrecisionTarget(target);
|
||||||
|
if (precisionRandomBlock.value > 0) {
|
||||||
|
precisionTargetRefreshToken.value += 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const createPracticeEndSnapshot = (message = {}) => {
|
const createPracticeEndSnapshot = (message = {}) => {
|
||||||
@@ -1102,6 +1126,7 @@ async function onReceiveMessage(msg) {
|
|||||||
scores.value = msg.details;
|
scores.value = msg.details;
|
||||||
hasNewShot = msg.details.length === previousScoreLength + 1;
|
hasNewShot = msg.details.length === previousScoreLength + 1;
|
||||||
latestShot = hasNewShot ? msg.details[msg.details.length - 1] : null;
|
latestShot = hasNewShot ? msg.details[msg.details.length - 1] : null;
|
||||||
|
maybeLogRuntimeStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trainingType.value === "precision") {
|
if (trainingType.value === "precision") {
|
||||||
@@ -1329,7 +1354,8 @@ onBeforeUnmount(() => {
|
|||||||
:sectorCount="precisionBlocks"
|
:sectorCount="precisionBlocks"
|
||||||
:activeSector="precisionRandomBlock"
|
:activeSector="precisionRandomBlock"
|
||||||
:activeRing="precisionRandomRingArea"
|
:activeRing="precisionRandomRingArea"
|
||||||
:showSectorLabels="precisionBlocks > 0"
|
:highlightRefreshToken="precisionTargetRefreshToken"
|
||||||
|
stable-shot-effect
|
||||||
@shot-effect-complete="onShotEffectComplete"
|
@shot-effect-complete="onShotEffectComplete"
|
||||||
/>
|
/>
|
||||||
<!-- <view v-if="env !== 'release'" class="highlight-test-actions">
|
<!-- <view v-if="env !== 'release'" class="highlight-test-actions">
|
||||||
@@ -1348,7 +1374,7 @@ onBeforeUnmount(() => {
|
|||||||
重置高亮
|
重置高亮
|
||||||
</button>
|
</button>
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="sound-text-box">
|
<view class="sound-row">
|
||||||
<button class="sound-btn" hover-class="none" @click="updateSound">
|
<button class="sound-btn" hover-class="none" @click="updateSound">
|
||||||
<image
|
<image
|
||||||
class="sound-icon"
|
class="sound-icon"
|
||||||
@@ -1356,6 +1382,8 @@ onBeforeUnmount(() => {
|
|||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
</view>
|
||||||
|
<view class="sound-text-box">
|
||||||
<view class="bat-text-big-box">
|
<view class="bat-text-big-box">
|
||||||
<image
|
<image
|
||||||
class="dao-icon"
|
class="dao-icon"
|
||||||
@@ -1365,14 +1393,23 @@ onBeforeUnmount(() => {
|
|||||||
<view v-if="trainingCopy" class="bat-text-box">
|
<view v-if="trainingCopy" class="bat-text-box">
|
||||||
<view class="bat-text-small-box">
|
<view class="bat-text-small-box">
|
||||||
<view class="text-round-box">
|
<view class="text-round-box">
|
||||||
<view class="text1">{{ trainingCopy.title }}</view>
|
<view v-if="trainingCopy.inline" class="training-copy-inline">
|
||||||
<view class="text2">
|
|
||||||
<text
|
<text
|
||||||
v-for="(part, index) in trainingCopy.details"
|
v-for="(part, index) in trainingCopy.details"
|
||||||
:key="index"
|
:key="index"
|
||||||
:class="{ 'text2-yellow': part.highlight }"
|
:class="{ 'text2-yellow': part.highlight }"
|
||||||
>{{ part.text }}</text>
|
>{{ part.text }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
<view class="text1">{{ trainingCopy.title }}</view>
|
||||||
|
<view class="text2">
|
||||||
|
<text
|
||||||
|
v-for="(part, index) in trainingCopy.details"
|
||||||
|
:key="index"
|
||||||
|
:class="{ 'text2-yellow': part.highlight }"
|
||||||
|
>{{ part.text }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -1385,7 +1422,11 @@ onBeforeUnmount(() => {
|
|||||||
:enhanced="true"
|
:enhanced="true"
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
>
|
>
|
||||||
<ScorePanel2 :arrows="scores" :total="total" />
|
<ScorePanel2
|
||||||
|
:arrows="scores"
|
||||||
|
:total="total"
|
||||||
|
:trainingType="trainingType"
|
||||||
|
/>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
@@ -1493,6 +1534,12 @@ onBeforeUnmount(() => {
|
|||||||
margin-left: 16rpx;
|
margin-left: 16rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sound-row {
|
||||||
|
height: 70rpx;
|
||||||
|
padding: 0 56rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
.sound-text-box{
|
.sound-text-box{
|
||||||
height: 125rpx;
|
height: 125rpx;
|
||||||
padding: 0 56rpx;
|
padding: 0 56rpx;
|
||||||
@@ -1502,6 +1549,9 @@ onBeforeUnmount(() => {
|
|||||||
.sound-btn {
|
.sound-btn {
|
||||||
width: 76rpx;
|
width: 76rpx;
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1514,7 +1564,7 @@ onBeforeUnmount(() => {
|
|||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
}
|
}
|
||||||
.bat-text-big-box{
|
.bat-text-big-box{
|
||||||
flex: 1;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.dao-icon{
|
.dao-icon{
|
||||||
@@ -1529,11 +1579,13 @@ onBeforeUnmount(() => {
|
|||||||
}
|
}
|
||||||
.bat-text-box{
|
.bat-text-box{
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
.bat-text-small-box{
|
.bat-text-small-box{
|
||||||
background: rgba(0, 0, 0, 0.5);
|
background: rgba(0, 0, 0, 0.5);
|
||||||
width: auto;
|
width: 100%;
|
||||||
min-width: 100rpx;
|
min-width: 100rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
border-radius: 16rpx 60rpx 60rpx 16rpx;
|
border-radius: 16rpx 60rpx 60rpx 16rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -1544,6 +1596,15 @@ onBeforeUnmount(() => {
|
|||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
color: #E7BA80;
|
color: #E7BA80;
|
||||||
}
|
}
|
||||||
|
.training-copy-inline {
|
||||||
|
width: 100%;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 40rpx;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
.text1{
|
.text1{
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|||||||
+45
-12
@@ -54,6 +54,11 @@ const toAudioTestPage = () => {
|
|||||||
url: "/pages/audio-test",
|
url: "/pages/audio-test",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const toUnbindDevicePage = () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/device/unbind-device",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const showLogout = ref(false);
|
const showLogout = ref(false);
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
@@ -77,7 +82,7 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
<template>
|
<template>
|
||||||
<Container title="用户信息">
|
<Container title="用户信息">
|
||||||
<view :style="{ width: '100%', height: '100%' }">
|
<view :style="{ width: '100%', height: '100%' }">
|
||||||
<UserHeader />
|
<UserHeader fullNickname />
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
@@ -104,7 +109,20 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
<text v-else :style="{ color: '#CC311F' }">未完成</text>
|
<text v-else :style="{ color: '#CC311F' }">未完成</text>
|
||||||
</UserItem>
|
</UserItem>
|
||||||
<UserItem title="会员" :onClick="toBeVipPage">
|
<UserItem title="会员" :onClick="toBeVipPage">
|
||||||
已赠送6个月会员
|
<view
|
||||||
|
v-if="user.sVip === true"
|
||||||
|
class="member-nickname member-nickname--svip"
|
||||||
|
>
|
||||||
|
<text class="member-nickname__text">已开通SVIP</text>
|
||||||
|
<text class="member-nickname__shine">已开通SVIP</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-else-if="user.vip === true"
|
||||||
|
class="member-nickname member-nickname--vip"
|
||||||
|
>
|
||||||
|
<text class="member-nickname__text">已开通VIP</text>
|
||||||
|
</view>
|
||||||
|
<text v-else>未开通</text>
|
||||||
</UserItem>
|
</UserItem>
|
||||||
<UserItem title="等级介绍" :onClick="toGradeIntroPage">
|
<UserItem title="等级介绍" :onClick="toGradeIntroPage">
|
||||||
<text :style="{ color: '#4C76FF' }">Lv{{ user.lvl }}</text>
|
<text :style="{ color: '#4C76FF' }">Lv{{ user.lvl }}</text>
|
||||||
@@ -115,7 +133,7 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
}"
|
}"
|
||||||
>{{ user.lvlPoints }}</text
|
>{{ user.lvlPoints }}</text
|
||||||
>
|
>
|
||||||
<text>点</text>
|
<text>经验</text>
|
||||||
</UserItem>
|
</UserItem>
|
||||||
<UserItem
|
<UserItem
|
||||||
title="段位介绍"
|
title="段位介绍"
|
||||||
@@ -124,15 +142,16 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
}"
|
}"
|
||||||
:onClick="toRankIntroPage"
|
:onClick="toRankIntroPage"
|
||||||
>
|
>
|
||||||
<text :style="{ color: '#8E53EA' }">{{ user.lvlName }}</text>
|
<view v-if="user.rankIcon || user.rankName" class="rank-info">
|
||||||
<text
|
<image
|
||||||
:style="{
|
v-if="user.rankIcon"
|
||||||
color: '#FF7900',
|
class="rank-info__frame"
|
||||||
marginLeft: '5px',
|
:src="user.rankIcon"
|
||||||
}"
|
mode="aspectFit"
|
||||||
>{{ user.scores }}</text
|
/>
|
||||||
>
|
<text>{{ user.rankName || "暂无段位" }}</text>
|
||||||
<text>点</text>
|
</view>
|
||||||
|
<text v-else>暂无段位</text>
|
||||||
</UserItem>
|
</UserItem>
|
||||||
<view class="my-grow" @click="toMyGrowthPage">
|
<view class="my-grow" @click="toMyGrowthPage">
|
||||||
<image src="https://static.shelingxingqiu.com/shootmini/static/my-grow.png" mode="widthFix" />
|
<image src="https://static.shelingxingqiu.com/shootmini/static/my-grow.png" mode="widthFix" />
|
||||||
@@ -147,6 +166,11 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
title="版本信息(仅用于测试)"
|
title="版本信息(仅用于测试)"
|
||||||
v-if="showLogout"
|
v-if="showLogout"
|
||||||
>{{ buildVersion }}</UserItem>
|
>{{ buildVersion }}</UserItem>
|
||||||
|
<UserItem
|
||||||
|
title="解绑设备(仅用于测试)"
|
||||||
|
:onClick="toUnbindDevicePage"
|
||||||
|
v-if="showLogout"
|
||||||
|
/>
|
||||||
<UserItem
|
<UserItem
|
||||||
title="退出登录(仅用于测试)"
|
title="退出登录(仅用于测试)"
|
||||||
:onClick="logout"
|
:onClick="logout"
|
||||||
@@ -170,4 +194,13 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
.my-grow > image {
|
.my-grow > image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.rank-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.rank-info__frame {
|
||||||
|
width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
margin-right: 8rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 27 KiB |
+17
-11
@@ -38,17 +38,15 @@ const getDefaultDailyCount = () => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getLvlName = (rankLvl, rankList = []) => {
|
const getLvlName = (rankLvl, rankList = []) => {
|
||||||
if (!rankList) return;
|
if (!Array.isArray(rankList) || rankLvl === undefined || rankLvl === null) {
|
||||||
let lvlName = "";
|
return "";
|
||||||
rankList.some((r, index) => {
|
}
|
||||||
lvlName = rankList[index].name;
|
|
||||||
if (r.rank_id === rankLvl) {
|
// 仅返回真正匹配的段位,避免未加载时误取列表最后一项。
|
||||||
lvlName = rankList[index].name;
|
const rankInfo = rankList.find(
|
||||||
return true;
|
(item) => String(item.rank_id) === String(rankLvl)
|
||||||
}
|
);
|
||||||
return false;
|
return rankInfo?.name || "";
|
||||||
});
|
|
||||||
return lvlName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLvlNameByScore = (score, rankList = []) => {
|
const getLvlNameByScore = (score, rankList = []) => {
|
||||||
@@ -111,6 +109,7 @@ export default defineStore("store", {
|
|||||||
tips: "", // 当前提示文案(用于 HeaderProgress 恢复状态,替代 uni.$emit 避免时序问题)
|
tips: "", // 当前提示文案(用于 HeaderProgress 恢复状态,替代 uni.$emit 避免时序问题)
|
||||||
},
|
},
|
||||||
dailyCount: getDefaultDailyCount(),
|
dailyCount: getDefaultDailyCount(),
|
||||||
|
deviceChargingDialogVisible: false,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
@@ -189,6 +188,12 @@ export default defineStore("store", {
|
|||||||
...(data || {}),
|
...(data || {}),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
showDeviceChargingDialog() {
|
||||||
|
this.deviceChargingDialogVisible = true;
|
||||||
|
},
|
||||||
|
hideDeviceChargingDialog() {
|
||||||
|
this.deviceChargingDialogVisible = false;
|
||||||
|
},
|
||||||
clearSessionState() {
|
clearSessionState() {
|
||||||
this.$patch({
|
this.$patch({
|
||||||
user: getDefaultUser(),
|
user: getDefaultUser(),
|
||||||
@@ -196,6 +201,7 @@ export default defineStore("store", {
|
|||||||
online: false,
|
online: false,
|
||||||
game: getDefaultGame(),
|
game: getDefaultGame(),
|
||||||
dailyCount: getDefaultDailyCount(),
|
dailyCount: getDefaultDailyCount(),
|
||||||
|
deviceChargingDialogVisible: false,
|
||||||
});
|
});
|
||||||
uni.removeStorageSync(PERSISTED_STORE_KEY);
|
uni.removeStorageSync(PERSISTED_STORE_KEY);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
+12
@@ -329,6 +329,18 @@ export const getDirectionText = (angle = 0) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 正式射箭阶段的距离单位为厘米,按距离异常类型选择对应语音。
|
||||||
|
export const getInvalidShotAudioKey = (shootData) => {
|
||||||
|
if (!shootData || typeof shootData !== "object") return "射击无效";
|
||||||
|
// protobuf 会省略值为 0 的标量字段;消息体存在且距离缺失时按 0 处理。
|
||||||
|
const rawDistance = Number(shootData.distance ?? shootData.dst ?? 0);
|
||||||
|
if (!Number.isFinite(rawDistance)) return "射击无效";
|
||||||
|
if (rawDistance < 0) return "射箭无效,靶纸错误";
|
||||||
|
if (rawDistance === 0) return "射箭无效,未识别到靶纸";
|
||||||
|
if (rawDistance / 100 < 5) return "射箭无效,距离不足";
|
||||||
|
return "射击无效";
|
||||||
|
};
|
||||||
|
|
||||||
export const wxLogin = () => {
|
export const wxLogin = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.login({
|
uni.login({
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -7,8 +7,8 @@ const { Reader, Writer } = protobuf;
|
|||||||
// 所以这里使用 minimal Reader/Writer 做静态字段解码和客户端消息编码。
|
// 所以这里使用 minimal Reader/Writer 做静态字段解码和客户端消息编码。
|
||||||
// <match-schema-generated>
|
// <match-schema-generated>
|
||||||
// 此区块由 scripts/generate-match-schema.mjs 自动生成,请勿手动修改。
|
// 此区块由 scripts/generate-match-schema.mjs 自动生成,请勿手动修改。
|
||||||
// 来源:src/utils/match.min.js(sha256: b4f272aad40fb951)
|
// 来源:src/utils/match.min.js(sha256: 150812589c2e6f7a)
|
||||||
// 协议命名空间:rpc;消息数:12;字段数:137
|
// 协议命名空间:rpc;消息数:12;字段数:151
|
||||||
|
|
||||||
export const ServerMessageType = {
|
export const ServerMessageType = {
|
||||||
SERVER_MSG_UNKNOWN: 0,
|
SERVER_MSG_UNKNOWN: 0,
|
||||||
@@ -50,6 +50,7 @@ const SCHEMAS = {
|
|||||||
7: { name: "angle", kind: "float" },
|
7: { name: "angle", kind: "float" },
|
||||||
8: { name: "distance", kind: "float" },
|
8: { name: "distance", kind: "float" },
|
||||||
9: { name: "three_consecutive_10_rings", kind: "bool" },
|
9: { name: "three_consecutive_10_rings", kind: "bool" },
|
||||||
|
10: { name: "ok", kind: "bool" },
|
||||||
},
|
},
|
||||||
MatchShootList: {
|
MatchShootList: {
|
||||||
1: { name: "items", kind: "message", type: "MatchShoot", repeated: true },
|
1: { name: "items", kind: "message", type: "MatchShoot", repeated: true },
|
||||||
@@ -101,6 +102,9 @@ const SCHEMAS = {
|
|||||||
13: { name: "s_vip", kind: "bool" },
|
13: { name: "s_vip", kind: "bool" },
|
||||||
14: { name: "vip", kind: "bool" },
|
14: { name: "vip", kind: "bool" },
|
||||||
15: { name: "player_match_result", kind: "message", type: "PlayerMatchResult" },
|
15: { name: "player_match_result", kind: "message", type: "PlayerMatchResult" },
|
||||||
|
16: { name: "rank_lvl", kind: "int32" },
|
||||||
|
17: { name: "rank_name", kind: "string" },
|
||||||
|
18: { name: "rank_icon", kind: "string" },
|
||||||
},
|
},
|
||||||
TeamInfo: {
|
TeamInfo: {
|
||||||
1: { name: "players", kind: "message", type: "PlayerFull", repeated: true },
|
1: { name: "players", kind: "message", type: "PlayerFull", repeated: true },
|
||||||
@@ -180,6 +184,16 @@ const SCHEMAS = {
|
|||||||
41: { name: "level", kind: "int32" },
|
41: { name: "level", kind: "int32" },
|
||||||
42: { name: "upgrade_exp", kind: "int32" },
|
42: { name: "upgrade_exp", kind: "int32" },
|
||||||
43: { name: "calories", kind: "double" },
|
43: { name: "calories", kind: "double" },
|
||||||
|
44: { name: "score_slot", kind: "int32" },
|
||||||
|
45: { name: "current_energy", kind: "int32" },
|
||||||
|
46: { name: "energy_cost_per_sec", kind: "int32" },
|
||||||
|
47: { name: "energy_per_hit", kind: "int32" },
|
||||||
|
48: { name: "energy_req_percent", kind: "int32" },
|
||||||
|
49: { name: "delta_current_energy", kind: "int32" },
|
||||||
|
50: { name: "round_time", kind: "int32" },
|
||||||
|
51: { name: "shoot_window_start", kind: "int64" },
|
||||||
|
52: { name: "in_shoot_window", kind: "bool" },
|
||||||
|
53: { name: "shoot_time", kind: "int32" },
|
||||||
},
|
},
|
||||||
MatchInfo: {
|
MatchInfo: {
|
||||||
1: { name: "match_id", kind: "string" },
|
1: { name: "match_id", kind: "string" },
|
||||||
|
|||||||
+20
-11
@@ -8,6 +8,13 @@ let manualClose = false;
|
|||||||
let checkingSession = false;
|
let checkingSession = false;
|
||||||
let kickedOut = false;
|
let kickedOut = false;
|
||||||
let isConnecting = false;
|
let isConnecting = false;
|
||||||
|
const ENABLE_REALTIME_MESSAGE_LOG = (() => {
|
||||||
|
try {
|
||||||
|
return uni.getAccountInfoSync().miniProgram.envVersion !== "release";
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
function createWebSocket(token, onMessage) {
|
function createWebSocket(token, onMessage) {
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
@@ -24,7 +31,7 @@ function createWebSocket(token, onMessage) {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
// url = "ws://192.168.1.2:8000/socket";
|
// url = "ws://192.168.1.30:8000/socket";
|
||||||
url = "wss://apitest.shelingxingqiu.com/socket";
|
url = "wss://apitest.shelingxingqiu.com/socket";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
@@ -73,22 +80,22 @@ function createWebSocket(token, onMessage) {
|
|||||||
const { data, event } = JSON.parse(res.data);
|
const { data, event } = JSON.parse(res.data);
|
||||||
if (event === "pong") return;
|
if (event === "pong") return;
|
||||||
if (data.type) {
|
if (data.type) {
|
||||||
console.log(
|
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||||
"收到 WebSocket 消息",
|
console.log("收到 WebSocket 消息", getMessageTypeName(data.type));
|
||||||
getMessageTypeName(data.type),
|
}
|
||||||
data.data
|
|
||||||
);
|
|
||||||
if (onMessage) onMessage({ ...(data.data || {}), type: data.type });
|
if (onMessage) onMessage({ ...(data.data || {}), type: data.type });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (onMessage && data.updates) onMessage(data.updates);
|
if (onMessage && data.updates) onMessage(data.updates);
|
||||||
const msg = data.updates[0];
|
const msg = data.updates[0];
|
||||||
if (msg) {
|
if (msg) {
|
||||||
console.log(
|
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||||
"收到 WebSocket 更新",
|
console.log(
|
||||||
getMessageTypeName(msg.constructor),
|
"收到 WebSocket 更新",
|
||||||
msg
|
getMessageTypeName(msg.constructor),
|
||||||
);
|
{ updateCount: data.updates.length }
|
||||||
|
);
|
||||||
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.RankUpdate) {
|
if (msg.constructor === MESSAGETYPES.RankUpdate) {
|
||||||
uni.setStorageSync("latestRank", msg.lvl);
|
uni.setStorageSync("latestRank", msg.lvl);
|
||||||
} else if (msg.constructor === MESSAGETYPES.LvlUpdate) {
|
} else if (msg.constructor === MESSAGETYPES.LvlUpdate) {
|
||||||
@@ -97,6 +104,8 @@ function createWebSocket(token, onMessage) {
|
|||||||
uni.$emit("update-online");
|
uni.$emit("update-online");
|
||||||
} else if (msg.constructor === MESSAGETYPES.DeviceOffline) {
|
} else if (msg.constructor === MESSAGETYPES.DeviceOffline) {
|
||||||
uni.$emit("update-online");
|
uni.$emit("update-online");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.DeviceCharging) {
|
||||||
|
uni.$emit("device-charging");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user