Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88febb92e5 | ||
|
|
c8533de5cf | ||
|
|
74bfd7a327 | ||
|
|
bbfa35e871 | ||
|
|
469487ba73 | ||
|
|
b9bbaba77f | ||
|
|
11eeb98b74 | ||
|
|
96b64e4187 | ||
|
|
45bc324f70 | ||
|
|
2eba5f87d7 | ||
|
|
9a06dcf942 | ||
|
|
35e0ee3ca0 | ||
|
|
59fa317c5a | ||
|
|
09756ae165 | ||
|
|
b89c003313 | ||
|
|
9dda58b19c | ||
|
|
962596e510 | ||
|
|
8a2fbb0780 | ||
|
|
0c0a00f742 | ||
|
|
66fc7fa8eb | ||
|
|
6363dda204 | ||
|
|
9f4fbbe4c9 | ||
|
|
45957d04b1 | ||
|
|
42cfb5c3d8 | ||
|
|
844f72489e | ||
|
|
d2571854bc | ||
|
|
bb224c9f29 | ||
|
|
82c360f1b1 | ||
|
|
63f3cada0f | ||
|
|
75cfcd66ee | ||
|
|
7955b37ec5 | ||
|
|
9e6ad4cf50 | ||
|
|
6c55d32f90 | ||
|
|
d60c32506f | ||
|
|
63fb4ae85a | ||
|
|
2628a17b3f | ||
|
|
e7f073ed7c | ||
|
|
d662db9465 | ||
|
|
23655102d3 | ||
|
|
fbb2076a77 | ||
|
|
8c96a4cb73 | ||
|
|
6a78093d31 | ||
|
|
4835993639 | ||
|
|
3c45ef78ac | ||
|
|
ab70c8c78e | ||
|
|
fac2576b65 | ||
|
|
360da2a1d7 | ||
|
|
e96537b21b | ||
|
|
8c834d299b | ||
|
|
b386990475 | ||
|
|
3ab1ad59bd | ||
|
|
cfdb169329 | ||
|
|
4245a3f947 | ||
|
|
d6f914ca7e | ||
|
|
f34800798d |
@@ -21,11 +21,14 @@
|
|||||||
import audioManager from "./audioManager";
|
import audioManager from "./audioManager";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const {
|
const {
|
||||||
user
|
user,
|
||||||
|
device,
|
||||||
|
online
|
||||||
} = storeToRefs(store);
|
} = storeToRefs(store);
|
||||||
const {
|
const {
|
||||||
updateUser,
|
updateUser,
|
||||||
updateOnline,
|
updateOnline,
|
||||||
|
showDeviceChargingDialog,
|
||||||
clearSessionState,
|
clearSessionState,
|
||||||
clearDevice
|
clearDevice
|
||||||
} = store;
|
} = store;
|
||||||
@@ -68,7 +71,11 @@
|
|||||||
|
|
||||||
async function emitUpdateOnline() {
|
async function emitUpdateOnline() {
|
||||||
const data = await getDeviceBatteryAPI();
|
const data = await getDeviceBatteryAPI();
|
||||||
updateOnline(data.online);
|
const wasOnline = Boolean(online.value);
|
||||||
|
const nextOnline = Boolean(data.online);
|
||||||
|
updateOnline(nextOnline);
|
||||||
|
if (!device.value.deviceId || wasOnline === nextOnline) return;
|
||||||
|
audioManager.play(nextOnline ? "设备已连接" : "设备连接已断开");
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDeviceBindInvalid() {
|
function onDeviceBindInvalid() {
|
||||||
@@ -76,6 +83,10 @@
|
|||||||
uni.setStorageSync("calibration", false);
|
uni.setStorageSync("calibration", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDeviceCharging() {
|
||||||
|
showDeviceChargingDialog();
|
||||||
|
}
|
||||||
|
|
||||||
function onDeviceShoot() {
|
function onDeviceShoot() {
|
||||||
// audioManager.play("射箭声音")
|
// audioManager.play("射箭声音")
|
||||||
}
|
}
|
||||||
@@ -113,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);
|
||||||
}
|
}
|
||||||
@@ -138,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,8 +26,9 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ADDONS_BASE_URL = BASE_URL.replace(/\/api\/shoot$/, "/api/shoot");
|
const ADDONS_BASE_URL = BASE_URL.replace(/\/api\/shoot$/, "/api/shoot");
|
||||||
// 统一处理业务接口请求,包含登录态、业务错误和 WiFi 连接空响应兼容。
|
const API_ROOT_URL = BASE_URL.replace(/\/api\/shoot$/, "");
|
||||||
function request(method, url, data = {}, baseUrl = BASE_URL) {
|
// 统一处理业务接口请求,包含登录态、业务错误和特定接口空响应兼容。
|
||||||
|
function request(method, url, data = {}, baseUrl = BASE_URL, successCodes = [0]) {
|
||||||
const token = uni.getStorageSync(
|
const token = uni.getStorageSync(
|
||||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||||
);
|
);
|
||||||
@@ -41,13 +42,17 @@ 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;
|
||||||
}
|
}
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
const {code, data, message} = res.data;
|
const {code, data, message} = res.data;
|
||||||
if (code === 0) resolve(data);
|
if (successCodes.includes(code)) resolve(data);
|
||||||
else if (message) {
|
else if (message) {
|
||||||
const error = {code, data, message};
|
const error = {code, data, message};
|
||||||
if (message.indexOf("登录身份已失效") !== -1) {
|
if (message.indexOf("登录身份已失效") !== -1) {
|
||||||
@@ -186,8 +191,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 +247,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 +271,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 +312,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 +352,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) => {
|
||||||
@@ -342,9 +376,11 @@ export const readyGameAPI = (battleId) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const simulShootAPI = (device_id, x, y) => {
|
export const simulShootAPI = (device_id, x, y, targetType = 40) => {
|
||||||
const data = {
|
const data = {
|
||||||
device_id,
|
device_id,
|
||||||
|
// 模拟射箭仅支持 20cm、40cm 靶纸,未传或传入无效值时默认使用 40cm。
|
||||||
|
targetType: Number(targetType) === 20 ? 20 : 40,
|
||||||
};
|
};
|
||||||
if (x !== undefined && y !== undefined) {
|
if (x !== undefined && y !== undefined) {
|
||||||
data.x = x;
|
data.x = x;
|
||||||
@@ -502,6 +538,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");
|
||||||
};
|
};
|
||||||
@@ -646,3 +701,76 @@ export const getMyTenRingRank = (seasonId) => {
|
|||||||
if (seasonId !== undefined && seasonId !== null) data.seasonId = seasonId;
|
if (seasonId !== undefined && seasonId !== null) data.seasonId = seasonId;
|
||||||
return request("GET", "/index/myTenRingRank", data);
|
return request("GET", "/index/myTenRingRank", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取当前用户的金币统计,可按门店查询。
|
||||||
|
export const getMyGoldAPI = (storeId) => {
|
||||||
|
const data = {};
|
||||||
|
if (storeId !== undefined && storeId !== null) data.storeId = storeId;
|
||||||
|
return request("GET", "/index/gold/my", data);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 分页获取当前用户的金币流水,type:1=获得,2=兑换。
|
||||||
|
export const getGoldLogAPI = ({page = 1, pageSize = 20, type, storeId} = {}) => {
|
||||||
|
const data = {page, pageSize};
|
||||||
|
if (type !== undefined && type !== null) data.type = type;
|
||||||
|
if (storeId !== undefined && storeId !== null) data.storeId = storeId;
|
||||||
|
return request("GET", "/index/gold/log", data);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 前台礼品接口位于站点根路径,并使用 code=200 表示成功。
|
||||||
|
export const getGiftListAPI = ({
|
||||||
|
page = 1,
|
||||||
|
pageSize = 20,
|
||||||
|
sort = "coin_desc",
|
||||||
|
storeId,
|
||||||
|
} = {}) => {
|
||||||
|
const data = {page, page_size: pageSize, sort};
|
||||||
|
if (storeId !== undefined && storeId !== null && storeId !== "") {
|
||||||
|
data.store_id = storeId;
|
||||||
|
}
|
||||||
|
return request(
|
||||||
|
"GET",
|
||||||
|
"/gin/api/v1/gift/list",
|
||||||
|
data,
|
||||||
|
API_ROOT_URL,
|
||||||
|
[0, 200]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getGiftDetailAPI = (id) => {
|
||||||
|
return request(
|
||||||
|
"GET",
|
||||||
|
`/gin/api/v1/gift/${id}`,
|
||||||
|
{},
|
||||||
|
API_ROOT_URL,
|
||||||
|
[0, 200]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 根据用户定位分页获取附近门店。
|
||||||
|
export const getNearbyStoresAPI = ({
|
||||||
|
longitude,
|
||||||
|
latitude,
|
||||||
|
radius = 65535,
|
||||||
|
page = 1,
|
||||||
|
pageSize = 20,
|
||||||
|
} = {}) => {
|
||||||
|
return request("GET", "/store/nearby", {
|
||||||
|
longitude,
|
||||||
|
latitude,
|
||||||
|
radius,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 分页获取指定门店的公开金币规则。
|
||||||
|
export const getStoreGoldRuleListAPI = ({storeId, page = 1, pageSize = 20} = {}) => {
|
||||||
|
return request(
|
||||||
|
"GET",
|
||||||
|
`/gin/api/v1/super-admin/gold-rule/store/${storeId}/list`,
|
||||||
|
{page, page_size: pageSize},
|
||||||
|
API_ROOT_URL,
|
||||||
|
[0, 200]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,9 +1,69 @@
|
|||||||
export const AUDIO_INTERRUPTION_BEGIN_EVENT = "audio-interruption-begin";
|
export const AUDIO_INTERRUPTION_BEGIN_EVENT = "audio-interruption-begin";
|
||||||
export const AUDIO_INTERRUPTION_END_EVENT = "audio-interruption-end";
|
export const AUDIO_INTERRUPTION_END_EVENT = "audio-interruption-end";
|
||||||
|
export const RHYTHM_SHOOT_WINDOW_AUDIO_KEY = "请射箭";
|
||||||
|
export const STABILITY_START_AUDIO_KEY =
|
||||||
|
"请在计时结束前能量条达到百分百";
|
||||||
|
export const STABILITY_ENERGY_50_AUDIO_KEY = "加油!到达50%啦";
|
||||||
|
export const STABILITY_ENERGY_70_AUDIO_KEY =
|
||||||
|
"70%啦!还差一点,胜利就在眼前";
|
||||||
|
|
||||||
|
const TRAINING_START_AUDIO_KEY_MAP = Object.freeze({
|
||||||
|
base: "请于计时前完成指定环数对应箭量",
|
||||||
|
endurance: "请于计时前完成累计环数和箭量",
|
||||||
|
precision: "请射箭命中高亮区域",
|
||||||
|
rhythm: "请在读条推进到标记区间内射箭",
|
||||||
|
stability: "请在计时结束前能量条达到百分百",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const getTrainingStartAudioKey = (trainingType, fallback = "") =>
|
||||||
|
TRAINING_START_AUDIO_KEY_MAP[trainingType] || fallback;
|
||||||
|
|
||||||
|
export const getPrecisionShotAudioKeys = (shootData, directionText = "") => {
|
||||||
|
if (!shootData || typeof shootData !== "object") return [];
|
||||||
|
const ring = Number(shootData.ring);
|
||||||
|
const directionAudioKey =
|
||||||
|
shootData.angle !== null &&
|
||||||
|
shootData.angle !== undefined &&
|
||||||
|
directionText
|
||||||
|
? `向${directionText}调整`
|
||||||
|
: "";
|
||||||
|
if (!Number.isFinite(ring) || ring <= 0) {
|
||||||
|
return ["未上靶", directionAudioKey].filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
// protobuf 的 false 可能不编码;只要不是明确命中,本箭就反馈未命中。
|
||||||
|
const hitAudioKey = shootData.ok === true ? "Bingo命中目标" : "未命中";
|
||||||
|
return [directionAudioKey, hitAudioKey].filter(Boolean);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getRhythmShotAudioKeys = (shootData) => {
|
||||||
|
if (!shootData || typeof shootData !== "object") return [];
|
||||||
|
const ring = Number(shootData.ring);
|
||||||
|
const ringAudioKey =
|
||||||
|
Number.isFinite(ring) && ring > 0
|
||||||
|
? `${shootData.ringX ? "X" : ring}环`
|
||||||
|
: "未上靶";
|
||||||
|
// 节奏训练是否达标完全由服务端 ok 字段决定,前端不根据环数复算。
|
||||||
|
return [ringAudioKey, shootData.ok === true ? "Perfect" : "miss"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStabilityShotAudioKeys = (shootData) => {
|
||||||
|
if (!shootData || typeof shootData !== "object") return [];
|
||||||
|
const ring = Number(shootData.ring);
|
||||||
|
const ringAudioKey =
|
||||||
|
Number.isFinite(ring) && ring > 0
|
||||||
|
? `${shootData.ringX ? "X" : ring}环`
|
||||||
|
: "未上靶";
|
||||||
|
return [ringAudioKey];
|
||||||
|
};
|
||||||
|
|
||||||
export const audioFils = {
|
export const audioFils = {
|
||||||
tententen: "https://static.shelingxingqiu.com/shootmini/static/audio/tententen.mp3",
|
tententen: "https://static.shelingxingqiu.com/shootmini/static/audio/tententen.mp3",
|
||||||
点击按钮: "https://static.shelingxingqiu.com/shootmini/static/audio/%E7%82%B9%E5%87%BB%E6%8C%89%E9%92%AE.mp3",
|
点击按钮: "https://static.shelingxingqiu.com/shootmini/static/audio/%E7%82%B9%E5%87%BB%E6%8C%89%E9%92%AE.mp3",
|
||||||
|
设备连接已断开:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E8%AE%BE%E5%A4%87%E8%BF%9E%E6%8E%A5%E5%B7%B2%E6%96%AD%E5%BC%80.MP3",
|
||||||
|
设备已连接:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E8%AE%BE%E5%A4%87%E5%B7%B2%E8%BF%9E%E6%8E%A5.MP3",
|
||||||
"20CM全环靶": "https://static.shelingxingqiu.com/shootmini/static/audio/20CM%E5%85%A8%E7%8E%AF%E9%9D%B6-%E6%97%A0%E6%95%88.mp3",
|
"20CM全环靶": "https://static.shelingxingqiu.com/shootmini/static/audio/20CM%E5%85%A8%E7%8E%AF%E9%9D%B6-%E6%97%A0%E6%95%88.mp3",
|
||||||
"40CM全环靶": "https://static.shelingxingqiu.com/shootmini/static/audio/40CM%E5%85%A8%E7%8E%AF%E9%9D%B6-%E6%97%A0%E6%95%88.mp3",
|
"40CM全环靶": "https://static.shelingxingqiu.com/shootmini/static/audio/40CM%E5%85%A8%E7%8E%AF%E9%9D%B6-%E6%97%A0%E6%95%88.mp3",
|
||||||
// 激光已校准:
|
// 激光已校准:
|
||||||
@@ -16,6 +76,24 @@ export const audioFils = {
|
|||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutwrda0amn5kqr4j.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutwrda0amn5kqr4j.mp3",
|
||||||
距离不足:
|
距离不足:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6hr2faw28t0ianh0.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6hr2faw28t0ianh0.mp3",
|
||||||
|
"靶纸不符!请更换靶纸":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E9%9D%B6%E7%BA%B8%E4%B8%8D%E7%AC%A6%EF%BC%81%E8%AF%B7%E6%9B%B4%E6%8D%A2%E9%9D%B6%E7%BA%B8.MP3",
|
||||||
|
"站距与靶纸合格":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E7%AB%99%E8%B7%9D%E4%B8%8E%E9%9D%B6%E7%BA%B8%E5%90%88%E6%A0%BC.MP3",
|
||||||
|
"请射箭!测试站距与靶纸":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E8%AF%B7%E5%B0%84%E7%AE%AD%EF%BC%81%E6%B5%8B%E8%AF%95%E7%AB%99%E8%B7%9D%E4%B8%8E%E9%9D%B6%E7%BA%B8.MP3",
|
||||||
|
"站距过近,靶纸正确":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E7%AB%99%E8%B7%9D%E8%BF%87%E8%BF%91%EF%BC%8C%E9%9D%B6%E7%BA%B8%E6%AD%A3%E7%A1%AE.MP3",
|
||||||
|
"站距过近,靶纸错误":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E7%AB%99%E8%B7%9D%E8%BF%87%E8%BF%91%EF%BC%8C%E9%9D%B6%E7%BA%B8%E9%94%99%E8%AF%AF.MP3",
|
||||||
|
"站距合格,靶纸正确":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E7%AB%99%E8%B7%9D%E5%90%88%E6%A0%BC%EF%BC%8C%E9%9D%B6%E7%BA%B8%E6%AD%A3%E7%A1%AE.MP3",
|
||||||
|
"站距合格,靶纸错误":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E7%AB%99%E8%B7%9D%E5%90%88%E6%A0%BC%EF%BC%8C%E9%9D%B6%E7%BA%B8%E9%94%99%E8%AF%AF.MP3",
|
||||||
|
"未识别到靶纸,请瞄准靶纸射箭":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E6%9C%AA%E8%AF%86%E5%88%AB%E5%88%B0%E9%9D%B6%E7%BA%B8%EF%BC%8C%E8%AF%B7%E7%9E%84%E5%87%86%E9%9D%B6%E7%BA%B8%E5%B0%84%E7%AE%AD.MP3",
|
||||||
|
"未发现靶纸,请瞄准靶纸射箭":
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E6%9C%AA%E5%8F%91%E7%8E%B0%E9%9D%B6%E7%BA%B8%EF%BC%8C%E8%AF%B7%E7%9E%84%E5%87%86%E9%9D%B6%E7%BA%B8%E5%B0%84%E7%AE%AD.MP3",
|
||||||
轮到你了:
|
轮到你了:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutzdrn4lxcpv8aqr.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutzdrn4lxcpv8aqr.mp3",
|
||||||
第一轮:
|
第一轮:
|
||||||
@@ -46,6 +124,14 @@ 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%E8%B7%9D%E7%A6%BB%E4%B8%8D%E8%B6%B3%E4%B8%94%E9%9D%B6%E7%BA%B8%E9%94%99%E8%AF%AF.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环":
|
||||||
@@ -89,6 +175,30 @@ export const audioFils = {
|
|||||||
"https://static.shelingxingqiu.com/attachment/2025-11-13/de7kzzllq0futwynso.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-13/de7kzzllq0futwynso.mp3",
|
||||||
练习开始:
|
练习开始:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-14/de88w0lmmt43nnfmoi.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-14/de88w0lmmt43nnfmoi.mp3",
|
||||||
|
[STABILITY_START_AUDIO_KEY]:
|
||||||
|
"https://static.shelingxingqiu.com/shootaudio/%E8%AF%B7%E5%9C%A8%E8%AE%A1%E6%97%B6%E7%BB%93%E6%9D%9F%E5%89%8D%E8%83%BD%E9%87%8F%E6%9D%A1%E8%BE%BE%E5%88%B0%E7%99%BE%E5%88%86%E7%99%BE.MP3",
|
||||||
|
[STABILITY_ENERGY_50_AUDIO_KEY]:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E5%8A%A0%E6%B2%B9%EF%BC%81%E5%88%B0%E8%BE%BE50%25%E5%95%A6.MP3",
|
||||||
|
[STABILITY_ENERGY_70_AUDIO_KEY]:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/70%25%E5%95%A6%EF%BC%81%E8%BF%98%E5%B7%AE%E4%B8%80%E7%82%B9%EF%BC%8C%E8%83%9C%E5%88%A9%E5%B0%B1%E5%9C%A8%E7%9C%BC%E5%89%8D.MP3",
|
||||||
|
请于计时前完成指定环数对应箭量:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E8%AF%B7%E4%BA%8E%E8%AE%A1%E6%97%B6%E5%89%8D%E5%AE%8C%E6%88%90%E6%8C%87%E5%AE%9A%E7%8E%AF%E6%95%B0%E5%AF%B9%E5%BA%94%E7%AE%AD%E9%87%8F.MP3",
|
||||||
|
请于计时前完成累计环数和箭量:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E8%AF%B7%E4%BA%8E%E8%AE%A1%E6%97%B6%E5%89%8D%E5%AE%8C%E6%88%90%E7%B4%AF%E8%AE%A1%E7%8E%AF%E6%95%B0%E5%92%8C%E7%AE%AD%E9%87%8F.MP3",
|
||||||
|
请射箭命中高亮区域:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E8%AF%B7%E5%B0%84%E7%AE%AD%E5%91%BD%E4%B8%AD%E9%AB%98%E4%BA%AE%E5%8C%BA%E5%9F%9F.MP3",
|
||||||
|
请在读条推进到标记区间内射箭:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E8%AF%B7%E5%9C%A8%E8%AF%BB%E6%9D%A1%E6%8E%A8%E8%BF%9B%E5%88%B0%E6%A0%87%E8%AE%B0%E5%8C%BA%E9%97%B4%E5%86%85%E5%B0%84%E7%AE%AD.MP3",
|
||||||
|
[RHYTHM_SHOOT_WINDOW_AUDIO_KEY]:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E8%AF%B7%E5%B0%84%E7%AE%AD.MP3",
|
||||||
|
Perfect:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/Perfect.MP3",
|
||||||
|
miss:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/miss.MP3",
|
||||||
|
Bingo命中目标:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/Bingo%E5%91%BD%E4%B8%AD%E7%9B%AE%E6%A0%87.MP3",
|
||||||
|
未命中:
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/audio0820/%E6%9C%AA%E5%91%BD%E4%B8%AD.MP3",
|
||||||
练习结束:
|
练习结束:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/audio/%E7%BB%83%E4%B9%A0%E7%BB%93%E6%9D%9F.mp3",
|
"https://static.shelingxingqiu.com/shootmini/static/audio/%E7%BB%83%E4%B9%A0%E7%BB%93%E6%9D%9F.mp3",
|
||||||
射箭声音:
|
射箭声音:
|
||||||
@@ -100,8 +210,12 @@ 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 = [
|
||||||
"点击按钮",
|
"点击按钮",
|
||||||
|
"设备连接已断开",
|
||||||
|
"设备已连接",
|
||||||
"比赛开始",
|
"比赛开始",
|
||||||
"练习开始",
|
"练习开始",
|
||||||
"练习结束",
|
"练习结束",
|
||||||
@@ -109,13 +223,22 @@ const AUDIO_WARM_PRIORITY_KEYS = [
|
|||||||
"轮到你了",
|
"轮到你了",
|
||||||
"比赛结束",
|
"比赛结束",
|
||||||
"射击无效",
|
"射击无效",
|
||||||
|
"射箭无效,距离不足",
|
||||||
|
"射箭无效,距离不足且靶纸错误",
|
||||||
|
"射箭无效,未识别到靶纸",
|
||||||
|
"射箭无效,靶纸错误",
|
||||||
|
"请射箭!测试站距与靶纸",
|
||||||
|
"站距过近,靶纸正确",
|
||||||
|
"站距过近,靶纸错误",
|
||||||
|
"站距合格,靶纸正确",
|
||||||
|
"站距合格,靶纸错误",
|
||||||
|
"未识别到靶纸,请瞄准靶纸射箭",
|
||||||
"中场休息",
|
"中场休息",
|
||||||
"下半场开始",
|
"下半场开始",
|
||||||
"决金箭轮",
|
"决金箭轮",
|
||||||
"请蓝方射箭",
|
"请蓝方射箭",
|
||||||
"请红方射箭",
|
"请红方射箭",
|
||||||
"距离合格",
|
"距离合格",
|
||||||
"距离不足",
|
|
||||||
"未上靶",
|
"未上靶",
|
||||||
"X环",
|
"X环",
|
||||||
];
|
];
|
||||||
@@ -144,6 +267,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;
|
||||||
|
|
||||||
// 连续播放队列相关属性
|
// 连续播放队列相关属性
|
||||||
@@ -235,14 +360,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,23 +479,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();
|
||||||
}
|
}
|
||||||
@@ -348,6 +549,7 @@ class AudioManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.pruneAudioInstances(key);
|
||||||
const audio = uni.createInnerAudioContext();
|
const audio = uni.createInnerAudioContext();
|
||||||
audio.autoplay = false;
|
audio.autoplay = false;
|
||||||
try {
|
try {
|
||||||
@@ -359,6 +561,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();
|
||||||
@@ -396,6 +599,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 (_) {}
|
||||||
@@ -428,6 +632,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 (_) {}
|
||||||
@@ -462,6 +667,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,
|
||||||
@@ -469,10 +675,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;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -682,14 +890,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);
|
||||||
}
|
}
|
||||||
@@ -736,7 +937,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 {
|
||||||
// 没有序列但当前有正在播放的:以当前为序列的起点
|
// 没有序列但当前有正在播放的:以当前为序列的起点
|
||||||
@@ -745,6 +947,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;
|
||||||
@@ -851,6 +1064,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} 尚未就绪,按需加载后播放...`);
|
||||||
@@ -867,7 +1081,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 {
|
||||||
// 队列播放完成
|
// 队列播放完成
|
||||||
@@ -951,6 +1166,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. 停止所有播放
|
||||||
@@ -963,6 +1179,7 @@ class AudioManager {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
this.audioMap.clear();
|
this.audioMap.clear();
|
||||||
|
this.audioLastUsedAt.clear();
|
||||||
|
|
||||||
// 3. 重置状态
|
// 3. 重置状态
|
||||||
this.readyMap.clear();
|
this.readyMap.clear();
|
||||||
@@ -981,10 +1198,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);
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
targetType: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 40,
|
||||||
|
},
|
||||||
targetRadius: {
|
targetRadius: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 20,
|
default: 20,
|
||||||
@@ -63,6 +67,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 +85,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 +121,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 +155,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 +169,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 +220,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 +289,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 +314,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;
|
||||||
@@ -357,12 +430,19 @@ function getExperienceTipStyle(shot) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) {
|
||||||
|
await simulShootAPI(
|
||||||
|
device.value.deviceId,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
props.targetType
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const simulShoot2 = async () => {
|
const simulShoot2 = async () => {
|
||||||
if (device.value.deviceId) {
|
if (device.value.deviceId) {
|
||||||
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
||||||
await simulShootAPI(device.value.deviceId, r1, r1);
|
await simulShootAPI(device.value.deviceId, r1, r1, props.targetType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -411,11 +491,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 +603,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 +617,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,9 +5,11 @@ 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";
|
||||||
|
const emit = defineEmits(["scrolltolower"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -130,8 +132,9 @@ const goCalibration = async () => {
|
|||||||
<template>
|
<template>
|
||||||
<view :style="{ paddingTop: capsuleHeight + 'px' }">
|
<view :style="{ paddingTop: capsuleHeight + 'px' }">
|
||||||
<AppBackground :type="bgType" :bgColor="bgColor" />
|
<AppBackground :type="bgType" :bgColor="bgColor" />
|
||||||
|
<slot v-if="$slots.header" name="header"></slot>
|
||||||
<Header
|
<Header
|
||||||
v-if="!isHome"
|
v-else-if="!isHome"
|
||||||
:class="headerClass"
|
:class="headerClass"
|
||||||
:title="title"
|
:title="title"
|
||||||
:onBack="onBack"
|
:onBack="onBack"
|
||||||
@@ -157,8 +160,10 @@ const goCalibration = async () => {
|
|||||||
:enhanced="true"
|
:enhanced="true"
|
||||||
:bounces="false"
|
:bounces="false"
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
|
:lower-threshold="120"
|
||||||
|
@scrolltolower="emit('scrolltolower')"
|
||||||
:style="{
|
:style="{
|
||||||
height: `calc(100vh - ${capsuleHeight + (isHome ? 0 : 50)}px - ${
|
height: `calc(100vh - ${capsuleHeight + (($slots.header || !isHome) ? 50 : 0)}px - ${
|
||||||
$slots.bottom && showBottom ? (isIOS ? '75px' : '65px') : '0px'
|
$slots.bottom && showBottom ? (isIOS ? '75px' : '65px') : '0px'
|
||||||
})`,
|
})`,
|
||||||
}"
|
}"
|
||||||
@@ -226,6 +231,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>
|
||||||
@@ -125,6 +125,8 @@ onBeforeUnmount(() => {
|
|||||||
<view
|
<view
|
||||||
:style="[{ color: whiteBackArrow ? '#fff' : '#000' }, titleStyle]"
|
:style="[{ color: whiteBackArrow ? '#fff' : '#000' }, titleStyle]"
|
||||||
>
|
>
|
||||||
|
<slot v-if="$slots.title" name="title"></slot>
|
||||||
|
<template v-else>
|
||||||
<view
|
<view
|
||||||
v-if="currentPage === 'pages/point-book'"
|
v-if="currentPage === 'pages/point-book'"
|
||||||
class="user-header"
|
class="user-header"
|
||||||
@@ -190,6 +192,7 @@ onBeforeUnmount(() => {
|
|||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
</template>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="pointBook" class="point-book-info">
|
<view v-if="pointBook" class="point-book-info">
|
||||||
<text>{{ pointBook.bowType.name }}</text>
|
<text>{{ pointBook.bowType.name }}</text>
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
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,
|
||||||
|
getInvalidShotText,
|
||||||
|
} from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -88,10 +92,10 @@ async function onReceiveMessage(message) {
|
|||||||
currentRoundEnded.value = true;
|
currentRoundEnded.value = true;
|
||||||
} else if (type === MESSAGETYPESV2.InvalidShot) {
|
} else if (type === MESSAGETYPESV2.InvalidShot) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "距离不足,无效",
|
title: getInvalidShotText(shootData),
|
||||||
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>
|
||||||
|
|||||||
@@ -5,13 +5,19 @@ const props = defineProps({
|
|||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const getSum = (a, b, c) => {
|
const getSum = (...arrows) => {
|
||||||
const sum = (Number(a) || 0) + (Number(b) || 0) + (Number(c) || 0);
|
const recordedArrows = arrows.filter(Boolean);
|
||||||
return sum > 0 ? sum + "环" : "-";
|
if (!recordedArrows.length) return "-";
|
||||||
|
const sum = recordedArrows.reduce(
|
||||||
|
(total, arrow) => total + (Number(arrow.ring) || 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
return `${sum}环`;
|
||||||
};
|
};
|
||||||
const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"];
|
const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"];
|
||||||
const getShowText = (arrow = {}) => {
|
const getShowText = (arrow) => {
|
||||||
return arrow.ring ? (arrow.ringX ? "X" : arrow.ring + "环") : "-";
|
if (!arrow) return "-";
|
||||||
|
return arrow.ringX ? "X" : `${Number(arrow.ring) || 0}环`;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -57,19 +57,22 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getRing = (arrow) => {
|
const getRing = (arrow) => {
|
||||||
|
if (!arrow) return "-";
|
||||||
if (arrow.ringX) return "X";
|
if (arrow.ringX) return "X";
|
||||||
return arrow.ring ? arrow.ring : "-";
|
return Number(arrow.ring) || 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const arrows = computed(() => {
|
const arrows = computed(() => {
|
||||||
const data = new Array(props.total).fill({ ring: 0 });
|
const data = new Array(props.total).fill(null);
|
||||||
(props.result.details || []).forEach((arrow, index) => {
|
(props.result.details || []).forEach((arrow, index) => {
|
||||||
data[index] = arrow;
|
data[index] = arrow;
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
const validArrows = computed(() => arrows.value.filter((a) => !!a.ring).length);
|
const validArrows = computed(
|
||||||
|
() => arrows.value.filter((a) => Number(a?.ring) > 0).length
|
||||||
|
);
|
||||||
const isMember = computed(() => user.value.vip === true || user.value.sVip === true);
|
const isMember = computed(() => user.value.vip === true || user.value.sVip === true);
|
||||||
const openCoachComment = () => {
|
const openCoachComment = () => {
|
||||||
if (!isMember.value) return;
|
if (!isMember.value) return;
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
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,
|
||||||
|
getInvalidShotText,
|
||||||
|
} from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -171,10 +175,10 @@ async function onReceiveMessage(msg) {
|
|||||||
audioManager.play("中场休息");
|
audioManager.play("中场休息");
|
||||||
} else if (msg.type === MESSAGETYPESV2.InvalidShot) {
|
} else if (msg.type === MESSAGETYPESV2.InvalidShot) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "距离不足,无效",
|
title: getInvalidShotText(msg.shootData),
|
||||||
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 {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import audioManager from "@/audioManager";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
clickSound: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
onClose: {
|
onClose: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
@@ -39,7 +44,19 @@ watch(
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const playClickSound = () => {
|
||||||
|
if (props.clickSound) {
|
||||||
|
audioManager.play("点击按钮");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectTarget = (target) => {
|
||||||
|
playClickSound();
|
||||||
|
selectedTarget.value = target;
|
||||||
|
};
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
|
playClickSound();
|
||||||
props.onConfirm(selectedTarget.value);
|
props.onConfirm(selectedTarget.value);
|
||||||
props.onClose();
|
props.onClose();
|
||||||
};
|
};
|
||||||
@@ -70,14 +87,14 @@ const handleConfirm = () => {
|
|||||||
<view class="target-options">
|
<view class="target-options">
|
||||||
<view
|
<view
|
||||||
:class="{ 'target-btn': true, 'target-choosen': selectedTarget === 1 }"
|
:class="{ 'target-btn': true, 'target-choosen': selectedTarget === 1 }"
|
||||||
@click="() => (selectedTarget = 1)"
|
@click="handleSelectTarget(1)"
|
||||||
>
|
>
|
||||||
<text>20厘米全环靶</text>
|
<text>20厘米全环靶</text>
|
||||||
</view>
|
</view>
|
||||||
<view style="width: 30rpx"></view>
|
<view style="width: 30rpx"></view>
|
||||||
<view
|
<view
|
||||||
:class="{ 'target-btn': true, 'target-choosen': selectedTarget === 2 }"
|
:class="{ 'target-btn': true, 'target-choosen': selectedTarget === 2 }"
|
||||||
@click="() => (selectedTarget = 2)"
|
@click="handleSelectTarget(2)"
|
||||||
>
|
>
|
||||||
<text>40厘米全环靶</text>
|
<text>40厘米全环靶</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -194,4 +211,4 @@ const handleConfirm = () => {
|
|||||||
color: #fed847;
|
color: #fed847;
|
||||||
border: 4rpx solid #fed847;
|
border: 4rpx solid #fed847;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,10 +6,16 @@ import Avatar from "@/components/Avatar.vue";
|
|||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { simulShootAPI } from "@/apis";
|
import { simulShootAPI } from "@/apis";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
|
import {
|
||||||
|
getDistanceCheckAudioKey,
|
||||||
|
getDistanceCheckText,
|
||||||
|
getShootValidation,
|
||||||
|
} from "@/util";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user, device } = storeToRefs(store);
|
const { user, device } = storeToRefs(store);
|
||||||
|
const emit = defineEmits(["passed"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
guide: {
|
guide: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -23,18 +29,50 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 15,
|
default: 15,
|
||||||
},
|
},
|
||||||
|
targetType: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 40,
|
||||||
|
},
|
||||||
|
autoStart: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const arrow = ref({});
|
const arrow = ref({});
|
||||||
const distance = ref(0);
|
const distance = ref(0);
|
||||||
|
const statusText = ref("");
|
||||||
const showsimul = ref(false);
|
const showsimul = ref(false);
|
||||||
const count = ref(props.count);
|
const count = ref(props.count);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
|
const autoStartPending = ref(false);
|
||||||
|
const autoStartTriggered = ref(false);
|
||||||
|
let autoStartTimer = null;
|
||||||
|
const DISTANCE_PASSED_AUDIO_KEY = "站距合格,靶纸正确";
|
||||||
|
const AUTO_START_TIMEOUT_MS = 6000;
|
||||||
|
|
||||||
|
const clearAutoStartTimer = () => {
|
||||||
|
if (!autoStartTimer) return;
|
||||||
|
clearTimeout(autoStartTimer);
|
||||||
|
autoStartTimer = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const triggerAutoStart = () => {
|
||||||
|
if (!autoStartPending.value || autoStartTriggered.value) return;
|
||||||
|
clearAutoStartTimer();
|
||||||
|
autoStartPending.value = false;
|
||||||
|
autoStartTriggered.value = true;
|
||||||
|
emit("passed");
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAudioEnded = (key) => {
|
||||||
|
if (key === DISTANCE_PASSED_AUDIO_KEY) triggerAutoStart();
|
||||||
|
};
|
||||||
|
|
||||||
const updateTimer = (value) => {
|
const updateTimer = (value) => {
|
||||||
count.value = Math.round(value);
|
count.value = Math.round(value);
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
audioManager.play("请射箭测试距离");
|
audioManager.play("请射箭!测试站距与靶纸");
|
||||||
if (props.isBattle) {
|
if (props.isBattle) {
|
||||||
timer.value = setInterval(() => {
|
timer.value = setInterval(() => {
|
||||||
count.value -= 1;
|
count.value -= 1;
|
||||||
@@ -42,23 +80,43 @@ onMounted(() => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
uni.$on("update-timer", updateTimer);
|
uni.$on("update-timer", updateTimer);
|
||||||
|
uni.$on("audioEnded", onAudioEnded);
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
clearAutoStartTimer();
|
||||||
uni.$off("update-timer", updateTimer);
|
uni.$off("update-timer", updateTimer);
|
||||||
|
uni.$off("audioEnded", onAudioEnded);
|
||||||
});
|
});
|
||||||
|
|
||||||
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));
|
if (autoStartPending.value || autoStartTriggered.value) return;
|
||||||
if (distance.value >= 5) audioManager.play("距离合格");
|
const rawDistance = Number(msg.shootData?.distance ?? msg.shootData?.dst);
|
||||||
else audioManager.play("距离不足");
|
distance.value = Number.isFinite(rawDistance)
|
||||||
|
? Number((rawDistance / 100).toFixed(2))
|
||||||
|
: 0;
|
||||||
|
statusText.value = getDistanceCheckText(msg.shootData);
|
||||||
|
const audioKey = getDistanceCheckAudioKey(msg.shootData);
|
||||||
|
const validation = getShootValidation(msg.shootData);
|
||||||
|
if (props.autoStart && validation.distanceOk && validation.targetOk) {
|
||||||
|
autoStartPending.value = true;
|
||||||
|
autoStartTimer = setTimeout(triggerAutoStart, AUTO_START_TIMEOUT_MS);
|
||||||
|
}
|
||||||
|
audioManager.play(audioKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) {
|
||||||
|
await simulShootAPI(
|
||||||
|
device.value.deviceId,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
props.targetType
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -96,13 +154,11 @@ onBeforeUnmount(() => {
|
|||||||
模拟射箭
|
模拟射箭
|
||||||
</button>
|
</button>
|
||||||
<view class="warnning-text">
|
<view class="warnning-text">
|
||||||
<block v-if="distance > 0">
|
<block v-if="statusText">
|
||||||
<text>当前距离{{ distance }}米</text>
|
<text>{{ statusText }}</text>
|
||||||
<text v-if="distance >= 5">已达到距离要求</text>
|
|
||||||
<text v-else>请调整站位</text>
|
|
||||||
</block>
|
</block>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<text>请射箭,测试站距</text>
|
<text>请射箭,测试站距与靶纸</text>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-row">
|
<view class="user-row">
|
||||||
@@ -113,7 +169,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,171 @@
|
|||||||
|
<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 props.trainingType === "stability" ? "-" : "0";
|
||||||
|
return arrow.ringX ? "X" : String(arrow.ring);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isFailed = (arrow = {}) => {
|
||||||
|
if (!arrow) return false;
|
||||||
|
if (
|
||||||
|
props.recordMode &&
|
||||||
|
props.trainingType !== "precision" &&
|
||||||
|
props.trainingType !== "rhythm" &&
|
||||||
|
props.trainingType !== "stability"
|
||||||
|
) {
|
||||||
|
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 = {
|
||||||
|
|||||||
@@ -9,7 +9,19 @@ import {
|
|||||||
getServerMessageTypeName,
|
getServerMessageTypeName,
|
||||||
} from "@/utils/matchProtocol";
|
} from "@/utils/matchProtocol";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import {
|
||||||
|
getDirectionText,
|
||||||
|
getDistanceCheckAudioKey,
|
||||||
|
getInvalidShotAudioKey,
|
||||||
|
} from "@/util";
|
||||||
|
import {
|
||||||
|
getPrecisionShotAudioKeys,
|
||||||
|
getRhythmShotAudioKeys,
|
||||||
|
getStabilityShotAudioKeys,
|
||||||
|
getTrainingStartAudioKey,
|
||||||
|
STABILITY_ENERGY_50_AUDIO_KEY,
|
||||||
|
STABILITY_ENERGY_70_AUDIO_KEY,
|
||||||
|
} from "@/audioManager";
|
||||||
import {
|
import {
|
||||||
normalizeId,
|
normalizeId,
|
||||||
normalizeMatchInfo,
|
normalizeMatchInfo,
|
||||||
@@ -41,6 +53,13 @@ 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;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
// 比赛服消息类型先映射成项目里已有的 V2 业务消息,页面仍然复用原来的 socket-inbox 流程。
|
// 比赛服消息类型先映射成项目里已有的 V2 业务消息,页面仍然复用原来的 socket-inbox 流程。
|
||||||
const BUSINESS_TYPE_BY_SERVER_TYPE = {
|
const BUSINESS_TYPE_BY_SERVER_TYPE = {
|
||||||
@@ -66,6 +85,9 @@ function normalizeShootData(shootData) {
|
|||||||
if (normalized.distance === undefined && normalized.dst !== undefined) {
|
if (normalized.distance === undefined && normalized.dst !== undefined) {
|
||||||
normalized.distance = normalized.dst;
|
normalized.distance = normalized.dst;
|
||||||
}
|
}
|
||||||
|
if (normalized.targetOk === undefined && normalized.target_ok !== undefined) {
|
||||||
|
normalized.targetOk = normalized.target_ok;
|
||||||
|
}
|
||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +153,15 @@ function buildBusinessMessage(message) {
|
|||||||
matchInfo.status = 0;
|
matchInfo.status = 0;
|
||||||
}
|
}
|
||||||
const practiceInfo = normalizePracticeInfo(message.practice_info);
|
const practiceInfo = normalizePracticeInfo(message.practice_info);
|
||||||
|
const trainingType = String(
|
||||||
|
practiceInfo.trainingType ||
|
||||||
|
matchInfo.trainingType ||
|
||||||
|
currentContext?.trainingType ||
|
||||||
|
""
|
||||||
|
).trim();
|
||||||
|
if (currentContext && trainingType) {
|
||||||
|
currentContext.trainingType = trainingType;
|
||||||
|
}
|
||||||
const businessType = getBusinessType(message, matchInfo);
|
const businessType = getBusinessType(message, matchInfo);
|
||||||
if (!businessType) return null;
|
if (!businessType) return null;
|
||||||
|
|
||||||
@@ -183,11 +214,22 @@ function buildBusinessMessage(message) {
|
|||||||
matchWsType: message.type,
|
matchWsType: message.type,
|
||||||
matchWsTypeName: getServerMessageTypeName(message.type),
|
matchWsTypeName: getServerMessageTypeName(message.type),
|
||||||
isSecondHalfStart,
|
isSecondHalfStart,
|
||||||
|
...(trainingType ? { trainingType } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildPracticeSyncMessage(message) {
|
function buildPracticeSyncMessage(message) {
|
||||||
const practiceInfo = normalizePracticeInfo(message.practice_info);
|
const practiceInfo = normalizePracticeInfo(message.practice_info);
|
||||||
|
if (currentContext && practiceInfo.trainingType) {
|
||||||
|
currentContext.trainingType = String(practiceInfo.trainingType).trim();
|
||||||
|
}
|
||||||
|
updateStabilityEnergyContext(practiceInfo, {
|
||||||
|
fullSnapshot: true,
|
||||||
|
detectCrossing: false,
|
||||||
|
});
|
||||||
|
updateStabilityShotContext(practiceInfo, {
|
||||||
|
detectShot: false,
|
||||||
|
});
|
||||||
const matchId = normalizeId(
|
const matchId = normalizeId(
|
||||||
pickField(message, "matchId", "match_id") ||
|
pickField(message, "matchId", "match_id") ||
|
||||||
practiceInfo.id ||
|
practiceInfo.id ||
|
||||||
@@ -346,16 +388,183 @@ function getShootResultAudioKeys(shootData) {
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeScoreSlot(value) {
|
||||||
|
const scoreSlot = Number(value);
|
||||||
|
return Number.isFinite(scoreSlot) && scoreSlot > 0 ? scoreSlot : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clampEnergy(value, scoreSlot = 0) {
|
||||||
|
const energy = Number(value);
|
||||||
|
if (!Number.isFinite(energy)) return 0;
|
||||||
|
const maxEnergy = normalizeScoreSlot(scoreSlot);
|
||||||
|
return maxEnergy > 0
|
||||||
|
? Math.min(maxEnergy, Math.max(0, energy))
|
||||||
|
: Math.max(0, energy);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEnergyPercent(energy, scoreSlot) {
|
||||||
|
const maxEnergy = normalizeScoreSlot(scoreSlot);
|
||||||
|
if (!maxEnergy) return 0;
|
||||||
|
return Math.min(100, (clampEnergy(energy, maxEnergy) / maxEnergy) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStabilityArrowCount(source = {}) {
|
||||||
|
const candidates = [
|
||||||
|
Array.isArray(source.details) ? source.details.length : NaN,
|
||||||
|
Number(source.currentArrows),
|
||||||
|
Number(source.totalArrows),
|
||||||
|
].filter((value) => Number.isFinite(value) && value >= 0);
|
||||||
|
return candidates.length > 0 ? Math.max(...candidates) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateStabilityShotContext(
|
||||||
|
source = {},
|
||||||
|
{ detectShot = false } = {}
|
||||||
|
) {
|
||||||
|
const trainingType = String(
|
||||||
|
source.trainingType || currentContext?.trainingType || ""
|
||||||
|
).trim();
|
||||||
|
if (trainingType !== "stability" || !currentContext) return false;
|
||||||
|
|
||||||
|
const nextArrowCount = getStabilityArrowCount(source);
|
||||||
|
if (nextArrowCount === null) return false;
|
||||||
|
|
||||||
|
const storedArrowCount = Number(currentContext.stabilityArrowCount);
|
||||||
|
const previousArrowCount = Number.isFinite(storedArrowCount)
|
||||||
|
? storedArrowCount
|
||||||
|
: 0;
|
||||||
|
const hasNewShot =
|
||||||
|
detectShot && nextArrowCount > previousArrowCount;
|
||||||
|
|
||||||
|
if (nextArrowCount >= previousArrowCount) {
|
||||||
|
currentContext.stabilityArrowCount = nextArrowCount;
|
||||||
|
}
|
||||||
|
return hasNewShot;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 稳定训练的阈值语音必须和 ACK 使用同一份判定结果,避免页面播放了
|
||||||
|
// 里程碑语音但比赛服提前收到 ACK。能量跌破阈值后再次向上跨越可重复触发。
|
||||||
|
function updateStabilityEnergyContext(
|
||||||
|
source = {},
|
||||||
|
{ fullSnapshot = false, detectCrossing = false } = {}
|
||||||
|
) {
|
||||||
|
const trainingType = String(
|
||||||
|
source.trainingType || currentContext?.trainingType || ""
|
||||||
|
).trim();
|
||||||
|
if (trainingType !== "stability" || !currentContext) return "";
|
||||||
|
|
||||||
|
const hasCurrentEnergy = Object.prototype.hasOwnProperty.call(
|
||||||
|
source,
|
||||||
|
"currentEnergy"
|
||||||
|
);
|
||||||
|
if (!hasCurrentEnergy && !fullSnapshot) return "";
|
||||||
|
|
||||||
|
const previousScoreSlot = normalizeScoreSlot(
|
||||||
|
currentContext.stabilityScoreSlot
|
||||||
|
);
|
||||||
|
const nextScoreSlot =
|
||||||
|
normalizeScoreSlot(source.scoreSlot) || previousScoreSlot;
|
||||||
|
const previousEnergy = clampEnergy(
|
||||||
|
currentContext.stabilityEnergy,
|
||||||
|
previousScoreSlot
|
||||||
|
);
|
||||||
|
const nextEnergy = clampEnergy(
|
||||||
|
hasCurrentEnergy ? source.currentEnergy : 0,
|
||||||
|
nextScoreSlot
|
||||||
|
);
|
||||||
|
const previousPercent = getEnergyPercent(
|
||||||
|
previousEnergy,
|
||||||
|
previousScoreSlot || nextScoreSlot
|
||||||
|
);
|
||||||
|
const nextPercent = getEnergyPercent(nextEnergy, nextScoreSlot);
|
||||||
|
|
||||||
|
currentContext.stabilityEnergy = nextEnergy;
|
||||||
|
currentContext.stabilityScoreSlot = nextScoreSlot;
|
||||||
|
|
||||||
|
if (!detectCrossing) {
|
||||||
|
currentContext.stabilityEnergy50Armed = nextPercent < 50;
|
||||||
|
currentContext.stabilityEnergy70Armed = nextPercent < 70;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
let energy50Armed =
|
||||||
|
typeof currentContext.stabilityEnergy50Armed === "boolean"
|
||||||
|
? currentContext.stabilityEnergy50Armed
|
||||||
|
: previousPercent < 50;
|
||||||
|
let energy70Armed =
|
||||||
|
typeof currentContext.stabilityEnergy70Armed === "boolean"
|
||||||
|
? currentContext.stabilityEnergy70Armed
|
||||||
|
: previousPercent < 70;
|
||||||
|
|
||||||
|
if (nextPercent < 50) energy50Armed = true;
|
||||||
|
if (nextPercent < 70) energy70Armed = true;
|
||||||
|
|
||||||
|
let milestoneAudioKey = "";
|
||||||
|
if (energy70Armed && nextPercent >= 70) {
|
||||||
|
milestoneAudioKey = STABILITY_ENERGY_70_AUDIO_KEY;
|
||||||
|
energy70Armed = false;
|
||||||
|
// 同一次直接跨过两个阈值时只播70%,不能在后续补播50%。
|
||||||
|
energy50Armed = false;
|
||||||
|
} else if (energy50Armed && nextPercent >= 50) {
|
||||||
|
milestoneAudioKey = STABILITY_ENERGY_50_AUDIO_KEY;
|
||||||
|
energy50Armed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentContext.stabilityEnergy50Armed = energy50Armed;
|
||||||
|
currentContext.stabilityEnergy70Armed = energy70Armed;
|
||||||
|
return milestoneAudioKey;
|
||||||
|
}
|
||||||
|
|
||||||
function getTestDistanceAudioKeys(shootData) {
|
function getTestDistanceAudioKeys(shootData) {
|
||||||
const distance = Number(shootData?.distance ?? shootData?.dst);
|
if (!shootData) return [];
|
||||||
if (Number.isNaN(distance)) return [];
|
return [getDistanceCheckAudioKey(shootData)];
|
||||||
return [distance / 100 >= 5 ? "\u8ddd\u79bb\u5408\u683c" : "\u8ddd\u79bb\u4e0d\u8db3"];
|
}
|
||||||
|
|
||||||
|
function attachStabilityAudioContext(message, businessMessage) {
|
||||||
|
const fullStabilitySnapshot = [
|
||||||
|
ServerMessageType.SERVER_MSG_MATCH_START,
|
||||||
|
ServerMessageType.SERVER_MSG_SHOT,
|
||||||
|
ServerMessageType.SERVER_MSG_MATCH_END,
|
||||||
|
ServerMessageType.SERVER_MSG_TIMEOUT,
|
||||||
|
ServerMessageType.SERVER_MSG_PRACTICE_END,
|
||||||
|
].includes(message.type);
|
||||||
|
const stabilityMilestoneAudioKey = updateStabilityEnergyContext(
|
||||||
|
businessMessage,
|
||||||
|
{
|
||||||
|
fullSnapshot: fullStabilitySnapshot,
|
||||||
|
detectCrossing: message.type === ServerMessageType.SERVER_MSG_SHOT,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const stabilityHasNewShot = updateStabilityShotContext(businessMessage, {
|
||||||
|
detectShot: message.type === ServerMessageType.SERVER_MSG_SHOT,
|
||||||
|
});
|
||||||
|
if (businessMessage && stabilityMilestoneAudioKey) {
|
||||||
|
businessMessage.stabilityMilestoneAudioKey = stabilityMilestoneAudioKey;
|
||||||
|
}
|
||||||
|
if (businessMessage) {
|
||||||
|
businessMessage.stabilityHasNewShot = stabilityHasNewShot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAckAudioKeys(message, businessMessage) {
|
function getAckAudioKeys(message, businessMessage) {
|
||||||
|
const stabilityMilestoneAudioKey = String(
|
||||||
|
businessMessage?.stabilityMilestoneAudioKey || ""
|
||||||
|
).trim();
|
||||||
|
const stabilityHasNewShot =
|
||||||
|
businessMessage?.stabilityHasNewShot === true;
|
||||||
|
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case ServerMessageType.SERVER_MSG_MATCH_START:
|
case ServerMessageType.SERVER_MSG_MATCH_START:
|
||||||
return [businessMessage?.isSecondHalfStart ? "下半场开始" : "比赛开始"];
|
if (businessMessage?.isSecondHalfStart) return ["下半场开始"];
|
||||||
|
// 个人训练在开始接口成功后主动播报,不再等待 MATCH_START 触发语音。
|
||||||
|
if (
|
||||||
|
getTrainingStartAudioKey(
|
||||||
|
businessMessage?.trainingType || currentContext?.trainingType
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return ["比赛开始"];
|
||||||
case ServerMessageType.SERVER_MSG_NOW_YOU:
|
case ServerMessageType.SERVER_MSG_NOW_YOU:
|
||||||
if (isMeleeMessage(message, businessMessage)) return [];
|
if (isMeleeMessage(message, businessMessage)) return [];
|
||||||
return getNowYouAudioKeys(businessMessage);
|
return getNowYouAudioKeys(businessMessage);
|
||||||
@@ -366,6 +575,27 @@ function getAckAudioKeys(message, businessMessage) {
|
|||||||
) {
|
) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
const trainingType =
|
||||||
|
businessMessage?.trainingType || currentContext?.trainingType;
|
||||||
|
if (trainingType === "precision") {
|
||||||
|
const shootData = businessMessage?.shootData;
|
||||||
|
const directionText =
|
||||||
|
shootData?.angle !== null && shootData?.angle !== undefined
|
||||||
|
? getDirectionText(shootData.angle)
|
||||||
|
: "";
|
||||||
|
return getPrecisionShotAudioKeys(shootData, directionText);
|
||||||
|
}
|
||||||
|
if (trainingType === "rhythm") {
|
||||||
|
return getRhythmShotAudioKeys(businessMessage?.shootData);
|
||||||
|
}
|
||||||
|
if (trainingType === "stability") {
|
||||||
|
return [
|
||||||
|
...(stabilityHasNewShot
|
||||||
|
? getStabilityShotAudioKeys(businessMessage?.shootData)
|
||||||
|
: []),
|
||||||
|
stabilityMilestoneAudioKey,
|
||||||
|
].filter(Boolean);
|
||||||
|
}
|
||||||
return getShootResultAudioKeys(businessMessage?.shootData);
|
return getShootResultAudioKeys(businessMessage?.shootData);
|
||||||
case ServerMessageType.SERVER_MSG_MATCH_END:
|
case ServerMessageType.SERVER_MSG_MATCH_END:
|
||||||
return ["比赛结束"];
|
return ["比赛结束"];
|
||||||
@@ -373,11 +603,11 @@ function getAckAudioKeys(message, businessMessage) {
|
|||||||
if (businessMessage?.type === MESSAGETYPESV2.HalfRest) return ["中场休息"];
|
if (businessMessage?.type === MESSAGETYPESV2.HalfRest) return ["中场休息"];
|
||||||
return ["比赛结束"];
|
return ["比赛结束"];
|
||||||
case ServerMessageType.SERVER_MSG_PRACTICE_END:
|
case ServerMessageType.SERVER_MSG_PRACTICE_END:
|
||||||
return ["比赛结束"];
|
return [currentContext?.practiceEndAudioKey || "比赛结束"];
|
||||||
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 [];
|
||||||
}
|
}
|
||||||
@@ -630,7 +860,9 @@ function sendHeartbeatAck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendPracticeInfoSync() {
|
function sendPracticeInfoSync() {
|
||||||
if (!socket || !currentContext?.matchId || !currentContext?.userId) return;
|
if (!socket || !currentContext?.matchId || !currentContext?.userId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const clientMessage = {
|
const clientMessage = {
|
||||||
type: ClientMessageType.CLIENT_MSG_SYNC_PRACTICE_INFO,
|
type: ClientMessageType.CLIENT_MSG_SYNC_PRACTICE_INFO,
|
||||||
@@ -645,6 +877,12 @@ function sendPracticeInfoSync() {
|
|||||||
"CLIENT_MSG_SYNC_PRACTICE_INFO",
|
"CLIENT_MSG_SYNC_PRACTICE_INFO",
|
||||||
clientMessage
|
clientMessage
|
||||||
);
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 训练开始后可在不重连 WebSocket 的情况下主动刷新完整练习快照。
|
||||||
|
export function requestPracticeInfoSync() {
|
||||||
|
return sendPracticeInfoSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendAck({ matchId, sequence }) {
|
function sendAck({ matchId, sequence }) {
|
||||||
@@ -783,8 +1021,9 @@ function handleMessage(data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeName = getServerMessageTypeName(message.type);
|
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||||
console.log("收到比赛服 WebSocket 消息", typeName, message);
|
console.log("收到比赛服 WebSocket 消息", 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) {
|
||||||
@@ -818,6 +1057,8 @@ function handleMessage(data) {
|
|||||||
if (businessMessage?.matchId && currentContext) {
|
if (businessMessage?.matchId && currentContext) {
|
||||||
currentContext.matchId = businessMessage.matchId;
|
currentContext.matchId = businessMessage.matchId;
|
||||||
}
|
}
|
||||||
|
// 阈值事件必须先于 ACK 判断生成,确保无 sequence 的状态推送也能播放。
|
||||||
|
attachStabilityAudioContext(message, businessMessage);
|
||||||
queueAckAfterAudio(message, businessMessage);
|
queueAckAfterAudio(message, businessMessage);
|
||||||
emitBusinessMessage(businessMessage);
|
emitBusinessMessage(businessMessage);
|
||||||
}
|
}
|
||||||
@@ -850,6 +1091,8 @@ export function connectMatchWebSocket(options = {}) {
|
|||||||
mode,
|
mode,
|
||||||
requestPracticeInfoOnOpen = false,
|
requestPracticeInfoOnOpen = false,
|
||||||
appHideResumable = false,
|
appHideResumable = false,
|
||||||
|
practiceEndAudioKey = "",
|
||||||
|
trainingType = "",
|
||||||
force = false,
|
force = false,
|
||||||
reconnecting = false,
|
reconnecting = false,
|
||||||
reconnectReason = "",
|
reconnectReason = "",
|
||||||
@@ -857,6 +1100,7 @@ export function connectMatchWebSocket(options = {}) {
|
|||||||
const normalizedMatchId = normalizeId(matchId);
|
const normalizedMatchId = normalizeId(matchId);
|
||||||
const normalizedUserId = normalizeId(userId);
|
const normalizedUserId = normalizeId(userId);
|
||||||
const normalizedMode = Number(mode);
|
const normalizedMode = Number(mode);
|
||||||
|
const normalizedTrainingType = String(trainingType || "").trim();
|
||||||
const incomingUrl = normalizeServerUrl(serverAddr, token);
|
const incomingUrl = normalizeServerUrl(serverAddr, token);
|
||||||
const currentUrlToken = getUrlToken(currentContext?.url);
|
const currentUrlToken = getUrlToken(currentContext?.url);
|
||||||
const shouldKeepAuthenticatedUrl = !!(
|
const shouldKeepAuthenticatedUrl = !!(
|
||||||
@@ -922,6 +1166,25 @@ export function connectMatchWebSocket(options = {}) {
|
|||||||
Number.isFinite(normalizedMode) ? normalizedMode > 3 : undefined,
|
Number.isFinite(normalizedMode) ? normalizedMode > 3 : undefined,
|
||||||
requestPracticeInfoOnOpen: requestPracticeInfoOnOpen === true,
|
requestPracticeInfoOnOpen: requestPracticeInfoOnOpen === true,
|
||||||
appHideResumable: appHideResumable === true,
|
appHideResumable: appHideResumable === true,
|
||||||
|
practiceEndAudioKey: String(practiceEndAudioKey || "").trim(),
|
||||||
|
trainingType:
|
||||||
|
normalizedTrainingType ||
|
||||||
|
(isSameContext ? currentContext?.trainingType || "" : ""),
|
||||||
|
stabilityEnergy: isSameContext
|
||||||
|
? currentContext?.stabilityEnergy
|
||||||
|
: undefined,
|
||||||
|
stabilityScoreSlot: isSameContext
|
||||||
|
? currentContext?.stabilityScoreSlot
|
||||||
|
: undefined,
|
||||||
|
stabilityEnergy50Armed: isSameContext
|
||||||
|
? currentContext?.stabilityEnergy50Armed
|
||||||
|
: undefined,
|
||||||
|
stabilityEnergy70Armed: isSameContext
|
||||||
|
? currentContext?.stabilityEnergy70Armed
|
||||||
|
: undefined,
|
||||||
|
stabilityArrowCount: isSameContext
|
||||||
|
? currentContext?.stabilityArrowCount
|
||||||
|
: undefined,
|
||||||
meleeHalfRest: isSameContext
|
meleeHalfRest: isSameContext
|
||||||
? currentContext?.meleeHalfRest === true
|
? currentContext?.meleeHalfRest === true
|
||||||
: false,
|
: false,
|
||||||
|
|||||||
@@ -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;
|
|
||||||
};
|
|
||||||
@@ -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,40 @@
|
|||||||
"^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/coin",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "index"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "rules"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "earning-records"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "exchange-records"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "nearby-stores"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "product-detail"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
cumulative: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
available: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="balance-panel">
|
||||||
|
<view class="balance-list">
|
||||||
|
<view class="balance-item">
|
||||||
|
<text class="balance-item__label">累计金币:</text>
|
||||||
|
<text class="balance-item__value">{{ cumulative }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="balance-list__line" />
|
||||||
|
<view class="balance-item">
|
||||||
|
<text class="balance-item__label">可兑换金币:</text>
|
||||||
|
<text class="balance-item__value">{{ available }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.balance-panel {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8rpx 28rpx 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.balance-list {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 706rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
margin-top: 0;
|
||||||
|
border: 2rpx solid rgba(255, 217, 71, 0.25);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: rgba(255, 217, 71, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.balance-item {
|
||||||
|
width: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.balance-item__label {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.balance-item__value {
|
||||||
|
color: #ffd947;
|
||||||
|
font-size: 30rpx;
|
||||||
|
line-height: 42rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.balance-list__line {
|
||||||
|
width: 2rpx;
|
||||||
|
height: 28rpx;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
|
margin: 0 22rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
text: {
|
||||||
|
type: String,
|
||||||
|
default: "暂无金币获取记录。",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="empty-state">
|
||||||
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/shootmini/static/coin/empty-coin-record.png"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
<text>{{ text }}</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.empty-state {
|
||||||
|
width: 100%;
|
||||||
|
padding-top: 280rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 36rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state > image {
|
||||||
|
width: 162rpx;
|
||||||
|
height: 190rpx;
|
||||||
|
margin-bottom: 26rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<script setup>
|
||||||
|
import Header from "@/components/Header.vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
onBack: {
|
||||||
|
type: Function,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="coin-header">
|
||||||
|
<Header title="" :onBack="onBack">
|
||||||
|
<template #title>
|
||||||
|
<view class="coin-header__title-group">
|
||||||
|
<text
|
||||||
|
:class="[
|
||||||
|
'coin-header__title',
|
||||||
|
subtitle ? 'coin-header__title--with-subtitle' : '',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
{{ title }}
|
||||||
|
</text>
|
||||||
|
<text v-if="subtitle" class="coin-header__subtitle">
|
||||||
|
{{ subtitle }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</Header>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.coin-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 20;
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coin-header__title-group {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 430rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coin-header__title {
|
||||||
|
color: #e7ba80;
|
||||||
|
font-size: 30rpx;
|
||||||
|
line-height: 42rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coin-header__title--with-subtitle {
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coin-header__subtitle {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 20rpx;
|
||||||
|
line-height: 28rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
menus: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["select"]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="quick-menu">
|
||||||
|
<view
|
||||||
|
v-for="item in menus"
|
||||||
|
:key="item.key"
|
||||||
|
class="quick-menu__item"
|
||||||
|
@click="emit('select', item)"
|
||||||
|
>
|
||||||
|
<image class="quick-menu__icon" :src="item.icon" mode="aspectFit" />
|
||||||
|
<text>{{ item.label }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.quick-menu {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
padding: 26rpx 46rpx 30rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-menu__item {
|
||||||
|
width: 142rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
color: #fae6bc;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-menu__icon {
|
||||||
|
width: 116rpx;
|
||||||
|
height: 116rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
records: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
mode: {
|
||||||
|
type: String,
|
||||||
|
default: "earning",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view
|
||||||
|
class="record-table"
|
||||||
|
:class="{ 'record-table--exchange': mode === 'exchange' }"
|
||||||
|
>
|
||||||
|
<view class="record-table__header">
|
||||||
|
<template v-if="mode === 'exchange'">
|
||||||
|
<text>兑换内容</text>
|
||||||
|
<text>兑换类型</text>
|
||||||
|
<text>时间</text>
|
||||||
|
<text>金币使用</text>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<text>时间</text>
|
||||||
|
<text>类型</text>
|
||||||
|
<text>金币获取</text>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-for="item in records"
|
||||||
|
:key="item.id"
|
||||||
|
class="record-table__row"
|
||||||
|
>
|
||||||
|
<template v-if="mode === 'exchange'">
|
||||||
|
<text class="record-table__exchange-content">{{ item.content }}</text>
|
||||||
|
<text class="record-table__exchange-type">{{ item.type }}</text>
|
||||||
|
<view class="record-table__time record-table__exchange-time">
|
||||||
|
<text>{{ item.date }}</text>
|
||||||
|
<text>{{ item.time }}</text>
|
||||||
|
</view>
|
||||||
|
<text class="record-table__amount record-table__exchange-amount">
|
||||||
|
{{ item.amount }}
|
||||||
|
</text>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class="record-table__time">
|
||||||
|
<text>{{ item.date }}</text>
|
||||||
|
<text>{{ item.time }}</text>
|
||||||
|
</view>
|
||||||
|
<text class="record-table__type">{{ item.type }}</text>
|
||||||
|
<text class="record-table__amount">{{ item.amount }}</text>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.record-table {
|
||||||
|
width: 670rpx;
|
||||||
|
margin: 20rpx auto 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 2rpx solid rgba(255, 255, 255, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__header,
|
||||||
|
.record-table__row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__header {
|
||||||
|
height: 66rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__header > text {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-right: 2rpx solid rgba(255, 255, 255, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__header > text:nth-child(1),
|
||||||
|
.record-table__time {
|
||||||
|
width: 182rpx;
|
||||||
|
flex: 0 0 182rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__header > text:nth-child(2),
|
||||||
|
.record-table__type {
|
||||||
|
width: 304rpx;
|
||||||
|
flex: 0 0 304rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__header > text:nth-child(3),
|
||||||
|
.record-table__amount {
|
||||||
|
width: 180rpx;
|
||||||
|
flex: 0 0 180rpx;
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__row {
|
||||||
|
height: 86rpx;
|
||||||
|
border-top: 2rpx solid rgba(255, 255, 255, 0.35);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__row > view,
|
||||||
|
.record-table__row > text {
|
||||||
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-right: 2rpx solid rgba(255, 255, 255, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__time {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__time > text:last-child {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__type {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__row > .record-table__amount {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 24rpx;
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table__exchange-content,
|
||||||
|
.record-table__exchange-type {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0 8rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table--exchange .record-table__header > text:nth-child(1),
|
||||||
|
.record-table__exchange-content {
|
||||||
|
width: 286rpx;
|
||||||
|
flex: 0 0 286rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table--exchange .record-table__header > text:nth-child(2),
|
||||||
|
.record-table__exchange-type {
|
||||||
|
width: 110rpx;
|
||||||
|
flex: 0 0 110rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table--exchange .record-table__header > text:nth-child(3),
|
||||||
|
.record-table__exchange-time {
|
||||||
|
width: 160rpx;
|
||||||
|
flex: 0 0 160rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-table--exchange .record-table__header > text:nth-child(4),
|
||||||
|
.record-table__exchange-amount {
|
||||||
|
width: 110rpx;
|
||||||
|
flex: 0 0 110rpx;
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<script setup>
|
||||||
|
const emit = defineEmits(["authorize"]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="location-state">
|
||||||
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/shootmini/static/coin/location-permission.png"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
<text>授权获取你的定位,以便推荐附近门店。</text>
|
||||||
|
<button hover-class="none" @click="emit('authorize')">立即授权</button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.location-state {
|
||||||
|
width: 100%;
|
||||||
|
padding-top: 190rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 32rpx;
|
||||||
|
line-height: 44rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-state > image {
|
||||||
|
width: 168rpx;
|
||||||
|
height: 190rpx;
|
||||||
|
margin-bottom: 52rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-state > button {
|
||||||
|
width: 360rpx;
|
||||||
|
height: 72rpx;
|
||||||
|
margin-top: 44rpx;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 36rpx;
|
||||||
|
background-color: #ffd947;
|
||||||
|
color: #22222e;
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 72rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-state > button::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
variant: {
|
||||||
|
type: String,
|
||||||
|
default: "gold",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="exchange-notice" :class="`exchange-notice--${variant}`">
|
||||||
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/shootmini/static/coin/icon-notice.png"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
<text>暂不支持线上兑换,请前往线下门店进行兑换。</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.exchange-notice {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 504rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: rgba(255, 255, 255, 0.65);
|
||||||
|
font-size: 20rpx;
|
||||||
|
line-height: 28rpx;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.exchange-notice--gold {
|
||||||
|
border: 2rpx solid rgba(255, 217, 71, 0.28);
|
||||||
|
background-color: rgba(255, 217, 71, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.exchange-notice--red {
|
||||||
|
width: 492rpx;
|
||||||
|
height: 44rpx;
|
||||||
|
margin: 0 0 0 40rpx;
|
||||||
|
border: none;
|
||||||
|
background-color: rgba(255, 96, 96, 0.3);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.exchange-notice > image {
|
||||||
|
width: 24rpx;
|
||||||
|
height: 24rpx;
|
||||||
|
margin-right: 8rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
|
||||||
|
const DEFAULT_PRODUCT_IMAGE =
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/coin/product-hero-item.png";
|
||||||
|
const props = defineProps({
|
||||||
|
images: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const current = ref(0);
|
||||||
|
const slideImages = computed(() => {
|
||||||
|
const images = props.images.filter(
|
||||||
|
(image) => typeof image === "string" && image.trim()
|
||||||
|
);
|
||||||
|
return images.length ? images : [DEFAULT_PRODUCT_IMAGE];
|
||||||
|
});
|
||||||
|
|
||||||
|
const onChange = (event) => {
|
||||||
|
current.value = event.detail.current;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="hero-swiper">
|
||||||
|
<swiper class="hero-swiper__body" :duration="260" @change="onChange">
|
||||||
|
<swiper-item v-for="(image, index) in slideImages" :key="index">
|
||||||
|
<view class="hero-swiper__item">
|
||||||
|
<image
|
||||||
|
class="hero-swiper__background"
|
||||||
|
src="https://static.shelingxingqiu.com/shootmini/static/coin/product-hero-bg.png"
|
||||||
|
mode="scaleToFill"
|
||||||
|
/>
|
||||||
|
<image class="hero-swiper__product" :src="image" mode="aspectFit" />
|
||||||
|
</view>
|
||||||
|
</swiper-item>
|
||||||
|
</swiper>
|
||||||
|
<view class="hero-swiper__dots">
|
||||||
|
<view
|
||||||
|
v-for="(_, index) in slideImages"
|
||||||
|
:key="index"
|
||||||
|
class="hero-swiper__dot"
|
||||||
|
:class="{ 'hero-swiper__dot--active': current === index }"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.hero-swiper,
|
||||||
|
.hero-swiper__body,
|
||||||
|
.hero-swiper__item {
|
||||||
|
position: relative;
|
||||||
|
width: 750rpx;
|
||||||
|
height: 750rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-swiper__background,
|
||||||
|
.hero-swiper__product {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-swiper__dots {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 20rpx;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-swiper__dot {
|
||||||
|
width: 12rpx;
|
||||||
|
height: 12rpx;
|
||||||
|
margin: 0 6rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: rgba(34, 34, 46, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-swiper__dot--active {
|
||||||
|
background-color: #ffd947;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed } from "vue";
|
||||||
|
|
||||||
|
const DEFAULT_PRODUCT_IMAGE =
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/coin/product-hero-bg.png";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
product: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const productImage = computed(() => {
|
||||||
|
const image = props.product?.image;
|
||||||
|
return typeof image === "string" && image.trim()
|
||||||
|
? image
|
||||||
|
: DEFAULT_PRODUCT_IMAGE;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="product-card">
|
||||||
|
<view class="product-card__image-wrap">
|
||||||
|
<image class="product-card__image" :src="productImage" mode="aspectFit" />
|
||||||
|
</view>
|
||||||
|
<text class="product-card__name">{{ product.name }}</text>
|
||||||
|
<view class="product-card__footer">
|
||||||
|
<text>{{ product.cost }}金币</text>
|
||||||
|
<text class="product-card__divider">|</text>
|
||||||
|
<text>剩余{{ product.stock }}个</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.product-card {
|
||||||
|
width: 336rpx;
|
||||||
|
height: 418rpx;
|
||||||
|
padding: 10rpx 10rpx 14rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 2rpx solid rgba(255, 217, 71, 0.1);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background-color: rgba(84, 67, 29, 0.2);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__image-wrap {
|
||||||
|
position: relative;
|
||||||
|
width: 312rpx;
|
||||||
|
height: 312rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__image {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__name {
|
||||||
|
display: block;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
color: #fff0c9;
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 36rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
font-size: 22rpx;
|
||||||
|
line-height: 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__footer > text:first-child {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__footer > text:last-child {
|
||||||
|
color: rgba(255, 255, 255, 0.78);
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__divider {
|
||||||
|
margin: 0 10rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.45);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<script setup>
|
||||||
|
const props = defineProps({
|
||||||
|
store: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["select"]);
|
||||||
|
|
||||||
|
const selectStore = () => {
|
||||||
|
emit("select", props.store);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="store-card" hover-class="none" @click="selectStore">
|
||||||
|
<image class="store-card__photo" :src="store.image" mode="aspectFill" />
|
||||||
|
<text class="store-card__name">{{ store.name }}</text>
|
||||||
|
<view class="store-card__info">
|
||||||
|
<view class="store-card__row">
|
||||||
|
<text>地址:{{ store.address }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="store-card__row">
|
||||||
|
<text>电话:{{ store.phone }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="store-card__row">
|
||||||
|
<text>营业时间:{{ store.hours }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.store-card {
|
||||||
|
width: 650rpx;
|
||||||
|
margin: 22rpx auto 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card__photo {
|
||||||
|
width: 650rpx;
|
||||||
|
height: 324rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card__name {
|
||||||
|
display: block;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
margin-left: 10rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 32rpx;
|
||||||
|
line-height: 44rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card__info {
|
||||||
|
width: 584rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
margin-left: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card__row {
|
||||||
|
margin-top: 0;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
export const quickMenus = [
|
||||||
|
{
|
||||||
|
key: "rules",
|
||||||
|
label: "金币规则",
|
||||||
|
icon: "https://static.shelingxingqiu.com/shootmini/static/coin/icon-rules.png",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "earningRecords",
|
||||||
|
label: "获取明细",
|
||||||
|
icon: "https://static.shelingxingqiu.com/shootmini/static/coin/icon-earning-records.png",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "exchangeRecords",
|
||||||
|
label: "兑换记录",
|
||||||
|
icon: "https://static.shelingxingqiu.com/shootmini/static/coin/icon-exchange-records.png",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "nearbyStores",
|
||||||
|
label: "附近门店",
|
||||||
|
icon: "https://static.shelingxingqiu.com/shootmini/static/coin/icon-nearby-store.png",
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import CoinHeader from "./components/CoinHeader.vue";
|
||||||
|
import CoinRecordList from "./components/CoinRecordList.vue";
|
||||||
|
import CoinEmptyState from "./components/CoinEmptyState.vue";
|
||||||
|
import { getGoldLogAPI } from "@/apis";
|
||||||
|
|
||||||
|
const PAGE_SIZE = 20;
|
||||||
|
const storeId = ref("");
|
||||||
|
const earningRecords = ref([]);
|
||||||
|
const page = ref(0);
|
||||||
|
const total = ref(0);
|
||||||
|
const loading = ref(false);
|
||||||
|
const noMore = ref(false);
|
||||||
|
const loaded = ref(false);
|
||||||
|
const showEmpty = computed(() => loaded.value && !earningRecords.value.length);
|
||||||
|
|
||||||
|
const formatRecord = (item = {}) => {
|
||||||
|
const [date = "", time = ""] = String(item.createdAt || "").split(" ");
|
||||||
|
const amount = Number(item.amount) || 0;
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
date,
|
||||||
|
time,
|
||||||
|
type: item.remark || item.typeDesc || "-",
|
||||||
|
amount: amount > 0 ? `+${amount}` : String(amount),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 实际接口返回 totalCount/pageCount/pageSize,同时兼容接口文档中的旧字段。
|
||||||
|
const updatePaginationState = (result, list, nextPage) => {
|
||||||
|
const currentPage = Number(result?.page) || nextPage;
|
||||||
|
const pageCount = Number(result?.pageCount);
|
||||||
|
const totalCount = Number(result?.totalCount ?? result?.total);
|
||||||
|
const responsePageSize = Number(result?.pageSize ?? result?.perPage) || PAGE_SIZE;
|
||||||
|
|
||||||
|
page.value = currentPage;
|
||||||
|
total.value = Number.isFinite(totalCount) ? totalCount : 0;
|
||||||
|
|
||||||
|
if (Number.isFinite(pageCount) && pageCount >= 0) {
|
||||||
|
noMore.value = currentPage >= pageCount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Number.isFinite(totalCount) && totalCount >= 0) {
|
||||||
|
noMore.value = earningRecords.value.length >= totalCount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noMore.value = list.length < responsePageSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadRecords = async ({ reset = false } = {}) => {
|
||||||
|
if (loading.value || (!reset && noMore.value)) return;
|
||||||
|
|
||||||
|
const nextPage = reset ? 1 : page.value + 1;
|
||||||
|
loading.value = true;
|
||||||
|
if (reset) noMore.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getGoldLogAPI({
|
||||||
|
page: nextPage,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
type: 1,
|
||||||
|
storeId: storeId.value,
|
||||||
|
});
|
||||||
|
const list = Array.isArray(result?.list) ? result.list : [];
|
||||||
|
const mappedList = list.map(formatRecord);
|
||||||
|
earningRecords.value = reset
|
||||||
|
? mappedList
|
||||||
|
: earningRecords.value.concat(mappedList);
|
||||||
|
updatePaginationState(result, list, nextPage);
|
||||||
|
} catch (error) {
|
||||||
|
if (reset) {
|
||||||
|
earningRecords.value = [];
|
||||||
|
page.value = 0;
|
||||||
|
}
|
||||||
|
console.error("加载金币获取明细失败", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
loaded.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad((options = {}) => {
|
||||||
|
const currentStoreId = String(options.storeId || "");
|
||||||
|
if (!/^\d+$/.test(currentStoreId) || Number(currentStoreId) <= 0) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/coin/nearby-stores",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storeId.value = currentStoreId;
|
||||||
|
loadRecords({ reset: true });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :bgType="6" :isHome="true" @scrolltolower="loadRecords">
|
||||||
|
<template #header>
|
||||||
|
<CoinHeader title="金币获取明细" />
|
||||||
|
</template>
|
||||||
|
<view class="records-page">
|
||||||
|
<CoinEmptyState v-if="showEmpty" />
|
||||||
|
<CoinRecordList v-else :records="earningRecords" />
|
||||||
|
<view
|
||||||
|
v-if="loading || (noMore && earningRecords.length)"
|
||||||
|
class="records-page__status"
|
||||||
|
>
|
||||||
|
<text>{{ loading ? "加载中..." : "没有更多了" }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.records-page {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.records-page__status {
|
||||||
|
padding: 24rpx 0 32rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import CoinHeader from "./components/CoinHeader.vue";
|
||||||
|
import CoinRecordList from "./components/CoinRecordList.vue";
|
||||||
|
import CoinEmptyState from "./components/CoinEmptyState.vue";
|
||||||
|
import { getGoldLogAPI } from "@/apis";
|
||||||
|
|
||||||
|
const PAGE_SIZE = 20;
|
||||||
|
const storeId = ref("");
|
||||||
|
const exchangeRecords = ref([]);
|
||||||
|
const page = ref(0);
|
||||||
|
const total = ref(0);
|
||||||
|
const loading = ref(false);
|
||||||
|
const noMore = ref(false);
|
||||||
|
const loaded = ref(false);
|
||||||
|
const showEmpty = computed(() => loaded.value && !exchangeRecords.value.length);
|
||||||
|
|
||||||
|
const formatRecord = (item = {}) => {
|
||||||
|
const [date = "", time = ""] = String(item.createdAt || "").split(" ");
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
content: item.remark || "-",
|
||||||
|
type: item.typeDesc || "-",
|
||||||
|
date,
|
||||||
|
time,
|
||||||
|
amount: String(Number(item.amount) || 0),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 实际接口返回 totalCount/pageCount/pageSize,同时兼容接口文档中的旧字段。
|
||||||
|
const updatePaginationState = (result, list, nextPage) => {
|
||||||
|
const currentPage = Number(result?.page) || nextPage;
|
||||||
|
const pageCount = Number(result?.pageCount);
|
||||||
|
const totalCount = Number(result?.totalCount ?? result?.total);
|
||||||
|
const responsePageSize = Number(result?.pageSize ?? result?.perPage) || PAGE_SIZE;
|
||||||
|
|
||||||
|
page.value = currentPage;
|
||||||
|
total.value = Number.isFinite(totalCount) ? totalCount : 0;
|
||||||
|
|
||||||
|
if (Number.isFinite(pageCount) && pageCount >= 0) {
|
||||||
|
noMore.value = currentPage >= pageCount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Number.isFinite(totalCount) && totalCount >= 0) {
|
||||||
|
noMore.value = exchangeRecords.value.length >= totalCount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noMore.value = list.length < responsePageSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadRecords = async ({ reset = false } = {}) => {
|
||||||
|
if (loading.value || (!reset && noMore.value)) return;
|
||||||
|
|
||||||
|
const nextPage = reset ? 1 : page.value + 1;
|
||||||
|
loading.value = true;
|
||||||
|
if (reset) noMore.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getGoldLogAPI({
|
||||||
|
page: nextPage,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
type: 2,
|
||||||
|
storeId: storeId.value,
|
||||||
|
});
|
||||||
|
const list = Array.isArray(result?.list) ? result.list : [];
|
||||||
|
const mappedList = list.map(formatRecord);
|
||||||
|
exchangeRecords.value = reset
|
||||||
|
? mappedList
|
||||||
|
: exchangeRecords.value.concat(mappedList);
|
||||||
|
updatePaginationState(result, list, nextPage);
|
||||||
|
} catch (error) {
|
||||||
|
if (reset) {
|
||||||
|
exchangeRecords.value = [];
|
||||||
|
page.value = 0;
|
||||||
|
}
|
||||||
|
console.error("加载金币兑换记录失败", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
loaded.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad((options = {}) => {
|
||||||
|
const currentStoreId = String(options.storeId || "");
|
||||||
|
if (!/^\d+$/.test(currentStoreId) || Number(currentStoreId) <= 0) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/coin/nearby-stores",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storeId.value = currentStoreId;
|
||||||
|
loadRecords({ reset: true });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :bgType="6" :isHome="true" @scrolltolower="loadRecords">
|
||||||
|
<template #header>
|
||||||
|
<CoinHeader title="金币兑换记录" />
|
||||||
|
</template>
|
||||||
|
<view class="records-page">
|
||||||
|
<CoinEmptyState v-if="showEmpty" text="暂无金币兑换记录。" />
|
||||||
|
<CoinRecordList v-else mode="exchange" :records="exchangeRecords" />
|
||||||
|
<view
|
||||||
|
v-if="loading || (noMore && exchangeRecords.length)"
|
||||||
|
class="records-page__status"
|
||||||
|
>
|
||||||
|
<text>{{ loading ? "加载中..." : "没有更多了" }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.records-page {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.records-page__status {
|
||||||
|
padding: 24rpx 0 32rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import CoinHeader from "./components/CoinHeader.vue";
|
||||||
|
import CoinBalancePanel from "./components/CoinBalancePanel.vue";
|
||||||
|
import CoinQuickMenu from "./components/CoinQuickMenu.vue";
|
||||||
|
import OfflineExchangeNotice from "./components/OfflineExchangeNotice.vue";
|
||||||
|
import RewardProductCard from "./components/RewardProductCard.vue";
|
||||||
|
import { getGiftListAPI, getMyGoldAPI } from "@/apis";
|
||||||
|
import { quickMenus } from "./data";
|
||||||
|
|
||||||
|
const PAGE_SIZE = 20;
|
||||||
|
const coinSummary = ref({
|
||||||
|
cumulative: 0,
|
||||||
|
available: 0,
|
||||||
|
});
|
||||||
|
const selectedStoreId = ref("");
|
||||||
|
const selectedStoreName = ref("");
|
||||||
|
const rewardProducts = ref([]);
|
||||||
|
const productPage = ref(0);
|
||||||
|
const productTotal = ref(0);
|
||||||
|
const productLoading = ref(false);
|
||||||
|
const productNoMore = ref(false);
|
||||||
|
|
||||||
|
const loadCoinSummary = async () => {
|
||||||
|
try {
|
||||||
|
const result = await getMyGoldAPI(selectedStoreId.value);
|
||||||
|
coinSummary.value = {
|
||||||
|
cumulative: Number(result?.totalGold) || 0,
|
||||||
|
available: Number(result?.usableGold) || 0,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载金币统计失败", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadProducts = async ({ reset = false } = {}) => {
|
||||||
|
if (productLoading.value || (!reset && productNoMore.value)) return;
|
||||||
|
|
||||||
|
const nextPage = reset ? 1 : productPage.value + 1;
|
||||||
|
productLoading.value = true;
|
||||||
|
if (reset) productNoMore.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getGiftListAPI({
|
||||||
|
page: nextPage,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
storeId: selectedStoreId.value,
|
||||||
|
});
|
||||||
|
const list = Array.isArray(result?.list) ? result.list : [];
|
||||||
|
const mappedList = list.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.name || "",
|
||||||
|
cost: Number(item.coin_price) || 0,
|
||||||
|
stock: Number(item.stock) || 0,
|
||||||
|
image: item.cover_image || "",
|
||||||
|
}));
|
||||||
|
|
||||||
|
rewardProducts.value = reset
|
||||||
|
? mappedList
|
||||||
|
: rewardProducts.value.concat(mappedList);
|
||||||
|
productPage.value = Number(result?.page) || nextPage;
|
||||||
|
const pageCount = Number(result?.pageCount ?? result?.page_count);
|
||||||
|
const totalCount = Number(result?.totalCount ?? result?.total);
|
||||||
|
const responsePageSize =
|
||||||
|
Number(result?.pageSize ?? result?.page_size) || PAGE_SIZE;
|
||||||
|
productTotal.value = Number.isFinite(totalCount) ? totalCount : 0;
|
||||||
|
|
||||||
|
if (Number.isFinite(pageCount) && pageCount >= 0) {
|
||||||
|
productNoMore.value = productPage.value >= pageCount;
|
||||||
|
} else if (Number.isFinite(totalCount) && totalCount >= 0) {
|
||||||
|
productNoMore.value = rewardProducts.value.length >= totalCount;
|
||||||
|
} else {
|
||||||
|
productNoMore.value = list.length < responsePageSize;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (reset) {
|
||||||
|
rewardProducts.value = [];
|
||||||
|
productPage.value = 0;
|
||||||
|
}
|
||||||
|
console.error("加载礼品列表失败", error);
|
||||||
|
} finally {
|
||||||
|
productLoading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const menuRoutes = {
|
||||||
|
rules: "/pages/coin/rules",
|
||||||
|
earningRecords: "/pages/coin/earning-records",
|
||||||
|
exchangeRecords: "/pages/coin/exchange-records",
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildStorePageUrl = (path, extraQuery = "") => {
|
||||||
|
const query = [
|
||||||
|
`storeId=${encodeURIComponent(selectedStoreId.value)}`,
|
||||||
|
`storeName=${encodeURIComponent(selectedStoreName.value)}`,
|
||||||
|
extraQuery,
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join("&");
|
||||||
|
return `${path}?${query}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const decodeRouteText = (value = "") => {
|
||||||
|
const text = String(value);
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(text.replace(/\+/g, " "));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("门店名称解码失败", error);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onMenuSelect = (menu) => {
|
||||||
|
if (menu.key === "nearbyStores") {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/coin/nearby-stores",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = menuRoutes[menu.key];
|
||||||
|
if (!url) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "功能开发中",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uni.navigateTo({
|
||||||
|
url: buildStorePageUrl(url),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toProductDetail = (product) => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: buildStorePageUrl(
|
||||||
|
"/pages/coin/product-detail",
|
||||||
|
`id=${encodeURIComponent(product.id)}`
|
||||||
|
),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad((options = {}) => {
|
||||||
|
const storeId = String(options.storeId || "");
|
||||||
|
if (!/^\d+$/.test(storeId) || Number(storeId) <= 0) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/coin/nearby-stores",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedStoreId.value = storeId;
|
||||||
|
selectedStoreName.value = decodeRouteText(options.storeName);
|
||||||
|
loadCoinSummary();
|
||||||
|
loadProducts({ reset: true });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :bgType="6" :isHome="true" @scrolltolower="loadProducts">
|
||||||
|
<template #header>
|
||||||
|
<CoinHeader title="我的金币" :subtitle="selectedStoreName" />
|
||||||
|
</template>
|
||||||
|
<view class="coin-page">
|
||||||
|
<CoinBalancePanel
|
||||||
|
:cumulative="coinSummary.cumulative"
|
||||||
|
:available="coinSummary.available"
|
||||||
|
/>
|
||||||
|
<CoinQuickMenu :menus="quickMenus" @select="onMenuSelect" />
|
||||||
|
<OfflineExchangeNotice />
|
||||||
|
<view class="reward-section">
|
||||||
|
<view class="reward-grid">
|
||||||
|
<view
|
||||||
|
v-for="product in rewardProducts"
|
||||||
|
:key="product.id"
|
||||||
|
class="reward-grid__item"
|
||||||
|
@click="toProductDetail(product)"
|
||||||
|
>
|
||||||
|
<RewardProductCard :product="product" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.coin-page {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
padding-bottom: 40rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reward-section {
|
||||||
|
padding: 20rpx 28rpx 40rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reward-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reward-grid__item {
|
||||||
|
width: 336rpx;
|
||||||
|
margin-right: 22rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reward-grid__item:nth-child(2n) {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import CoinHeader from "./components/CoinHeader.vue";
|
||||||
|
import LocationPermissionState from "./components/LocationPermissionState.vue";
|
||||||
|
import StoreCard from "./components/StoreCard.vue";
|
||||||
|
import { getNearbyStoresAPI } from "@/apis";
|
||||||
|
|
||||||
|
const PAGE_SIZE = 20;
|
||||||
|
const DEFAULT_STORE_IMAGE =
|
||||||
|
"https://static.shelingxingqiu.com/shootmini/static/coin/store-photo.png";
|
||||||
|
const showPermissionState = ref(false);
|
||||||
|
const stores = ref([]);
|
||||||
|
const location = ref(null);
|
||||||
|
const page = ref(0);
|
||||||
|
const total = ref(0);
|
||||||
|
const loading = ref(false);
|
||||||
|
const noMore = ref(false);
|
||||||
|
const loaded = ref(false);
|
||||||
|
|
||||||
|
const getCurrentLocation = () =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
uni.getLocation({
|
||||||
|
type: "gcj02",
|
||||||
|
success: resolve,
|
||||||
|
fail: reject,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapStore = (item = {}) => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.name || "",
|
||||||
|
address: item.address || "",
|
||||||
|
phone: item.phone || "",
|
||||||
|
hours: item.businessHours || "",
|
||||||
|
image: item.coverImage || DEFAULT_STORE_IMAGE,
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadStores = async ({ reset = false } = {}) => {
|
||||||
|
if (!location.value || loading.value || (!reset && noMore.value)) return;
|
||||||
|
|
||||||
|
const nextPage = reset ? 1 : page.value + 1;
|
||||||
|
loading.value = true;
|
||||||
|
if (reset) noMore.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getNearbyStoresAPI({
|
||||||
|
...location.value,
|
||||||
|
page: nextPage,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
});
|
||||||
|
const list = Array.isArray(result?.list) ? result.list : [];
|
||||||
|
const mappedList = list.map(mapStore);
|
||||||
|
stores.value = reset ? mappedList : stores.value.concat(mappedList);
|
||||||
|
page.value = Number(result?.page) || nextPage;
|
||||||
|
const pageCount = Number(result?.pageCount);
|
||||||
|
const totalCount = Number(result?.totalCount ?? result?.total);
|
||||||
|
const responsePageSize = Number(result?.pageSize) || PAGE_SIZE;
|
||||||
|
total.value = Number.isFinite(totalCount) ? totalCount : 0;
|
||||||
|
|
||||||
|
if (Number.isFinite(pageCount) && pageCount >= 0) {
|
||||||
|
noMore.value = page.value >= pageCount;
|
||||||
|
} else if (Number.isFinite(totalCount) && totalCount >= 0) {
|
||||||
|
noMore.value = stores.value.length >= totalCount;
|
||||||
|
} else {
|
||||||
|
noMore.value = list.length < responsePageSize;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (reset) {
|
||||||
|
stores.value = [];
|
||||||
|
page.value = 0;
|
||||||
|
}
|
||||||
|
console.error("加载附近门店失败", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
loaded.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const locateAndLoadStores = async () => {
|
||||||
|
try {
|
||||||
|
const position = await getCurrentLocation();
|
||||||
|
location.value = {
|
||||||
|
longitude: position.longitude,
|
||||||
|
latitude: position.latitude,
|
||||||
|
};
|
||||||
|
showPermissionState.value = false;
|
||||||
|
await loadStores({ reset: true });
|
||||||
|
} catch (error) {
|
||||||
|
showPermissionState.value = true;
|
||||||
|
loaded.value = true;
|
||||||
|
console.error("获取定位失败", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const authorizeLocation = () => {
|
||||||
|
uni.openSetting({
|
||||||
|
success: locateAndLoadStores,
|
||||||
|
fail: locateAndLoadStores,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 选择门店后替换当前页面,返回时直接回到进入金币模块前的页面。
|
||||||
|
const selectStore = (store) => {
|
||||||
|
const storeId = String(store?.id || "");
|
||||||
|
if (!/^\d+$/.test(storeId) || Number(storeId) <= 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "门店信息无效",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const storeName = encodeURIComponent(store?.name || "");
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/coin/index?storeId=${encodeURIComponent(storeId)}&storeName=${storeName}`,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad(locateAndLoadStores);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :bgType="6" :isHome="true" @scrolltolower="loadStores">
|
||||||
|
<template #header>
|
||||||
|
<CoinHeader title="附近门店" />
|
||||||
|
</template>
|
||||||
|
<view class="stores-page">
|
||||||
|
<LocationPermissionState
|
||||||
|
v-if="showPermissionState"
|
||||||
|
@authorize="authorizeLocation"
|
||||||
|
/>
|
||||||
|
<template v-else>
|
||||||
|
<StoreCard
|
||||||
|
v-for="store in stores"
|
||||||
|
:key="store.id"
|
||||||
|
:store="store"
|
||||||
|
@select="selectStore"
|
||||||
|
/>
|
||||||
|
<text v-if="loaded && !stores.length" class="stores-page__more">
|
||||||
|
附近暂无门店~
|
||||||
|
</text>
|
||||||
|
<text v-else-if="noMore" class="stores-page__more">没有更多门店了~</text>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.stores-page {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
padding-bottom: 54rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stores-page__more {
|
||||||
|
display: block;
|
||||||
|
width: 650rpx;
|
||||||
|
margin: 26rpx auto 0;
|
||||||
|
color: rgba(255, 255, 255, 0.72);
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 36rpx;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import CoinHeader from "./components/CoinHeader.vue";
|
||||||
|
import ProductHeroSwiper from "./components/ProductHeroSwiper.vue";
|
||||||
|
import OfflineExchangeNotice from "./components/OfflineExchangeNotice.vue";
|
||||||
|
import { getGiftDetailAPI } from "@/apis";
|
||||||
|
|
||||||
|
const productDetail = ref({
|
||||||
|
name: "",
|
||||||
|
coinPrice: 0,
|
||||||
|
stock: 0,
|
||||||
|
images: [],
|
||||||
|
descriptions: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadProductDetail = async (id) => {
|
||||||
|
try {
|
||||||
|
const result = await getGiftDetailAPI(id);
|
||||||
|
const images = Array.isArray(result?.images)
|
||||||
|
? result.images
|
||||||
|
.slice()
|
||||||
|
.sort((first, second) =>
|
||||||
|
(Number(first?.sort_order) || 0) - (Number(second?.sort_order) || 0)
|
||||||
|
)
|
||||||
|
.map((item) => item?.image_url)
|
||||||
|
.filter(Boolean)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
productDetail.value = {
|
||||||
|
...productDetail.value,
|
||||||
|
name: result?.name || "",
|
||||||
|
coinPrice: Number(result?.coin_price) || 0,
|
||||||
|
stock: Number(result?.stock) || 0,
|
||||||
|
images,
|
||||||
|
descriptions: result?.description
|
||||||
|
? String(result.description).split(/\r?\n/).filter(Boolean)
|
||||||
|
: [],
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载礼品详情失败", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad((options = {}) => {
|
||||||
|
const id = Number(options.id);
|
||||||
|
if (!Number.isInteger(id) || id <= 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "商品参数无效",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadProductDetail(id);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :bgType="6" :isHome="true">
|
||||||
|
<template #header>
|
||||||
|
<CoinHeader title="商品详情" />
|
||||||
|
</template>
|
||||||
|
<view class="product-detail">
|
||||||
|
<ProductHeroSwiper
|
||||||
|
:images="productDetail.images"
|
||||||
|
/>
|
||||||
|
<view class="product-detail__summary">
|
||||||
|
<text class="product-detail__name">{{ productDetail.name }}</text>
|
||||||
|
<view class="product-detail__balance">
|
||||||
|
<text>金币:</text>
|
||||||
|
<text class="product-detail__amount">{{ productDetail.coinPrice }}</text>
|
||||||
|
<text>(剩余{{ productDetail.stock }}个)</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<OfflineExchangeNotice variant="red" />
|
||||||
|
<view class="product-detail__content">
|
||||||
|
<text
|
||||||
|
v-for="(description, index) in productDetail.descriptions"
|
||||||
|
:key="index"
|
||||||
|
class="product-detail__paragraph"
|
||||||
|
>
|
||||||
|
{{ description }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.product-detail {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
padding-bottom: 60rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: #22222e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-detail__summary {
|
||||||
|
padding: 30rpx 40rpx 20rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-detail__name {
|
||||||
|
color: #ffd947;
|
||||||
|
font-size: 52rpx;
|
||||||
|
line-height: 74rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-detail__balance {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-detail__amount {
|
||||||
|
margin-right: 6rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 36rpx;
|
||||||
|
line-height: 50rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-detail__content {
|
||||||
|
padding: 38rpx 40rpx 60rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-bottom: 2rpx solid rgba(255, 217, 71, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-detail__paragraph {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import CoinHeader from "./components/CoinHeader.vue";
|
||||||
|
import CoinEmptyState from "./components/CoinEmptyState.vue";
|
||||||
|
import { getStoreGoldRuleListAPI } from "@/apis";
|
||||||
|
|
||||||
|
const PAGE_SIZE = 20;
|
||||||
|
const storeId = ref("");
|
||||||
|
const coinRules = ref([]);
|
||||||
|
const page = ref(0);
|
||||||
|
const loading = ref(false);
|
||||||
|
const noMore = ref(false);
|
||||||
|
const loaded = ref(false);
|
||||||
|
const showEmpty = computed(() => loaded.value && !coinRules.value.length);
|
||||||
|
|
||||||
|
const updatePaginationState = (result, list, nextPage) => {
|
||||||
|
const currentPage = Number(result?.page) || nextPage;
|
||||||
|
const pageCount = Number(result?.pageCount ?? result?.page_count);
|
||||||
|
const totalCount = Number(result?.totalCount ?? result?.total);
|
||||||
|
const responsePageSize =
|
||||||
|
Number(result?.pageSize ?? result?.page_size) || PAGE_SIZE;
|
||||||
|
|
||||||
|
page.value = currentPage;
|
||||||
|
if (Number.isFinite(pageCount) && pageCount >= 0) {
|
||||||
|
noMore.value = currentPage >= pageCount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Number.isFinite(totalCount) && totalCount >= 0) {
|
||||||
|
noMore.value = coinRules.value.length >= totalCount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noMore.value = list.length < responsePageSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadRules = async ({ reset = false } = {}) => {
|
||||||
|
if (loading.value || (!reset && noMore.value)) return;
|
||||||
|
|
||||||
|
const nextPage = reset ? 1 : page.value + 1;
|
||||||
|
loading.value = true;
|
||||||
|
if (reset) noMore.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getStoreGoldRuleListAPI({
|
||||||
|
storeId: storeId.value,
|
||||||
|
page: nextPage,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
});
|
||||||
|
const list = Array.isArray(result?.list) ? result.list : [];
|
||||||
|
const mappedList = list.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
content: item.content || "",
|
||||||
|
}));
|
||||||
|
|
||||||
|
coinRules.value = reset ? mappedList : coinRules.value.concat(mappedList);
|
||||||
|
updatePaginationState(result, list, nextPage);
|
||||||
|
} catch (error) {
|
||||||
|
if (reset) {
|
||||||
|
coinRules.value = [];
|
||||||
|
page.value = 0;
|
||||||
|
}
|
||||||
|
console.error("加载金币规则失败", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
loaded.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad((options = {}) => {
|
||||||
|
const currentStoreId = String(options.storeId || "");
|
||||||
|
if (!/^\d+$/.test(currentStoreId) || Number(currentStoreId) <= 0) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/coin/nearby-stores",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storeId.value = currentStoreId;
|
||||||
|
loadRules({ reset: true });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :bgType="6" :isHome="true" @scrolltolower="loadRules">
|
||||||
|
<template #header>
|
||||||
|
<CoinHeader title="金币规则" />
|
||||||
|
</template>
|
||||||
|
<view class="rules-page">
|
||||||
|
<CoinEmptyState v-if="showEmpty" text="暂无金币规则。" />
|
||||||
|
<template v-else>
|
||||||
|
<view
|
||||||
|
v-for="rule in coinRules"
|
||||||
|
:key="rule.id"
|
||||||
|
class="rules-page__item"
|
||||||
|
>
|
||||||
|
<rich-text class="rules-page__content" :nodes="rule.content" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<view v-if="loading" class="rules-page__status">
|
||||||
|
<text>加载中...</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.rules-page {
|
||||||
|
width: 100%;
|
||||||
|
padding: 28rpx 38rpx 60rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rules-page__item {
|
||||||
|
margin-bottom: 26rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.88);
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 52rpx;
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rules-page__content {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rules-page__status {
|
||||||
|
padding: 12rpx 0 20rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -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>
|
||||||
@@ -22,7 +22,12 @@ import {
|
|||||||
} from "@/apis";
|
} from "@/apis";
|
||||||
import { connectMatchWebSocket, closeMatchWebSocket } from "@/matchWebsocket";
|
import { connectMatchWebSocket, closeMatchWebSocket } from "@/matchWebsocket";
|
||||||
import { sharePractiseData } from "@/canvas";
|
import { sharePractiseData } from "@/canvas";
|
||||||
import { wxShare, debounce } from "@/util";
|
import {
|
||||||
|
wxShare,
|
||||||
|
debounce,
|
||||||
|
getDistanceCheckAudioKey,
|
||||||
|
getShootValidation,
|
||||||
|
} from "@/util";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -109,7 +114,7 @@ const createPractise = async (arrows) => {
|
|||||||
const result = await createPractiseAPI(
|
const result = await createPractiseAPI(
|
||||||
arrows,
|
arrows,
|
||||||
120,
|
120,
|
||||||
1,
|
2,
|
||||||
device.value.deviceId
|
device.value.deviceId
|
||||||
);
|
);
|
||||||
if (result) practiseId.value = result.id;
|
if (result) practiseId.value = result.id;
|
||||||
@@ -154,11 +159,11 @@ async function onReceiveMessage(msg) {
|
|||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||||
setTimeout(() => onOver(msg), 1500);
|
setTimeout(() => onOver(msg), 1500);
|
||||||
} else if (msg.type === MESSAGETYPESV2.TestDistance && step.value === 3) {
|
} else if (msg.type === MESSAGETYPESV2.TestDistance && step.value === 3) {
|
||||||
if (msg.shootData.distance / 100 >= 5) {
|
const result = getShootValidation(msg.shootData);
|
||||||
audioManager.play("距离合格");
|
const isQualified = result.distanceOk && result.targetOk;
|
||||||
btnDisabled.value = false;
|
audioManager.play(getDistanceCheckAudioKey(msg.shootData));
|
||||||
showGuide.value = true;
|
btnDisabled.value = !isQualified;
|
||||||
} else audioManager.play("距离不足");
|
showGuide.value = isQualified;
|
||||||
}
|
}
|
||||||
// messages.forEach((msg) => {
|
// messages.forEach((msg) => {
|
||||||
// if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
// if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||||
@@ -192,7 +197,7 @@ const onClickShare = debounce(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void audioManager.warmAll();
|
void audioManager.warmCommon();
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
@@ -379,7 +384,7 @@ const getResultTipSrc = (result = {}) => {
|
|||||||
<text>请完成以上步骤校准智能弓</text>
|
<text>请完成以上步骤校准智能弓</text>
|
||||||
</view>
|
</view>
|
||||||
<ShootProgress v-if="step === 5" tips="请开始连续射箭" :start="start" />
|
<ShootProgress v-if="step === 5" tips="请开始连续射箭" :start="start" />
|
||||||
<TestDistance v-if="step === 3" :guide="false" />
|
<TestDistance v-if="step === 3" :guide="false" :targetType="40" />
|
||||||
<view
|
<view
|
||||||
class="user-row"
|
class="user-row"
|
||||||
v-if="step === 5"
|
v-if="step === 5"
|
||||||
@@ -394,6 +399,8 @@ const getResultTipSrc = (result = {}) => {
|
|||||||
:totalRound="step === 5 ? total : 0"
|
:totalRound="step === 5 ? total : 0"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
:isSvip="isSvip"
|
:isSvip="isSvip"
|
||||||
|
:targetType="40"
|
||||||
|
stable-shot-effect
|
||||||
/>
|
/>
|
||||||
<ScorePanel
|
<ScorePanel
|
||||||
v-if="step === 5"
|
v-if="step === 5"
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -28,6 +29,7 @@ const { user, online } = storeToRefs(store);
|
|||||||
const title = ref("");
|
const title = ref("");
|
||||||
const start = ref(null);
|
const start = ref(null);
|
||||||
const battleId = ref("");
|
const battleId = ref("");
|
||||||
|
const targetType = ref(20);
|
||||||
/** 对战模式:1=好友约战 2=排位赛,用于结算页跳转判断 */
|
/** 对战模式:1=好友约战 2=排位赛,用于结算页跳转判断 */
|
||||||
const way = ref(0);
|
const way = ref(0);
|
||||||
const currentRound = ref(1);
|
const currentRound = ref(1);
|
||||||
@@ -253,6 +255,8 @@ watch(online, (newVal, oldVal) => {
|
|||||||
function recoverData(battleInfo, { force = false } = {}) {
|
function recoverData(battleInfo, { force = false } = {}) {
|
||||||
battleInfo = normalizeBattleInfo(battleInfo);
|
battleInfo = normalizeBattleInfo(battleInfo);
|
||||||
if (!battleInfo) return;
|
if (!battleInfo) return;
|
||||||
|
const nextTargetType = Number(battleInfo.targetType ?? battleInfo.target_type);
|
||||||
|
if ([20, 40].includes(nextTargetType)) targetType.value = nextTargetType;
|
||||||
if (battleInfo.status !== undefined) {
|
if (battleInfo.status !== undefined) {
|
||||||
battleEnded = [2, 4].includes(Number(battleInfo.status));
|
battleEnded = [2, 4].includes(Number(battleInfo.status));
|
||||||
}
|
}
|
||||||
@@ -373,6 +377,7 @@ function onMatchSocketState(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
|
targetType.value = 20;
|
||||||
const returnSnapshot = options.fromReturn ? takeMatchReturnSnapshot() : null;
|
const returnSnapshot = options.fromReturn ? takeMatchReturnSnapshot() : null;
|
||||||
skipNextRestoreOnShow = false;
|
skipNextRestoreOnShow = false;
|
||||||
if (returnSnapshot?.matchId) battleId.value = returnSnapshot.matchId;
|
if (returnSnapshot?.matchId) battleId.value = returnSnapshot.matchId;
|
||||||
@@ -467,6 +472,7 @@ onShow(() => {
|
|||||||
:guide="false"
|
:guide="false"
|
||||||
:isBattle="true"
|
:isBattle="true"
|
||||||
:count="readyTime"
|
:count="readyTime"
|
||||||
|
:targetType="targetType"
|
||||||
/>
|
/>
|
||||||
<ShootProgress
|
<ShootProgress
|
||||||
:show="start"
|
:show="start"
|
||||||
@@ -489,8 +495,9 @@ 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"
|
:targetType="targetType"
|
||||||
: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>
|
||||||
|
|||||||
@@ -1,25 +1,61 @@
|
|||||||
<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 trainingType = computed(() =>
|
||||||
|
String(practiseDetail.value.trainingType || "").trim().toLowerCase()
|
||||||
|
);
|
||||||
|
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 +71,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>{{ practiseDetail.trainingTypeText }}</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 +106,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;
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ const matchList = ref([]);
|
|||||||
const battleList = ref([]);
|
const battleList = ref([]);
|
||||||
const practiseList = ref([]);
|
const practiseList = ref([]);
|
||||||
|
|
||||||
|
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({
|
||||||
url: `/pages/match-detail?battleId=${id}`,
|
url: `/pages/match-detail?battleId=${id}`,
|
||||||
@@ -81,7 +89,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 +161,8 @@ onLoad((options) => {
|
|||||||
@click="() => getPractiseDetail(item.id)"
|
@click="() => getPractiseDetail(item.id)"
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
>{{ item.completed_arrows === 36 ? "耐力挑战" : "单组练习" }}
|
>{{ item.trainingTypeText }}
|
||||||
{{ 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,306 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import Signin from "@/components/Signin.vue";
|
||||||
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import AppBackground from "@/components/AppBackground.vue";
|
||||||
|
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
|
||||||
|
import { tempBindOrgAPI } from "@/apis";
|
||||||
|
import useStore from "@/store";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
|
||||||
|
const store = useStore();
|
||||||
|
const { user } = storeToRefs(store);
|
||||||
|
|
||||||
|
const scene = ref("");
|
||||||
|
const status = ref("idle");
|
||||||
|
const errorMessage = ref("");
|
||||||
|
const showSignin = ref(false);
|
||||||
|
const binding = ref(false);
|
||||||
|
const bindInfo = ref({});
|
||||||
|
|
||||||
|
const successInfo = computed(() => {
|
||||||
|
const result = bindInfo.value || {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
avatar: user.value.avatar,
|
||||||
|
nickName: user.value.nickName || "--",
|
||||||
|
mobile: result.mobile || "--",
|
||||||
|
storeName: result.storeName || "--",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
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 = "";
|
||||||
|
bindInfo.value = {};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = (await tempBindOrgAPI(scene.value)) || {};
|
||||||
|
if (result.success !== true) {
|
||||||
|
status.value = "failed";
|
||||||
|
errorMessage.value = result.msg || "授权登录失败,请稍后重试。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bindInfo.value = result;
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
|
||||||
|
const goHome = () => {
|
||||||
|
uni.reLaunch({ url: "/pages/index" });
|
||||||
|
};
|
||||||
|
|
||||||
|
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">
|
||||||
|
<AppBackground :type="6" bgColor="#20202c" />
|
||||||
|
|
||||||
|
<view class="content">
|
||||||
|
<text class="title">登录门店Pad端</text>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="status === 'idle' || status === 'binding'"
|
||||||
|
class="state message-state"
|
||||||
|
>
|
||||||
|
<text class="state-title">正在授权登录</text>
|
||||||
|
<text class="description">正在登录门店Pad端,请稍候……</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="status === 'login'" class="state login-state">
|
||||||
|
<image
|
||||||
|
class="login-icon"
|
||||||
|
src="../static/org-bind/login-icon.png"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
<text class="login-title">{{
|
||||||
|
errorMessage || "请先登录小程序"
|
||||||
|
}}</text>
|
||||||
|
<SButton width="600rpx" :rounded="22" :onClick="openSignin">
|
||||||
|
<text>微信授权登录</text>
|
||||||
|
</SButton>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="status === 'success'" class="state success-state">
|
||||||
|
<view class="avatar-wrap">
|
||||||
|
<Avatar
|
||||||
|
:src="successInfo.avatar"
|
||||||
|
:size="176"
|
||||||
|
sizeUnit="rpx"
|
||||||
|
imageMode="aspectFill"
|
||||||
|
/>
|
||||||
|
<image
|
||||||
|
class="success-badge"
|
||||||
|
src="../static/org-bind/green-gou.png"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text class="success-title">已成功授权登录射灵星球门店Pad端。</text>
|
||||||
|
<view class="account-info">
|
||||||
|
<text>登录账号:{{ successInfo.nickName }}</text>
|
||||||
|
<text>手机号:{{ successInfo.mobile }}</text>
|
||||||
|
<text>登录门店:{{ successInfo.storeName }}</text>
|
||||||
|
<text class="warm-tip">
|
||||||
|
温馨提示:离开门店时候记得在Pad退出登录哦!
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="success-action">
|
||||||
|
<SButton width="600rpx" :rounded="22" :onClick="goHome">
|
||||||
|
<text>回到首页</text>
|
||||||
|
</SButton>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="status === 'failed'" class="state message-state">
|
||||||
|
<text class="state-title">授权登录失败</text>
|
||||||
|
<text class="description">{{ errorMessage }}</text>
|
||||||
|
<SButton width="600rpx" :rounded="22" :onClick="bindOrg">
|
||||||
|
<text>重新登录</text>
|
||||||
|
</SButton>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else class="state message-state">
|
||||||
|
<text class="state-title">二维码无效</text>
|
||||||
|
<text class="description">请重新扫描门店Pad端上的小程序码。</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) + 64rpx) 48rpx 80rpx;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
color: #d8ad69;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.state {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-state,
|
||||||
|
.success-state {
|
||||||
|
margin-top: 320rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-state {
|
||||||
|
margin-top: 240rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-icon {
|
||||||
|
width: 176rpx;
|
||||||
|
height: 176rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-title {
|
||||||
|
width: 600rpx;
|
||||||
|
margin: 28rpx 0 60rpx;
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-wrap {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-badge {
|
||||||
|
position: absolute;
|
||||||
|
right: -2rpx;
|
||||||
|
bottom: 4rpx;
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-title {
|
||||||
|
width: 572rpx;
|
||||||
|
margin-top: 28rpx;
|
||||||
|
color: #fed847;
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 48rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-info {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 572rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 52rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warm-tip {
|
||||||
|
margin-top: 40rpx;
|
||||||
|
color: #b8b8bd;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-action {
|
||||||
|
margin-top: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.state-title {
|
||||||
|
font-size: 38rpx;
|
||||||
|
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>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, nextTick, onMounted, onBeforeUnmount } from "vue";
|
import { computed, ref, nextTick, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { onHide, onLoad, onShow } from "@dcloudio/uni-app";
|
import { onHide, onLoad, onShow } 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";
|
||||||
@@ -37,6 +37,7 @@ const store = useStore();
|
|||||||
const { user, device } = storeToRefs(store);
|
const { user, device } = storeToRefs(store);
|
||||||
|
|
||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
|
const practiceStarting = ref(false);
|
||||||
const scores = ref([]);
|
const scores = ref([]);
|
||||||
const isSvip = ref(false);
|
const isSvip = ref(false);
|
||||||
const total = 12;
|
const total = 12;
|
||||||
@@ -46,6 +47,9 @@ const serverAddr = ref("");
|
|||||||
const showGuide = ref(false);
|
const showGuide = ref(false);
|
||||||
const tips = ref("");
|
const tips = ref("");
|
||||||
const targetType = ref(1);
|
const targetType = ref(1);
|
||||||
|
const simulatorTargetType = computed(() =>
|
||||||
|
[2, 40].includes(Number(targetType.value)) ? 40 : 20
|
||||||
|
);
|
||||||
const sharing = ref(false);
|
const sharing = ref(false);
|
||||||
const exiting = ref(false);
|
const exiting = ref(false);
|
||||||
const hiddenWhileActive = ref(false);
|
const hiddenWhileActive = ref(false);
|
||||||
@@ -156,12 +160,18 @@ const beginPractise = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
const result = await beginPractise();
|
if (practiceStarting.value || start.value) return;
|
||||||
if (!result) return;
|
practiceStarting.value = true;
|
||||||
scores.value = [];
|
try {
|
||||||
isSvip.value = false;
|
const result = await beginPractise();
|
||||||
start.value = true;
|
if (!result) return;
|
||||||
audioManager.play("练习开始");
|
scores.value = [];
|
||||||
|
isSvip.value = false;
|
||||||
|
start.value = true;
|
||||||
|
audioManager.play("练习开始");
|
||||||
|
} finally {
|
||||||
|
practiceStarting.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOver = async (message) => {
|
const onOver = async (message) => {
|
||||||
@@ -403,7 +413,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,
|
||||||
@@ -438,7 +448,12 @@ onBeforeUnmount(() => {
|
|||||||
:onBack="exitPractise"
|
:onBack="exitPractise"
|
||||||
>
|
>
|
||||||
<view>
|
<view>
|
||||||
<TestDistance v-if="!start && !practiseResult.id" />
|
<TestDistance
|
||||||
|
v-if="!start && !practiseResult.id"
|
||||||
|
:targetType="simulatorTargetType"
|
||||||
|
:autoStart="true"
|
||||||
|
@passed="onReady"
|
||||||
|
/>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<ShootProgress
|
<ShootProgress
|
||||||
:tips="`${
|
:tips="`${
|
||||||
@@ -466,6 +481,8 @@ onBeforeUnmount(() => {
|
|||||||
:currentRound="scores.length % 3"
|
:currentRound="scores.length % 3"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
:isSvip="isSvip"
|
:isSvip="isSvip"
|
||||||
|
:targetType="simulatorTargetType"
|
||||||
|
stable-shot-effect
|
||||||
/>
|
/>
|
||||||
<ScorePanel2 :arrows="scores" />
|
<ScorePanel2 :arrows="scores" />
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, nextTick, onMounted, onBeforeUnmount } from "vue";
|
import { computed, ref, nextTick, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { onHide, onLoad, onShow } from "@dcloudio/uni-app";
|
import { onHide, onLoad, onShow } 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";
|
||||||
@@ -37,6 +37,7 @@ const store = useStore();
|
|||||||
const { user, device } = storeToRefs(store);
|
const { user, device } = storeToRefs(store);
|
||||||
|
|
||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
|
const practiceStarting = ref(false);
|
||||||
const scores = ref([]);
|
const scores = ref([]);
|
||||||
const isSvip = ref(false);
|
const isSvip = ref(false);
|
||||||
const total = 36;
|
const total = 36;
|
||||||
@@ -45,6 +46,9 @@ const practiseId = ref("");
|
|||||||
const serverAddr = ref("");
|
const serverAddr = ref("");
|
||||||
const showGuide = ref(false);
|
const showGuide = ref(false);
|
||||||
const targetType = ref(1);
|
const targetType = ref(1);
|
||||||
|
const simulatorTargetType = computed(() =>
|
||||||
|
[2, 40].includes(Number(targetType.value)) ? 40 : 20
|
||||||
|
);
|
||||||
const sharing = ref(false);
|
const sharing = ref(false);
|
||||||
const exiting = ref(false);
|
const exiting = ref(false);
|
||||||
const hiddenWhileActive = ref(false);
|
const hiddenWhileActive = ref(false);
|
||||||
@@ -155,12 +159,18 @@ const beginPractise = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
const result = await beginPractise();
|
if (practiceStarting.value || start.value) return;
|
||||||
if (!result) return;
|
practiceStarting.value = true;
|
||||||
scores.value = [];
|
try {
|
||||||
isSvip.value = false;
|
const result = await beginPractise();
|
||||||
start.value = true;
|
if (!result) return;
|
||||||
audioManager.play("练习开始");
|
scores.value = [];
|
||||||
|
isSvip.value = false;
|
||||||
|
start.value = true;
|
||||||
|
audioManager.play("练习开始");
|
||||||
|
} finally {
|
||||||
|
practiceStarting.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOver = async (message) => {
|
const onOver = async (message) => {
|
||||||
@@ -418,7 +428,7 @@ onShow(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
void audioManager.warmAll();
|
void audioManager.warmCommon();
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
@@ -452,7 +462,12 @@ onBeforeUnmount(() => {
|
|||||||
:onBack="exitPractise"
|
:onBack="exitPractise"
|
||||||
>
|
>
|
||||||
<view>
|
<view>
|
||||||
<TestDistance v-if="!start && !practiseResult.id" />
|
<TestDistance
|
||||||
|
v-if="!start && !practiseResult.id"
|
||||||
|
:targetType="simulatorTargetType"
|
||||||
|
:autoStart="true"
|
||||||
|
@passed="onReady"
|
||||||
|
/>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<ShootProgress
|
<ShootProgress
|
||||||
:tips="`请连续射${total}支箭`"
|
:tips="`请连续射${total}支箭`"
|
||||||
@@ -475,6 +490,7 @@ onBeforeUnmount(() => {
|
|||||||
:totalRound="start ? total : 0"
|
:totalRound="start ? total : 0"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
:isSvip="isSvip"
|
:isSvip="isSvip"
|
||||||
|
:targetType="simulatorTargetType"
|
||||||
/>
|
/>
|
||||||
<ScorePanel
|
<ScorePanel
|
||||||
v-if="start"
|
v-if="start"
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
targetType: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 20,
|
||||||
|
},
|
||||||
targetRadius: {
|
targetRadius: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 20,
|
default: 20,
|
||||||
@@ -67,6 +71,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 +85,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 +147,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 +161,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 +212,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 +288,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 +309,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 +321,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;
|
||||||
@@ -363,12 +426,19 @@ function getExperienceTipStyle(shot) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) {
|
||||||
|
await simulShootAPI(
|
||||||
|
device.value.deviceId,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
props.targetType
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const simulShoot2 = async () => {
|
const simulShoot2 = async () => {
|
||||||
if (device.value.deviceId) {
|
if (device.value.deviceId) {
|
||||||
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
||||||
await simulShootAPI(device.value.deviceId, r1, r1);
|
await simulShootAPI(device.value.deviceId, r1, r1, props.targetType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -417,11 +487,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 +611,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 +625,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>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Avatar from "./Avatar.vue";
|
|||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { simulShootAPI } from "@/apis";
|
import { simulShootAPI } from "@/apis";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
|
import { getDistanceCheckAudioKey, getDistanceCheckText } from "@/util";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
@@ -23,9 +24,14 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 15,
|
default: 15,
|
||||||
},
|
},
|
||||||
|
targetType: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 20,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const arrow = ref({});
|
const arrow = ref({});
|
||||||
const distance = ref(0);
|
const distance = ref(0);
|
||||||
|
const statusText = ref("");
|
||||||
const showsimul = ref(false);
|
const showsimul = ref(false);
|
||||||
const count = ref(props.count);
|
const count = ref(props.count);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
@@ -34,7 +40,7 @@ const updateTimer = (value) => {
|
|||||||
count.value = Math.round(value);
|
count.value = Math.round(value);
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
audioManager.play("请射箭测试距离");
|
audioManager.play("请射箭!测试站距与靶纸");
|
||||||
if (props.isBattle) {
|
if (props.isBattle) {
|
||||||
timer.value = setInterval(() => {
|
timer.value = setInterval(() => {
|
||||||
count.value -= 1;
|
count.value -= 1;
|
||||||
@@ -51,14 +57,24 @@ 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 ?? msg.shootData?.dst);
|
||||||
if (distance.value >= 5) audioManager.play("距离合格");
|
distance.value = Number.isFinite(rawDistance)
|
||||||
else audioManager.play("距离不足");
|
? Number((rawDistance / 100).toFixed(2))
|
||||||
|
: 0;
|
||||||
|
statusText.value = getDistanceCheckText(msg.shootData);
|
||||||
|
audioManager.play(getDistanceCheckAudioKey(msg.shootData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) {
|
||||||
|
await simulShootAPI(
|
||||||
|
device.value.deviceId,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
props.targetType
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -96,13 +112,11 @@ onBeforeUnmount(() => {
|
|||||||
模拟射箭
|
模拟射箭
|
||||||
</button>
|
</button>
|
||||||
<view class="warnning-text">
|
<view class="warnning-text">
|
||||||
<block v-if="distance > 0">
|
<block v-if="statusText">
|
||||||
<text>当前距离{{ distance }}米</text>
|
<text>{{ statusText }}</text>
|
||||||
<text v-if="distance >= 5">已达到距离要求</text>
|
|
||||||
<text v-else>请调整站位</text>
|
|
||||||
</block>
|
</block>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<text>请射箭,测试站距</text>
|
<text>请射箭,测试站距与靶纸</text>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-row">
|
<view class="user-row">
|
||||||
@@ -113,7 +127,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,11 @@ 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,
|
||||||
|
getInvalidShotText,
|
||||||
|
} from "@/util";
|
||||||
import { takeMatchReturnSnapshot } from "@/utils/matchReturn";
|
import { takeMatchReturnSnapshot } from "@/utils/matchReturn";
|
||||||
import audioManager, {
|
import audioManager, {
|
||||||
AUDIO_INTERRUPTION_BEGIN_EVENT,
|
AUDIO_INTERRUPTION_BEGIN_EVENT,
|
||||||
@@ -63,6 +67,7 @@ const COUNTDOWN_READY_EVENT = "team-battle-countdown-ready";
|
|||||||
const start = ref(null);
|
const start = ref(null);
|
||||||
const tips = ref("");
|
const tips = ref("");
|
||||||
const battleId = ref("");
|
const battleId = ref("");
|
||||||
|
const targetType = ref(20);
|
||||||
const currentRound = ref(0);
|
const currentRound = ref(0);
|
||||||
const roundTipRound = ref(0);
|
const roundTipRound = ref(0);
|
||||||
const goldenRound = ref(0);
|
const goldenRound = ref(0);
|
||||||
@@ -650,6 +655,8 @@ function applyBattleBase(battleInfo) {
|
|||||||
battleInfo = normalizeBattleInfo(battleInfo);
|
battleInfo = normalizeBattleInfo(battleInfo);
|
||||||
if (!battleInfo) return;
|
if (!battleInfo) return;
|
||||||
if (battleInfo.matchId) battleId.value = battleInfo.matchId;
|
if (battleInfo.matchId) battleId.value = battleInfo.matchId;
|
||||||
|
const nextTargetType = Number(battleInfo.targetType ?? battleInfo.target_type);
|
||||||
|
if ([20, 40].includes(nextTargetType)) targetType.value = nextTargetType;
|
||||||
if (battleInfo.status !== undefined) {
|
if (battleInfo.status !== undefined) {
|
||||||
start.value = battleInfo.status !== 0;
|
start.value = battleInfo.status !== 0;
|
||||||
matchStatus.value = battleInfo.status;
|
matchStatus.value = battleInfo.status;
|
||||||
@@ -1133,10 +1140,12 @@ async function runBattleEndTask(task, runId) {
|
|||||||
async function runInvalidShotTask(task, runId) {
|
async function runInvalidShotTask(task, runId) {
|
||||||
if (!isQueueAlive(runId)) return;
|
if (!isQueueAlive(runId)) return;
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "距离不足,无效",
|
title: getInvalidShotText(task.message?.shootData),
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
await playAudioKeys("射击无效", { interrupt: false });
|
await playAudioKeys(getInvalidShotAudioKey(task.message?.shootData), {
|
||||||
|
interrupt: false,
|
||||||
|
});
|
||||||
notifyMatchAudioAck(task);
|
notifyMatchAudioAck(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1259,6 +1268,7 @@ onLoad((options) => {
|
|||||||
start.value = null;
|
start.value = null;
|
||||||
tips.value = "";
|
tips.value = "";
|
||||||
battleId.value = returnSnapshot?.matchId || options.battleId || "";
|
battleId.value = returnSnapshot?.matchId || options.battleId || "";
|
||||||
|
targetType.value = 20;
|
||||||
currentRound.value = 0;
|
currentRound.value = 0;
|
||||||
roundTipRound.value = 0;
|
roundTipRound.value = 0;
|
||||||
goldenRound.value = 0;
|
goldenRound.value = 0;
|
||||||
@@ -1392,6 +1402,7 @@ onShow(() => {
|
|||||||
:guide="false"
|
:guide="false"
|
||||||
:isBattle="true"
|
:isBattle="true"
|
||||||
:count="readyTime"
|
:count="readyTime"
|
||||||
|
:targetType="targetType"
|
||||||
/>
|
/>
|
||||||
<!-- 比赛进行中显示:左右队伍、进度条、靶面和底部比分。 -->
|
<!-- 比赛进行中显示:左右队伍、进度条、靶面和底部比分。 -->
|
||||||
<view v-if="start" class="players-row">
|
<view v-if="start" class="players-row">
|
||||||
@@ -1417,6 +1428,8 @@ onShow(() => {
|
|||||||
:latestShotFlash="latestShotFlash"
|
:latestShotFlash="latestShotFlash"
|
||||||
:redTeam="redTeam"
|
:redTeam="redTeam"
|
||||||
:blueTeam="blueTeam"
|
:blueTeam="blueTeam"
|
||||||
|
:targetType="targetType"
|
||||||
|
stable-shot-effect
|
||||||
/>
|
/>
|
||||||
<BattleFooter
|
<BattleFooter
|
||||||
v-if="start"
|
v-if="start"
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
trainingType: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ const props = defineProps({
|
|||||||
:rowCount="total === 12 ? 6 : 9"
|
:rowCount="total === 12 ? 6 : 9"
|
||||||
:total="total"
|
:total="total"
|
||||||
:arrows="arrows"
|
:arrows="arrows"
|
||||||
|
:trainingType="trainingType"
|
||||||
:margin="total === 12 ? 4 : 1"
|
:margin="total === 12 ? 4 : 1"
|
||||||
:fontSize="total === 12 ? 25 : 22"
|
:fontSize="total === 12 ? 25 : 22"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -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 双排
|
||||||
@@ -52,6 +56,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
targetType: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 40,
|
||||||
|
},
|
||||||
coordinateRadius: {
|
coordinateRadius: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 20,
|
default: 20,
|
||||||
@@ -84,6 +92,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 +103,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 +271,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 +280,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 +320,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 +342,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,35 +415,41 @@ 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,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) {
|
||||||
|
await simulShootAPI(
|
||||||
|
device.value.deviceId,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
props.targetType
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const simulShoot2 = async () => {
|
const simulShoot2 = async () => {
|
||||||
if (device.value.deviceId) {
|
if (device.value.deviceId) {
|
||||||
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
||||||
await simulShootAPI(device.value.deviceId, r1, r1);
|
await simulShootAPI(device.value.deviceId, r1, r1, props.targetType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -431,11 +503,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 +549,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 +595,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 +650,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,
|
||||||
@@ -21,14 +21,16 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
trainingType: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const items = ref(new Array(props.total).fill(9));
|
const items = ref(new Array(props.total).fill(9));
|
||||||
const bgImages = [
|
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";
|
||||||
@@ -36,7 +38,11 @@ const getDisplayText = (arrow) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isLowScore = (arrow) => {
|
const isLowScore = (arrow) => {
|
||||||
if (!arrow || arrow.ringX) return false;
|
if (!arrow) return false;
|
||||||
|
if (["rhythm", "stability"].includes(props.trainingType)) {
|
||||||
|
return arrow.ok !== true;
|
||||||
|
}
|
||||||
|
if (arrow.ringX) return false;
|
||||||
const ring = Number(arrow.ring);
|
const ring = Number(arrow.ring);
|
||||||
return Number.isFinite(ring) && ring < 6;
|
return Number.isFinite(ring) && ring < 6;
|
||||||
};
|
};
|
||||||
@@ -47,35 +53,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 +155,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>
|
|
||||||
@@ -54,6 +54,18 @@ const showComment = ref(false);
|
|||||||
const showBowData = ref(false);
|
const showBowData = ref(false);
|
||||||
const showUpgrade = ref(false);
|
const showUpgrade = ref(false);
|
||||||
|
|
||||||
|
const isCompleted = computed(() => props.result.completed === true);
|
||||||
|
const heroBackground = computed(() =>
|
||||||
|
isCompleted.value
|
||||||
|
? "https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-bg.png"
|
||||||
|
: "https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-bg-fail.png"
|
||||||
|
);
|
||||||
|
const titleBackground = computed(() =>
|
||||||
|
isCompleted.value
|
||||||
|
? "https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-t-bg.png"
|
||||||
|
: "https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-t-bg-fail.png"
|
||||||
|
);
|
||||||
|
|
||||||
const closePanel = () => {
|
const closePanel = () => {
|
||||||
showPanel.value = false;
|
showPanel.value = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -219,6 +231,13 @@ const metricConfigs = {
|
|||||||
deltaKeys: ["deltaStability", "delta_stability"],
|
deltaKeys: ["deltaStability", "delta_stability"],
|
||||||
deltaUnit: "",
|
deltaUnit: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "十环次数",
|
||||||
|
valueKeys: ["tenRingCount", "ten_ring_count"],
|
||||||
|
unit: "次",
|
||||||
|
deltaKeys: ["deltaTenRingCount", "delta_ten_ring_count"],
|
||||||
|
deltaUnit: "次",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
rhythm: [
|
rhythm: [
|
||||||
{
|
{
|
||||||
@@ -235,6 +254,39 @@ const metricConfigs = {
|
|||||||
deltaKeys: ["deltaTotalRings", "delta_total_rings"],
|
deltaKeys: ["deltaTotalRings", "delta_total_rings"],
|
||||||
deltaUnit: "环",
|
deltaUnit: "环",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "十环次数",
|
||||||
|
valueKeys: ["tenRingCount", "ten_ring_count"],
|
||||||
|
unit: "次",
|
||||||
|
deltaKeys: ["deltaTenRingCount", "delta_ten_ring_count"],
|
||||||
|
deltaUnit: "次",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stability: [
|
||||||
|
{
|
||||||
|
label: "能量最高值",
|
||||||
|
valueKeys: ["maxEnergyPercent", "max_energy_percent"],
|
||||||
|
unit: "%",
|
||||||
|
deltaKeys: [
|
||||||
|
"deltaMaxEnergyPercent",
|
||||||
|
"delta_max_energy_percent",
|
||||||
|
],
|
||||||
|
deltaUnit: "%",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "达标箭数",
|
||||||
|
valueKeys: ["qualifiedArrows", "qualified_arrows"],
|
||||||
|
unit: "箭",
|
||||||
|
deltaKeys: ["deltaQualifiedArrows", "delta_qualified_arrows"],
|
||||||
|
deltaUnit: "箭",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "达标率",
|
||||||
|
valueKeys: ["qualifiedRate", "qualified_rate"],
|
||||||
|
unit: "%",
|
||||||
|
deltaKeys: ["deltaQualifiedRate", "delta_qualified_rate"],
|
||||||
|
deltaUnit: "%",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
endurance: [
|
endurance: [
|
||||||
{
|
{
|
||||||
@@ -251,41 +303,43 @@ const metricConfigs = {
|
|||||||
deltaKeys: ["deltaTotalRings", "delta_total_rings"],
|
deltaKeys: ["deltaTotalRings", "delta_total_rings"],
|
||||||
deltaUnit: "环",
|
deltaUnit: "环",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "平均环数",
|
||||||
|
valueKeys: ["averageRing", "average_ring"],
|
||||||
|
unit: "环",
|
||||||
|
deltaKeys: ["deltaAverageRing", "delta_average_ring"],
|
||||||
|
deltaUnit: "环",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
precision: [
|
precision: [
|
||||||
{
|
{
|
||||||
label: "共命中目标",
|
label: "命中目标数",
|
||||||
valueKeys: ["totalHits", "total_hits"],
|
valueKeys: ["totalHits", "total_hits"],
|
||||||
fallback: () => 0,
|
fallback: () => 0,
|
||||||
unit: "次",
|
unit: "次",
|
||||||
deltaKeys: [
|
deltaKeys: ["deltaTotalHits", "delta_total_hits"],
|
||||||
"deltaTotalHits",
|
|
||||||
"delta_total_hits",
|
|
||||||
"hitCompare",
|
|
||||||
"hitDiff",
|
|
||||||
"hitDelta",
|
|
||||||
],
|
|
||||||
deltaUnit: "次",
|
deltaUnit: "次",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "用时",
|
label: "射箭数",
|
||||||
valueKeys: ["duration", "usedTime", "shootTime", "time"],
|
valueKeys: ["totalArrows", "total_arrows"],
|
||||||
unit: "",
|
unit: "箭",
|
||||||
deltaKeys: [
|
deltaKeys: ["deltaTotalArrows", "delta_total_arrows"],
|
||||||
"deltaDuration",
|
deltaUnit: "箭",
|
||||||
"delta_duration",
|
},
|
||||||
"timeCompare",
|
{
|
||||||
"timeDiff",
|
label: "命中率",
|
||||||
"durationDiff",
|
valueKeys: ["hitRate", "hit_rate"],
|
||||||
],
|
unit: "%",
|
||||||
deltaUnit: "",
|
deltaKeys: ["deltaHitRate", "delta_hit_rate"],
|
||||||
duration: true,
|
deltaUnit: "%",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const resultRows = computed(() => {
|
const resultRows = computed(() => {
|
||||||
const configs = metricConfigs[resultTrainingType.value] || metricConfigs.precision;
|
const configs =
|
||||||
|
metricConfigs[resultTrainingType.value] || metricConfigs.precision;
|
||||||
return configs.map((config) => {
|
return configs.map((config) => {
|
||||||
const fallback = config.fallback ? config.fallback() : 0;
|
const fallback = config.fallback ? config.fallback() : 0;
|
||||||
const value = readMetricNumber(config.valueKeys, fallback);
|
const value = readMetricNumber(config.valueKeys, fallback);
|
||||||
@@ -314,20 +368,17 @@ const handlePrimary = () => {
|
|||||||
retryPractice();
|
retryPractice();
|
||||||
};
|
};
|
||||||
|
|
||||||
const calories = computed(
|
|
||||||
() => formatMetricNumber(readMetricNumber(["calories", "calorie", "kcal"]))
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view :class="['result-mask', showPanel ? 'result-mask--show' : 'result-mask--hide']">
|
<view :class="['result-mask', showPanel ? 'result-mask--show' : 'result-mask--hide']">
|
||||||
<image class="hero-glow" src="https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-bg.png" mode="widthFix" />
|
<image class="hero-glow" :src="heroBackground" mode="widthFix" />
|
||||||
<view class="result-title">
|
<view class="result-title">
|
||||||
<image class="result-title-bg" src="https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-t-bg.png" mode="widthFix" />
|
<image class="result-title-bg" :src="titleBackground" mode="widthFix" />
|
||||||
<view class="result-title-text">Lv{{ resultDifficultyLevel }}</view>
|
<view class="result-title-text">Lv{{ resultDifficultyLevel }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="result-panel">
|
<view :class="['result-panel', { 'result-panel--fail': !isCompleted }]">
|
||||||
<view class="line-top"></view>
|
<view class="line-top"></view>
|
||||||
<view class="line-bottom"></view>
|
<view class="line-bottom"></view>
|
||||||
<view class="stats">
|
<view class="stats">
|
||||||
@@ -352,25 +403,6 @@ const calories = computed(
|
|||||||
<view v-else class="stat-value">--</view>
|
<view v-else class="stat-value">--</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="stat-row">
|
|
||||||
<image class="stat-bg" src="https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-c-bg.png" mode="scaleToFill" />
|
|
||||||
<view class="stat-cell">
|
|
||||||
<text class="stat-label">消耗卡路里</text>
|
|
||||||
<view class="stat-value">
|
|
||||||
<text>{{ calories }}卡</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<text class="stat-equal">≈</text>
|
|
||||||
<!-- <view class="stat-divider"></view> -->
|
|
||||||
<view class="stat-cell stat-cell--compare">
|
|
||||||
<view class="stat-value">
|
|
||||||
<image v-for="index in 3" :key="index" class="rice-icon"
|
|
||||||
src="https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-rice.png" mode="widthFix" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<view class="actions">
|
<view class="actions">
|
||||||
<view class="action-item" @click="() => (showBowData = true)">
|
<view class="action-item" @click="() => (showBowData = true)">
|
||||||
<image class="action-icon" src="https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-icon-1.png" mode="widthFix" />
|
<image class="action-icon" src="https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/result-icon-1.png" mode="widthFix" />
|
||||||
@@ -435,7 +467,7 @@ const calories = computed(
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</ScreenHint>
|
</ScreenHint>
|
||||||
<BowData :total="arrows.length" :arrows="result.details" :show="showBowData"
|
<BowData :total="details.length" :arrows="details" :show="showBowData" :trainingType="resultTrainingType"
|
||||||
:onClose="() => (showBowData = false)" />
|
:onClose="() => (showBowData = false)" />
|
||||||
<UserUpgrade :show="showUpgrade" :onClose="() => (showUpgrade = false)" :lvl="userLevel" />
|
<UserUpgrade :show="showUpgrade" :onClose="() => (showUpgrade = false)" :lvl="userLevel" />
|
||||||
</view>
|
</view>
|
||||||
@@ -517,6 +549,10 @@ const calories = computed(
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result-panel--fail {
|
||||||
|
background: rgba(34, 34, 46, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
.stats {
|
.stats {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 34rpx;
|
margin-top: 34rpx;
|
||||||
@@ -610,14 +646,6 @@ const calories = computed(
|
|||||||
transform: skewX(12deg);
|
transform: skewX(12deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.stat-equal{
|
|
||||||
width: 30rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
color: #F3E0B9;
|
|
||||||
font-size: 30rpx;
|
|
||||||
margin-left: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.trend-icon {
|
.trend-icon {
|
||||||
width: 28rpx;
|
width: 28rpx;
|
||||||
height: 42rpx;
|
height: 42rpx;
|
||||||
@@ -636,18 +664,6 @@ const calories = computed(
|
|||||||
height: 62rpx;
|
height: 62rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rice-list {
|
|
||||||
width: 160rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rice-icon {
|
|
||||||
width: 36rpx;
|
|
||||||
height: 34rpx;
|
|
||||||
margin-right: 14rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.oper-box {
|
.oper-box {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|||||||
@@ -1,8 +1,22 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
import {
|
||||||
import audioManager from "@/audioManager";
|
ref,
|
||||||
|
watch,
|
||||||
|
onMounted,
|
||||||
|
onBeforeUnmount,
|
||||||
|
computed,
|
||||||
|
nextTick,
|
||||||
|
} from "vue";
|
||||||
|
import audioManager, {
|
||||||
|
getTrainingStartAudioKey,
|
||||||
|
RHYTHM_SHOOT_WINDOW_AUDIO_KEY,
|
||||||
|
} from "@/audioManager";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import {
|
||||||
|
getDirectionText,
|
||||||
|
getInvalidShotAudioKey,
|
||||||
|
getInvalidShotText,
|
||||||
|
} from "@/util";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -35,6 +49,38 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: "precision",
|
default: "precision",
|
||||||
},
|
},
|
||||||
|
roundTime: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
shootTime: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
shootWindowStart: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
inShootWindow: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
serverTimestamp: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
hitReq: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
energyPercent: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
energyReqPercent: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
isVip: {
|
isVip: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
@@ -89,12 +135,100 @@ const currentRoundEnded = ref(false);
|
|||||||
const halfTime = ref(false);
|
const halfTime = ref(false);
|
||||||
const wait = ref(0);
|
const wait = ref(0);
|
||||||
const transitionStyle = ref("all 1s linear");
|
const transitionStyle = ref("all 1s linear");
|
||||||
|
const rhythmRemainingMs = ref(0);
|
||||||
|
const rhythmRemainingSeconds = ref(0);
|
||||||
|
const rhythmIsShootWindow = ref(false);
|
||||||
|
const rhythmTransitionStyle = ref("none");
|
||||||
|
let rhythmCountdownTimer = null;
|
||||||
|
let rhythmTransitionTimer = null;
|
||||||
|
let rhythmServerClockOffsetMs = 0;
|
||||||
|
let rhythmSyncGeneration = 0;
|
||||||
|
|
||||||
|
const isRhythmTraining = computed(() => props.trainingType === "rhythm");
|
||||||
|
const isStabilityTraining = computed(
|
||||||
|
() => props.trainingType === "stability"
|
||||||
|
);
|
||||||
|
|
||||||
|
const normalizePositiveInteger = (value) => {
|
||||||
|
const numberValue = Number(value);
|
||||||
|
return Number.isFinite(numberValue) && numberValue > 0
|
||||||
|
? Math.round(numberValue)
|
||||||
|
: 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 服务端时间戳可能由 protobuf int64 以字符串形式下发。
|
||||||
|
const normalizeTimestamp = (value) => {
|
||||||
|
const numberValue = Number(value);
|
||||||
|
if (!Number.isFinite(numberValue) || numberValue <= 0) return 0;
|
||||||
|
return numberValue < 1e12 ? numberValue * 1000 : numberValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
const validRhythmRoundTime = computed(() =>
|
||||||
|
normalizePositiveInteger(props.roundTime)
|
||||||
|
);
|
||||||
|
const validRhythmShootTime = computed(() =>
|
||||||
|
Math.min(
|
||||||
|
normalizePositiveInteger(props.shootTime),
|
||||||
|
validRhythmRoundTime.value
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const validRhythmHitReq = computed(() =>
|
||||||
|
normalizePositiveInteger(props.hitReq)
|
||||||
|
);
|
||||||
|
const rhythmRoundDurationMs = computed(
|
||||||
|
() => validRhythmRoundTime.value * 1000
|
||||||
|
);
|
||||||
|
const rhythmShootDurationMs = computed(
|
||||||
|
() => validRhythmShootTime.value * 1000
|
||||||
|
);
|
||||||
|
|
||||||
const progressPercent = computed(() => {
|
const progressPercent = computed(() => {
|
||||||
if (!props.countdownEnabled || !props.total) return 0;
|
if (!props.countdownEnabled || !props.total) return 0;
|
||||||
return Math.max(0, Math.min(100, (remain.value / props.total) * 100));
|
return Math.max(0, Math.min(100, (remain.value / props.total) * 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const stabilityEnergyPercent = computed(() =>
|
||||||
|
Math.max(0, Math.min(100, Number(props.energyPercent) || 0))
|
||||||
|
);
|
||||||
|
const stabilityEnergyReqPercent = computed(() =>
|
||||||
|
Math.max(0, Math.min(100, Number(props.energyReqPercent) || 0))
|
||||||
|
);
|
||||||
|
const stabilityEnergyReached = computed(
|
||||||
|
() =>
|
||||||
|
stabilityEnergyReqPercent.value > 0 &&
|
||||||
|
stabilityEnergyPercent.value >= stabilityEnergyReqPercent.value
|
||||||
|
);
|
||||||
|
|
||||||
|
const rhythmMarkerPercent = computed(() => {
|
||||||
|
if (!validRhythmRoundTime.value) return 0;
|
||||||
|
return Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(
|
||||||
|
100,
|
||||||
|
(validRhythmShootTime.value / validRhythmRoundTime.value) * 100
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const rhythmProgressPercent = computed(() => {
|
||||||
|
if (!rhythmRoundDurationMs.value) return 0;
|
||||||
|
return Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(
|
||||||
|
100,
|
||||||
|
(rhythmRemainingMs.value / rhythmRoundDurationMs.value) * 100
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const rhythmTitle = computed(() => {
|
||||||
|
if (!validRhythmShootTime.value) return "节奏训练";
|
||||||
|
if (!validRhythmHitReq.value) {
|
||||||
|
return `在最后的${validRhythmShootTime.value}秒内射箭`;
|
||||||
|
}
|
||||||
|
return `在最后的${validRhythmShootTime.value}秒并命中${validRhythmHitReq.value}环内`;
|
||||||
|
});
|
||||||
|
|
||||||
const displayName = computed(() => {
|
const displayName = computed(() => {
|
||||||
return (
|
return (
|
||||||
user.value?.nickName ||
|
user.value?.nickName ||
|
||||||
@@ -139,8 +273,147 @@ const clearTimer = () => {
|
|||||||
timer.value = null;
|
timer.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearRhythmTimers = () => {
|
||||||
|
if (rhythmCountdownTimer) {
|
||||||
|
clearTimeout(rhythmCountdownTimer);
|
||||||
|
rhythmCountdownTimer = null;
|
||||||
|
}
|
||||||
|
if (rhythmTransitionTimer) {
|
||||||
|
clearTimeout(rhythmTransitionTimer);
|
||||||
|
rhythmTransitionTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRhythmServerNow = () => Date.now() + rhythmServerClockOffsetMs;
|
||||||
|
|
||||||
|
const getRhythmRoundRemainingMs = () => {
|
||||||
|
const shootWindowStart = normalizeTimestamp(props.shootWindowStart);
|
||||||
|
if (!shootWindowStart || !rhythmRoundDurationMs.value) return 0;
|
||||||
|
|
||||||
|
const firstRoundEnd = shootWindowStart + rhythmShootDurationMs.value;
|
||||||
|
const serverNow = getRhythmServerNow();
|
||||||
|
let roundEnd = firstRoundEnd;
|
||||||
|
|
||||||
|
// 服务端锚点过期后继续按 round_time 推演下一轮,避免进度停在 0。
|
||||||
|
if (serverNow >= firstRoundEnd) {
|
||||||
|
const elapsedRounds =
|
||||||
|
Math.floor(
|
||||||
|
(serverNow - firstRoundEnd) / rhythmRoundDurationMs.value
|
||||||
|
) + 1;
|
||||||
|
roundEnd = firstRoundEnd + elapsedRounds * rhythmRoundDurationMs.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(rhythmRoundDurationMs.value, roundEnd - serverNow)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateRhythmShootWindow = (isInWindow) => {
|
||||||
|
const nextIsInWindow = Boolean(isInWindow);
|
||||||
|
const enteredShootWindow =
|
||||||
|
nextIsInWindow && !rhythmIsShootWindow.value;
|
||||||
|
rhythmIsShootWindow.value = nextIsInWindow;
|
||||||
|
|
||||||
|
// 只在进入窗口的边沿立即提示;预热和播放均为异步,不阻塞倒计时。
|
||||||
|
if (enteredShootWindow && props.start && isRhythmTraining.value) {
|
||||||
|
audioManager.play(RHYTHM_SHOOT_WINDOW_AUDIO_KEY);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 每秒只更新一次目标宽度,实际推进交给 CSS transition,减少响应式刷新。
|
||||||
|
const scheduleRhythmCountdownStep = () => {
|
||||||
|
rhythmCountdownTimer = null;
|
||||||
|
const currentRemaining = getRhythmRoundRemainingMs();
|
||||||
|
if (currentRemaining <= 0) {
|
||||||
|
rhythmTransitionStyle.value = "none";
|
||||||
|
rhythmRemainingMs.value = 0;
|
||||||
|
rhythmRemainingSeconds.value = 0;
|
||||||
|
updateRhythmShootWindow(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数字展示使用服务端校准后的真实剩余时间,不读取提前写入的动画目标值。
|
||||||
|
rhythmRemainingSeconds.value = Math.ceil(currentRemaining / 1000);
|
||||||
|
updateRhythmShootWindow(
|
||||||
|
currentRemaining <= rhythmShootDurationMs.value
|
||||||
|
);
|
||||||
|
|
||||||
|
// 一轮结束后先无动画恢复至 100%,再开始下一轮向左递减。
|
||||||
|
if (currentRemaining - rhythmRemainingMs.value > 1000) {
|
||||||
|
rhythmTransitionStyle.value = "none";
|
||||||
|
rhythmRemainingMs.value = currentRemaining;
|
||||||
|
rhythmTransitionTimer = setTimeout(() => {
|
||||||
|
rhythmTransitionTimer = null;
|
||||||
|
scheduleRhythmCountdownStep();
|
||||||
|
}, 50);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetRemaining = Math.max(
|
||||||
|
0,
|
||||||
|
(Math.ceil(currentRemaining / 1000) - 1) * 1000
|
||||||
|
);
|
||||||
|
const stepDuration = Math.max(50, currentRemaining - targetRemaining);
|
||||||
|
rhythmTransitionStyle.value = `width ${stepDuration}ms linear`;
|
||||||
|
rhythmRemainingMs.value = targetRemaining;
|
||||||
|
rhythmCountdownTimer = setTimeout(
|
||||||
|
scheduleRhythmCountdownStep,
|
||||||
|
stepDuration
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const syncRhythmCountdown = async () => {
|
||||||
|
const generation = ++rhythmSyncGeneration;
|
||||||
|
clearRhythmTimers();
|
||||||
|
|
||||||
|
if (!isRhythmTraining.value) {
|
||||||
|
rhythmTransitionStyle.value = "none";
|
||||||
|
rhythmRemainingMs.value = 0;
|
||||||
|
rhythmRemainingSeconds.value = 0;
|
||||||
|
updateRhythmShootWindow(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const serverTimestamp = normalizeTimestamp(props.serverTimestamp);
|
||||||
|
rhythmServerClockOffsetMs = serverTimestamp
|
||||||
|
? serverTimestamp - Date.now()
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!validRhythmRoundTime.value ||
|
||||||
|
!validRhythmShootTime.value ||
|
||||||
|
!normalizeTimestamp(props.shootWindowStart)
|
||||||
|
) {
|
||||||
|
rhythmTransitionStyle.value = "none";
|
||||||
|
rhythmRemainingMs.value = 0;
|
||||||
|
rhythmRemainingSeconds.value = 0;
|
||||||
|
updateRhythmShootWindow(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rhythmTransitionStyle.value = "none";
|
||||||
|
rhythmRemainingMs.value = getRhythmRoundRemainingMs();
|
||||||
|
rhythmRemainingSeconds.value = Math.ceil(rhythmRemainingMs.value / 1000);
|
||||||
|
updateRhythmShootWindow(
|
||||||
|
rhythmRemainingMs.value > 0 &&
|
||||||
|
rhythmRemainingMs.value <= rhythmShootDurationMs.value
|
||||||
|
);
|
||||||
|
await nextTick();
|
||||||
|
if (generation !== rhythmSyncGeneration) return;
|
||||||
|
|
||||||
|
rhythmTransitionTimer = setTimeout(() => {
|
||||||
|
rhythmTransitionTimer = null;
|
||||||
|
scheduleRhythmCountdownStep();
|
||||||
|
}, 50);
|
||||||
|
};
|
||||||
|
|
||||||
const resetTimer = (count) => {
|
const resetTimer = (count) => {
|
||||||
clearTimer();
|
clearTimer();
|
||||||
|
if (isRhythmTraining.value) {
|
||||||
|
remain.value = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!props.countdownEnabled) {
|
if (!props.countdownEnabled) {
|
||||||
remain.value = 0;
|
remain.value = 0;
|
||||||
return;
|
return;
|
||||||
@@ -173,9 +446,12 @@ const resetTimer = (count) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.start, props.countdownEnabled],
|
() => [props.start, props.countdownEnabled, props.trainingType],
|
||||||
([started, countdownEnabled]) => {
|
([started, countdownEnabled, trainingType]) => {
|
||||||
if (started && countdownEnabled) {
|
if (trainingType === "rhythm") {
|
||||||
|
clearTimer();
|
||||||
|
remain.value = 0;
|
||||||
|
} else if (started && countdownEnabled) {
|
||||||
resetTimer(props.total);
|
resetTimer(props.total);
|
||||||
} else {
|
} else {
|
||||||
clearTimer();
|
clearTimer();
|
||||||
@@ -187,6 +463,18 @@ watch(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [
|
||||||
|
props.trainingType,
|
||||||
|
props.roundTime,
|
||||||
|
props.shootTime,
|
||||||
|
props.shootWindowStart,
|
||||||
|
props.serverTimestamp,
|
||||||
|
],
|
||||||
|
syncRhythmCountdown,
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
const tipContent = computed(() => {
|
const tipContent = computed(() => {
|
||||||
if (halfTime.value) {
|
if (halfTime.value) {
|
||||||
return props.battleId ? "中场休息" : `中场休息(${wait.value}秒)`;
|
return props.battleId ? "中场休息" : `中场休息(${wait.value}秒)`;
|
||||||
@@ -203,11 +491,14 @@ async function onReceiveMessage(msg) {
|
|||||||
if (Array.isArray(msg)) return;
|
if (Array.isArray(msg)) return;
|
||||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||||
halfTime.value = false;
|
halfTime.value = false;
|
||||||
audioManager.play("比赛开始");
|
// 已实现的个人训练由页面播放专属提示,避免重复播报。
|
||||||
|
if (!getTrainingStartAudioKey(props.trainingType)) {
|
||||||
|
audioManager.play("比赛开始");
|
||||||
|
}
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||||
audioManager.play("练习结束", false);
|
audioManager.play("练习结束", false);
|
||||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||||
// 精准训练由页面统一等待语音和飞箭结束,其他训练保持原播放链路。
|
// 精准和节奏训练由页面统一处理专属结果语音,其他训练保持原播放链路。
|
||||||
if (props.externalShootResultAudio) return;
|
if (props.externalShootResultAudio) return;
|
||||||
const latestDetail =
|
const latestDetail =
|
||||||
Array.isArray(msg.details) && msg.details.length > 0
|
Array.isArray(msg.details) && msg.details.length > 0
|
||||||
@@ -238,10 +529,10 @@ async function onReceiveMessage(msg) {
|
|||||||
audioManager.play("中场休息");
|
audioManager.play("中场休息");
|
||||||
} else if (msg.type === MESSAGETYPESV2.InvalidShot) {
|
} else if (msg.type === MESSAGETYPESV2.InvalidShot) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "距离不足,无效",
|
title: getInvalidShotText(msg.shootData),
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
audioManager.play("射击无效");
|
audioManager.play(getInvalidShotAudioKey(msg.shootData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,12 +551,66 @@ onBeforeUnmount(() => {
|
|||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
uni.$off("play-sound", playSound);
|
uni.$off("play-sound", playSound);
|
||||||
clearTimer();
|
clearTimer();
|
||||||
|
rhythmSyncGeneration += 1;
|
||||||
|
clearRhythmTimers();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view v-if="show" class="progress-card">
|
<view
|
||||||
<view class="progress-card__header">
|
v-if="show"
|
||||||
|
:class="
|
||||||
|
isRhythmTraining
|
||||||
|
? 'rhythm-progress'
|
||||||
|
: isStabilityTraining
|
||||||
|
? 'stability-progress'
|
||||||
|
: 'progress-card'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template v-if="isStabilityTraining">
|
||||||
|
<text class="stability-progress__time">{{ remain }}秒</text>
|
||||||
|
<view class="stability-progress__track">
|
||||||
|
<view
|
||||||
|
class="stability-progress__fill"
|
||||||
|
:class="{
|
||||||
|
'stability-progress__fill--reached': stabilityEnergyReached,
|
||||||
|
}"
|
||||||
|
:style="{ width: `${stabilityEnergyPercent}%` }"
|
||||||
|
/>
|
||||||
|
<view
|
||||||
|
class="stability-progress__marker"
|
||||||
|
:style="{ left: `${stabilityEnergyReqPercent}%` }"
|
||||||
|
/>
|
||||||
|
<text class="stability-progress__value">
|
||||||
|
{{ Math.round(stabilityEnergyPercent) }}%
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="isRhythmTraining">
|
||||||
|
<text class="rhythm-progress__title">{{ rhythmTitle }}</text>
|
||||||
|
<view class="rhythm-progress__track">
|
||||||
|
<view
|
||||||
|
class="rhythm-progress__fill"
|
||||||
|
:class="{
|
||||||
|
'rhythm-progress__fill--shooting': rhythmIsShootWindow,
|
||||||
|
}"
|
||||||
|
:style="{
|
||||||
|
width: `${rhythmProgressPercent}%`,
|
||||||
|
transition: rhythmTransitionStyle,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<view
|
||||||
|
class="rhythm-progress__marker"
|
||||||
|
:style="{ left: `${rhythmMarkerPercent}%` }"
|
||||||
|
/>
|
||||||
|
<text
|
||||||
|
v-if="rhythmRemainingSeconds > 0"
|
||||||
|
class="rhythm-progress__window-label"
|
||||||
|
>{{ rhythmRemainingSeconds }}秒</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class="progress-card__header">
|
||||||
<view class="progress-card__profile">
|
<view class="progress-card__profile">
|
||||||
<view class="progress-card__avatar-shell">
|
<view class="progress-card__avatar-shell">
|
||||||
<Avatar
|
<Avatar
|
||||||
@@ -297,16 +642,16 @@ onBeforeUnmount(() => {
|
|||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
</button> -->
|
</button> -->
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="progress-card__track-wrap">
|
<view class="progress-card__track-wrap">
|
||||||
<image
|
<image
|
||||||
class="progress-card__titile"
|
class="progress-card__titile"
|
||||||
:src="trainingTitleIcon"
|
:src="trainingTitleIcon"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
<view v-if="countdownEnabled" class="progress-card__track">
|
<view v-if="countdownEnabled" class="progress-card__track">
|
||||||
<view
|
<view
|
||||||
class="progress-card__fill"
|
class="progress-card__fill"
|
||||||
:style="{
|
:style="{
|
||||||
width: `${progressPercent}%`,
|
width: `${progressPercent}%`,
|
||||||
@@ -314,13 +659,14 @@ onBeforeUnmount(() => {
|
|||||||
right: tips.includes('红队') ? 0 : 'unset',
|
right: tips.includes('红队') ? 0 : 'unset',
|
||||||
transition: transitionStyle,
|
transition: transitionStyle,
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<view class="progress-card__badge">
|
<view class="progress-card__badge">
|
||||||
<text class="progress-card__badge-text">剩余{{ remain }}秒</text>
|
<text class="progress-card__badge-text">剩余{{ remain }}秒</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- <text v-if="tipContent" class="progress-card__tip">{{ tipContent }}123</text> -->
|
||||||
</view>
|
</view>
|
||||||
<!-- <text v-if="tipContent" class="progress-card__tip">{{ tipContent }}123</text> -->
|
</template>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -459,4 +805,131 @@ onBeforeUnmount(() => {
|
|||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stability-progress {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 32rpx 84rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stability-progress__time {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 48rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stability-progress__track {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 24rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: #444444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stability-progress__fill {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: linear-gradient(90deg, #87f1df 0%, #5ba8e8 100%);
|
||||||
|
transition: width 240ms linear, background 240ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stability-progress__fill--reached {
|
||||||
|
background: linear-gradient(90deg, #a5df62 0%, #61c787 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stability-progress__marker {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 2;
|
||||||
|
width: 4rpx;
|
||||||
|
transform: translateX(-2rpx);
|
||||||
|
background: rgba(26, 24, 22, 0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stability-progress__value {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 3;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #eefaff;
|
||||||
|
font-size: 18rpx;
|
||||||
|
line-height: 24rpx;
|
||||||
|
text-align: center;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 32rpx 84rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress__title {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 42rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress__track {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 24rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: #444444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress__fill {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: linear-gradient(133deg, #ffd19a 0%, #a17636 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress__fill--shooting {
|
||||||
|
background: linear-gradient(90deg, #e2bd2e 0%, #fff047 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress__marker {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 2;
|
||||||
|
width: 4rpx;
|
||||||
|
transform: translateX(-2rpx);
|
||||||
|
background: rgba(26, 24, 22, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rhythm-progress__window-label {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 50%;
|
||||||
|
z-index: 3;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
color: #fff7de;
|
||||||
|
font-size: 18rpx;
|
||||||
|
line-height: 24rpx;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,10 +6,16 @@ import Avatar from "@/components/Avatar.vue";
|
|||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { simulShootAPI } from "@/apis";
|
import { simulShootAPI } from "@/apis";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
|
import {
|
||||||
|
getDistanceCheckAudioKey,
|
||||||
|
getDistanceCheckText,
|
||||||
|
getShootValidation,
|
||||||
|
} from "@/util";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user, device } = storeToRefs(store);
|
const { user, device } = storeToRefs(store);
|
||||||
|
const emit = defineEmits(["passed"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
guide: {
|
guide: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -27,18 +33,46 @@ const props = defineProps({
|
|||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: "",
|
default: "",
|
||||||
},
|
},
|
||||||
|
autoStart: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const arrow = ref({});
|
const arrow = ref({});
|
||||||
const distance = ref(0);
|
const distance = ref(0);
|
||||||
|
const statusText = ref("");
|
||||||
const showsimul = ref(false);
|
const showsimul = ref(false);
|
||||||
const count = ref(props.count);
|
const count = ref(props.count);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
|
const autoStartPending = ref(false);
|
||||||
|
const autoStartTriggered = ref(false);
|
||||||
|
let autoStartTimer = null;
|
||||||
|
const DISTANCE_PASSED_AUDIO_KEY = "站距合格,靶纸正确";
|
||||||
|
const AUTO_START_TIMEOUT_MS = 6000;
|
||||||
|
|
||||||
|
const clearAutoStartTimer = () => {
|
||||||
|
if (!autoStartTimer) return;
|
||||||
|
clearTimeout(autoStartTimer);
|
||||||
|
autoStartTimer = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const triggerAutoStart = () => {
|
||||||
|
if (!autoStartPending.value || autoStartTriggered.value) return;
|
||||||
|
clearAutoStartTimer();
|
||||||
|
autoStartPending.value = false;
|
||||||
|
autoStartTriggered.value = true;
|
||||||
|
emit("passed");
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAudioEnded = (key) => {
|
||||||
|
if (key === DISTANCE_PASSED_AUDIO_KEY) triggerAutoStart();
|
||||||
|
};
|
||||||
|
|
||||||
const updateTimer = (value) => {
|
const updateTimer = (value) => {
|
||||||
count.value = Math.round(value);
|
count.value = Math.round(value);
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
audioManager.play("请射箭测试距离");
|
audioManager.play("请射箭!测试站距与靶纸");
|
||||||
if (props.isBattle) {
|
if (props.isBattle) {
|
||||||
timer.value = setInterval(() => {
|
timer.value = setInterval(() => {
|
||||||
count.value -= 1;
|
count.value -= 1;
|
||||||
@@ -46,23 +80,43 @@ onMounted(() => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
uni.$on("update-timer", updateTimer);
|
uni.$on("update-timer", updateTimer);
|
||||||
|
uni.$on("audioEnded", onAudioEnded);
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
clearAutoStartTimer();
|
||||||
uni.$off("update-timer", updateTimer);
|
uni.$off("update-timer", updateTimer);
|
||||||
|
uni.$off("audioEnded", onAudioEnded);
|
||||||
});
|
});
|
||||||
|
|
||||||
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));
|
if (autoStartPending.value || autoStartTriggered.value) return;
|
||||||
if (distance.value >= 5) audioManager.play("距离合格");
|
const rawDistance = Number(msg.shootData?.distance ?? msg.shootData?.dst);
|
||||||
else audioManager.play("距离不足");
|
distance.value = Number.isFinite(rawDistance)
|
||||||
|
? Number((rawDistance / 100).toFixed(2))
|
||||||
|
: 0;
|
||||||
|
statusText.value = getDistanceCheckText(msg.shootData);
|
||||||
|
const audioKey = getDistanceCheckAudioKey(msg.shootData);
|
||||||
|
const validation = getShootValidation(msg.shootData);
|
||||||
|
if (props.autoStart && validation.distanceOk && validation.targetOk) {
|
||||||
|
autoStartPending.value = true;
|
||||||
|
autoStartTimer = setTimeout(triggerAutoStart, AUTO_START_TIMEOUT_MS);
|
||||||
|
}
|
||||||
|
audioManager.play(audioKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) {
|
||||||
|
await simulShootAPI(
|
||||||
|
device.value.deviceId,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
props.targetType
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -94,14 +148,12 @@ 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="statusText">
|
||||||
<text>当前距离<text class="text-yellow">{{ distance }}</text>米</text>
|
<text>{{ statusText }}</text>
|
||||||
<text v-if="distance >= 5">已达到距离要求</text>
|
|
||||||
<text v-else>请调整站位</text>
|
|
||||||
</block>
|
</block>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<text>请射箭,测试站距</text>
|
<text>请射箭,测试站距与靶纸</text>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-row">
|
<view class="user-row">
|
||||||
@@ -112,7 +164,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>
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
showUnlockProgress: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
completedProgress: {
|
completedProgress: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
@@ -106,6 +110,15 @@ const handleClick = () => {
|
|||||||
<view class="difficulty-badge__label">{{ node.label }}</view>
|
<view class="difficulty-badge__label">{{ node.label }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view
|
||||||
|
v-if="showUnlockProgress"
|
||||||
|
class="difficulty-badge__unlock-progress"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="difficulty-badge__unlock-progress-completed"
|
||||||
|
:style="{ width: `${progressValue}%` }"
|
||||||
|
></view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -315,6 +328,25 @@ const handleClick = () => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.difficulty-badge__unlock-progress {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 30rpx);
|
||||||
|
left: 50%;
|
||||||
|
width: 120rpx;
|
||||||
|
height: 10rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
transform: translateX(-50%);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.difficulty-badge__unlock-progress-completed {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
background: rgba(255, 217, 71, 1);
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes badge-orbit-spin {
|
@keyframes badge-orbit-spin {
|
||||||
from {
|
from {
|
||||||
transform: translate(-50%, -50%) rotate(0deg);
|
transform: translate(-50%, -50%) rotate(0deg);
|
||||||
|
|||||||
@@ -13,7 +13,20 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const previewLines = computed(() => {
|
const previewLines = computed(() => {
|
||||||
return props.lines.map((line) => String(line || "").trim()).filter(Boolean);
|
return props.lines
|
||||||
|
.map((line) => {
|
||||||
|
const rawParts = Array.isArray(line?.parts)
|
||||||
|
? line.parts
|
||||||
|
: [{ text: line }];
|
||||||
|
const parts = rawParts
|
||||||
|
.map((part) => ({
|
||||||
|
text: String(part?.text ?? part ?? "").trim(),
|
||||||
|
}))
|
||||||
|
.filter((part) => part.text);
|
||||||
|
|
||||||
|
return { parts };
|
||||||
|
})
|
||||||
|
.filter((line) => line.parts.length > 0);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -27,13 +40,16 @@ const previewLines = computed(() => {
|
|||||||
<view class="difficulty-preview__content">
|
<view class="difficulty-preview__content">
|
||||||
<text class="difficulty-preview__title">{{ title }}</text>
|
<text class="difficulty-preview__title">{{ title }}</text>
|
||||||
<view class="difficulty-preview__copy">
|
<view class="difficulty-preview__copy">
|
||||||
<text
|
<view
|
||||||
v-for="(line, index) in previewLines"
|
v-for="(line, index) in previewLines"
|
||||||
:key="`${line}-${index}`"
|
:key="index"
|
||||||
class="difficulty-preview__line"
|
class="difficulty-preview__line"
|
||||||
>
|
>
|
||||||
{{ line }}
|
<text
|
||||||
</text>
|
v-for="(part, partIndex) in line.parts"
|
||||||
|
:key="partIndex"
|
||||||
|
>{{ part.text }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -53,7 +69,7 @@ const previewLines = computed(() => {
|
|||||||
.difficulty-preview__content {
|
.difficulty-preview__content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 30rpx;
|
left: 40rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 486rpx;
|
width: 486rpx;
|
||||||
height: 93%;
|
height: 93%;
|
||||||
@@ -86,6 +102,4 @@ const previewLines = computed(() => {
|
|||||||
.difficulty-preview__line {
|
.difficulty-preview__line {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Container from "@/components/Container.vue";
|
|||||||
import TrainingDifficultyBadge from "./components/TrainingDifficultyBadge.vue";
|
import TrainingDifficultyBadge from "./components/TrainingDifficultyBadge.vue";
|
||||||
import TrainingDifficultyPreviewCard from "./components/TrainingDifficultyPreviewCard.vue";
|
import TrainingDifficultyPreviewCard from "./components/TrainingDifficultyPreviewCard.vue";
|
||||||
import TrainingDifficultyStartButton from "./components/TrainingDifficultyStartButton.vue";
|
import TrainingDifficultyStartButton from "./components/TrainingDifficultyStartButton.vue";
|
||||||
|
import audioManager from "@/audioManager";
|
||||||
import {
|
import {
|
||||||
createPractiseV2API,
|
createPractiseV2API,
|
||||||
endPractiseAPI,
|
endPractiseAPI,
|
||||||
@@ -12,7 +13,7 @@ import {
|
|||||||
} from "@/apis";
|
} from "@/apis";
|
||||||
|
|
||||||
// 难度页接口数据源:
|
// 难度页接口数据源:
|
||||||
// 1. 接口:GET /training/difficulty/list?type=base/endurance/precision/rhythm
|
// 1. 接口:GET /training/difficulty/list?type=base/endurance/precision/rhythm/stability
|
||||||
// 2. 当前进度:接口 user_levels / list.completed,路由参数可覆盖选中难度
|
// 2. 当前进度:接口 user_levels / list.completed,路由参数可覆盖选中难度
|
||||||
const trainingDifficultyStorageKey = "training-selection";
|
const trainingDifficultyStorageKey = "training-selection";
|
||||||
const defaultTrainingType = "precision";
|
const defaultTrainingType = "precision";
|
||||||
@@ -34,6 +35,10 @@ const trainingTypeMetaMap = {
|
|||||||
key: "rhythm",
|
key: "rhythm",
|
||||||
title: "节奏训练",
|
title: "节奏训练",
|
||||||
},
|
},
|
||||||
|
stability: {
|
||||||
|
key: "stability",
|
||||||
|
title: "稳定训练",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const routeModeTypeMap = {
|
const routeModeTypeMap = {
|
||||||
basic: "base",
|
basic: "base",
|
||||||
@@ -41,6 +46,9 @@ const routeModeTypeMap = {
|
|||||||
endurance: "endurance",
|
endurance: "endurance",
|
||||||
precision: "precision",
|
precision: "precision",
|
||||||
rhythm: "rhythm",
|
rhythm: "rhythm",
|
||||||
|
stability: "stability",
|
||||||
|
// 兼容历史上已经分享出去的 power 深链,实际创建仍统一传 stability。
|
||||||
|
power: "stability",
|
||||||
};
|
};
|
||||||
const defaultTargetType = 1;
|
const defaultTargetType = 1;
|
||||||
|
|
||||||
@@ -82,10 +90,6 @@ const checkDifficultyCompleted = (item = {}) => {
|
|||||||
return Boolean(item.completed) || (promoteCnt > 0 && completedCnt >= promoteCnt);
|
return Boolean(item.completed) || (promoteCnt > 0 && completedCnt >= promoteCnt);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDifficultyModeText = (mode) => {
|
|
||||||
return Number(mode) === 1 ? "随机区域+指定环数" : "随机区域命中";
|
|
||||||
};
|
|
||||||
|
|
||||||
const createEmptyModeConfig = (type = defaultTrainingType) => {
|
const createEmptyModeConfig = (type = defaultTrainingType) => {
|
||||||
const meta = trainingTypeMetaMap[type] || trainingTypeMetaMap[defaultTrainingType];
|
const meta = trainingTypeMetaMap[type] || trainingTypeMetaMap[defaultTrainingType];
|
||||||
|
|
||||||
@@ -106,41 +110,52 @@ 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 energyReqPercent = toNumber(item.energy_req_percent);
|
||||||
const promoteCnt = toNumber(item.promote_cnt);
|
const shootingTimeText =
|
||||||
const timeText = timeLimit > 0 ? `${timeLimit}秒内完成` : "不限时完成";
|
timeLimit > 0 ? `在${timeLimit}秒内进行射箭` : "不限时进行射箭";
|
||||||
const promoteText = promoteCnt > 0 ? `完成${promoteCnt}次晋级` : "";
|
const enduranceTimeText =
|
||||||
|
timeLimit > 0
|
||||||
|
? `在${timeLimit}秒内完成${arrows}箭`
|
||||||
|
: `不限时完成${arrows}箭`;
|
||||||
|
|
||||||
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}秒射击`,
|
arrows > 0
|
||||||
[
|
? `需要在指定时间节点射出${arrows}射箭`
|
||||||
`${arrows}箭`,
|
: "需要在指定时间节点射箭",
|
||||||
hitReq > 0 ? `每箭${hitReq}环以上` : "上靶即可",
|
hitReq > 0 ? `且每箭命中${hitReq}环内` : "且每箭命中指定区域",
|
||||||
getDifficultyModeText(item.mode),
|
],
|
||||||
promoteText,
|
stability: [
|
||||||
]
|
{
|
||||||
.filter(Boolean)
|
parts: [
|
||||||
.join(" · "),
|
{ text: timeLimit > 0 ? "在" : "" },
|
||||||
|
{
|
||||||
|
text: timeLimit > 0 ? `${timeLimit}秒` : "不限时",
|
||||||
|
highlight: true,
|
||||||
|
},
|
||||||
|
{ text: timeLimit > 0 ? "内射箭,命中" : "射箭,命中" },
|
||||||
|
{ text: `${hitReq}环`, highlight: true },
|
||||||
|
{ text: "可获得能量" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parts: [
|
||||||
|
{ text: "计时结束能量需要大于" },
|
||||||
|
{ text: `${energyReqPercent}%`, highlight: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -444,6 +459,16 @@ const selectedDifficulty = computed(() => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const targetTypeImageMap = {
|
||||||
|
20: "https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/20cm.png",
|
||||||
|
40: "https://static.shelingxingqiu.com/shootmini/static/training-difficulty-design/40cm.png",
|
||||||
|
};
|
||||||
|
|
||||||
|
// 根据接口返回的 target_type 展示当前难度使用的靶纸类型。
|
||||||
|
const selectedTargetTypeImage = computed(() => {
|
||||||
|
return targetTypeImageMap[toNumber(selectedDifficulty.value?.target_type)] || "";
|
||||||
|
});
|
||||||
|
|
||||||
// 优先显示配置中的难度进度;没有配置时,再按已解锁等级推导完成态。
|
// 优先显示配置中的难度进度;没有配置时,再按已解锁等级推导完成态。
|
||||||
const getCompletedDifficultyProgress = (node) => {
|
const getCompletedDifficultyProgress = (node) => {
|
||||||
const configuredProgress = Number(difficultyProgressMap.value[node?.id]);
|
const configuredProgress = Number(difficultyProgressMap.value[node?.id]);
|
||||||
@@ -604,6 +629,23 @@ const createPracticeQuery = (difficulty) => {
|
|||||||
rhythm: {
|
rhythm: {
|
||||||
hitReq: toNumber(difficulty.hit_req),
|
hitReq: toNumber(difficulty.hit_req),
|
||||||
mode: toNumber(difficulty.mode),
|
mode: toNumber(difficulty.mode),
|
||||||
|
roundTime: toNumber(difficulty.round_time ?? difficulty.roundTime),
|
||||||
|
shootTime: toNumber(difficulty.shoot_time ?? difficulty.shootTime),
|
||||||
|
},
|
||||||
|
stability: {
|
||||||
|
hitReq: toNumber(difficulty.hit_req),
|
||||||
|
scoreSlot: toNumber(
|
||||||
|
difficulty.score_slot ?? difficulty.scoreSlot
|
||||||
|
),
|
||||||
|
energyPerHit: toNumber(
|
||||||
|
difficulty.energy_per_hit ?? difficulty.energyPerHit
|
||||||
|
),
|
||||||
|
energyCostPerSec: toNumber(
|
||||||
|
difficulty.energy_cost_per_sec ?? difficulty.energyCostPerSec
|
||||||
|
),
|
||||||
|
energyReqPercent: toNumber(
|
||||||
|
difficulty.energy_req_percent ?? difficulty.energyReqPercent
|
||||||
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -637,6 +679,21 @@ const saveTrainingContext = (practice = {}) => {
|
|||||||
difficultyLabel: difficulty.label,
|
difficultyLabel: difficulty.label,
|
||||||
targetType: defaultTargetType,
|
targetType: defaultTargetType,
|
||||||
targetPaperType: difficulty.targetPaperType,
|
targetPaperType: difficulty.targetPaperType,
|
||||||
|
roundTime: toNumber(difficulty.round_time ?? difficulty.roundTime),
|
||||||
|
shootTime: toNumber(difficulty.shoot_time ?? difficulty.shootTime),
|
||||||
|
hitReq: toNumber(difficulty.hit_req ?? difficulty.hitReq),
|
||||||
|
scoreSlot: toNumber(
|
||||||
|
difficulty.score_slot ?? difficulty.scoreSlot
|
||||||
|
),
|
||||||
|
energyPerHit: toNumber(
|
||||||
|
difficulty.energy_per_hit ?? difficulty.energyPerHit
|
||||||
|
),
|
||||||
|
energyCostPerSec: toNumber(
|
||||||
|
difficulty.energy_cost_per_sec ?? difficulty.energyCostPerSec
|
||||||
|
),
|
||||||
|
energyReqPercent: toNumber(
|
||||||
|
difficulty.energy_req_percent ?? difficulty.energyReqPercent
|
||||||
|
),
|
||||||
practiceId: practice.id || "",
|
practiceId: practice.id || "",
|
||||||
serverAddr: practice.serverAddr || "",
|
serverAddr: practice.serverAddr || "",
|
||||||
createdAt: practice.id ? Date.now() : 0,
|
createdAt: practice.id ? Date.now() : 0,
|
||||||
@@ -676,6 +733,8 @@ const handleSelectDifficulty = (node) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audioManager.play("点击按钮");
|
||||||
|
|
||||||
if (node.id === selectedDifficultyId.value) {
|
if (node.id === selectedDifficultyId.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -793,6 +852,7 @@ onShow(() => {
|
|||||||
:node="node"
|
:node="node"
|
||||||
:active="node.id === selectedDifficultyId"
|
:active="node.id === selectedDifficultyId"
|
||||||
:locked="checkDifficultyLocked(node)"
|
:locked="checkDifficultyLocked(node)"
|
||||||
|
:showUnlockProgress="node.id === unlockedDifficultyId"
|
||||||
:completedProgress="getCompletedDifficultyProgress(node)"
|
:completedProgress="getCompletedDifficultyProgress(node)"
|
||||||
@click="handleSelectDifficulty"
|
@click="handleSelectDifficulty"
|
||||||
/>
|
/>
|
||||||
@@ -805,12 +865,18 @@ onShow(() => {
|
|||||||
:title="selectedDifficulty.title"
|
:title="selectedDifficulty.title"
|
||||||
:lines="selectedDifficulty.summary"
|
:lines="selectedDifficulty.summary"
|
||||||
/>
|
/>
|
||||||
|
<image
|
||||||
|
v-if="selectedTargetTypeImage"
|
||||||
|
class="difficulty-page__target-type"
|
||||||
|
:src="selectedTargetTypeImage"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="difficulty-page__start">
|
<view class="difficulty-page__start">
|
||||||
<TrainingDifficultyStartButton
|
<TrainingDifficultyStartButton
|
||||||
:text="selectedDifficulty.startText"
|
:text="selectedDifficulty.startText"
|
||||||
@click="handleStart"
|
@click="$clickSound(handleStart)"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -863,6 +929,16 @@ onShow(() => {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.difficulty-page__target-type {
|
||||||
|
position: absolute;
|
||||||
|
top: 10rpx;
|
||||||
|
left: 2rpx;
|
||||||
|
z-index: 2;
|
||||||
|
width: 100rpx;
|
||||||
|
height: 74rpx;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.difficulty-page__start {
|
.difficulty-page__start {
|
||||||
position: relative;
|
position: relative;
|
||||||
flex: none;
|
flex: none;
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ const trainingModeRouteMap = {
|
|||||||
endurance: "endurance",
|
endurance: "endurance",
|
||||||
precision: "precision",
|
precision: "precision",
|
||||||
rhythm: "rhythm",
|
rhythm: "rhythm",
|
||||||
strength: "power",
|
stability: "stability",
|
||||||
};
|
};
|
||||||
const unavailableTrainingIds = new Set(["rhythm", "strength"]);
|
const unavailableTrainingIds = new Set();
|
||||||
// 训练项目卡片右侧主图标。
|
// 训练项目卡片右侧主图标。
|
||||||
const trainingModeIconMap = {
|
const trainingModeIconMap = {
|
||||||
base_bow:
|
base_bow:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/training-home/img_3.png",
|
"https://static.shelingxingqiu.com/shootmini/static/training-home/img_3.png",
|
||||||
bow: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_4.png",
|
bow: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_5.png",
|
||||||
target:
|
target:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/training-home/img_5.png",
|
"https://static.shelingxingqiu.com/shootmini/static/training-home/img_4.png",
|
||||||
wave: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_6.png",
|
wave: "https://static.shelingxingqiu.com/shootmini/static/training-home/img_6.png",
|
||||||
muscle:
|
muscle:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/training-home/img_6.png",
|
"https://static.shelingxingqiu.com/shootmini/static/training-home/img_7.png",
|
||||||
};
|
};
|
||||||
// 训练项目卡片标题图,按接口 id 映射 CDN 资源。
|
// 训练项目卡片标题图,按接口 id 映射 CDN 资源。
|
||||||
const trainingModeTitleImageMap = {
|
const trainingModeTitleImageMap = {
|
||||||
@@ -39,21 +39,22 @@ const trainingModeTitleImageMap = {
|
|||||||
"https://static.shelingxingqiu.com/shootmini/static/training-home/jingzhunxunlian.png",
|
"https://static.shelingxingqiu.com/shootmini/static/training-home/jingzhunxunlian.png",
|
||||||
rhythm:
|
rhythm:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/training-home/jiezouxunlian.png",
|
"https://static.shelingxingqiu.com/shootmini/static/training-home/jiezouxunlian.png",
|
||||||
strength:
|
stability:
|
||||||
"https://static.shelingxingqiu.com/shootmini/static/training-home/liliangxulian.png",
|
"https://static.shelingxingqiu.com/shootmini/static/training-home/wendingxunlian.png",
|
||||||
};
|
};
|
||||||
const defaultWeekDays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
|
const defaultWeekDays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
|
||||||
const defaultRadarDimensions = [
|
const defaultRadarDimensions = [
|
||||||
{ name: "基础", score: 0 },
|
{ name: "基础", score: 0 },
|
||||||
{ name: "精准", score: 0 },
|
{ name: "精准", score: 0 },
|
||||||
{ name: "力量", score: 0 },
|
{ name: "稳定", score: 0 },
|
||||||
{ name: "节奏", score: 0 },
|
{ name: "节奏", score: 0 },
|
||||||
{ name: "耐力", score: 0 },
|
{ name: "耐力", score: 0 },
|
||||||
];
|
];
|
||||||
const radarDimensionTrainingIdMap = Object.freeze({
|
const radarDimensionTrainingIdMap = Object.freeze({
|
||||||
基础: "base",
|
基础: "base",
|
||||||
精准: "precision",
|
精准: "precision",
|
||||||
力量: "strength",
|
稳定: "stability",
|
||||||
|
力量: "stability",
|
||||||
节奏: "rhythm",
|
节奏: "rhythm",
|
||||||
耐力: "endurance",
|
耐力: "endurance",
|
||||||
});
|
});
|
||||||
@@ -64,9 +65,9 @@ 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,
|
average_ring: 0,
|
||||||
},
|
},
|
||||||
beat_percent: 0,
|
beat_percent: 0,
|
||||||
radar_max: 0,
|
radar_max: 0,
|
||||||
@@ -124,20 +125,20 @@ const formatValue = (value, digits = 1) => {
|
|||||||
return String(Number(numberValue.toFixed(digits)));
|
return String(Number(numberValue.toFixed(digits)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatCompactCount = (value) => {
|
||||||
|
const numberValue = Number(value);
|
||||||
|
if (!Number.isFinite(numberValue)) return "--";
|
||||||
|
if (numberValue >= 10000) return `${formatValue(numberValue / 1000)}K`;
|
||||||
|
return formatValue(numberValue, 0);
|
||||||
|
};
|
||||||
|
|
||||||
const getLevelText = (item) => {
|
const getLevelText = (item) => {
|
||||||
if (!item) return "";
|
if (!item) return "";
|
||||||
const level = Number(item.current_level) || 0;
|
const level = Number(item.current_level) || 0;
|
||||||
return `当前进度 LV${level} >`;
|
return `当前进度 LV${level} >`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 卡路里字段按需求做 K / W 缩写展示。
|
const getAverageRingValue = (value) => formatValue(value);
|
||||||
const getCaloriesValue = (value) => {
|
|
||||||
const numberValue = Number(value);
|
|
||||||
if (!Number.isFinite(numberValue)) return "--";
|
|
||||||
if (numberValue >= 10000) return `${formatValue(numberValue / 10000)}W`;
|
|
||||||
if (numberValue >= 1000) return `${formatValue(numberValue / 1000)}K`;
|
|
||||||
return formatValue(numberValue, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getTrainingIcon = (item = {}) =>
|
const getTrainingIcon = (item = {}) =>
|
||||||
trainingModeIconMap[item.icon] || trainingModeIconMap.bow;
|
trainingModeIconMap[item.icon] || trainingModeIconMap.bow;
|
||||||
@@ -286,9 +287,9 @@ 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,
|
average_ring: result?.stats?.average_ring ?? 0,
|
||||||
},
|
},
|
||||||
beat_percent: result?.beat_percent ?? 0,
|
beat_percent: result?.beat_percent ?? 0,
|
||||||
radar_max: result?.radar_max ?? 0,
|
radar_max: result?.radar_max ?? 0,
|
||||||
@@ -418,7 +419,7 @@ 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.total_arrows, 0) }}
|
{{ formatCompactCount(trainingData.stats.total_arrows) }}
|
||||||
</text>
|
</text>
|
||||||
<text class="stats-unit">支</text>
|
<text class="stats-unit">支</text>
|
||||||
<view class="stats-value-decoration"></view>
|
<view class="stats-value-decoration"></view>
|
||||||
@@ -431,45 +432,45 @@ 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) }}
|
{{ formatCompactCount(trainingData.stats.ten_ring_count) }}
|
||||||
</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">
|
||||||
<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">
|
||||||
{{ getCaloriesValue(trainingData.stats.total_calories) }}
|
{{ getAverageRingValue(trainingData.stats.average_ring) }}
|
||||||
</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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="radar-section">
|
<view class="radar-section">
|
||||||
<view class="record-bubble" @click="openTrainingRecord">
|
<view class="record-bubble" @click="$clickSound(openTrainingRecord)">
|
||||||
<image
|
<image
|
||||||
class="record-bubble-bg"
|
class="record-bubble-bg"
|
||||||
src="https://static.shelingxingqiu.com/shootmini/static/training-home/img_28.png"
|
src="https://static.shelingxingqiu.com/shootmini/static/training-home/img_28.png"
|
||||||
@@ -483,7 +484,7 @@ onShow(async () => {
|
|||||||
<text class="record-sub-text">我的训练记录</text>
|
<text class="record-sub-text">我的训练记录</text>
|
||||||
<image
|
<image
|
||||||
class="record-arrow"
|
class="record-arrow"
|
||||||
src="https://static.shelingxingqiu.com/shootmini/static/training-home/img_7.png"
|
src="https://static.shelingxingqiu.com/shootmini/static/training-home/img_right.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
@@ -530,24 +531,31 @@ onShow(async () => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="featured-card" @click="openRoutineTraining">
|
|
||||||
<image
|
|
||||||
class="featured-card-bg"
|
|
||||||
src="https://static.shelingxingqiu.com/shootmini/static/training-home/img_22.png"
|
|
||||||
mode="widthFix"
|
|
||||||
/>
|
|
||||||
<view class="featured-card-mask"></view>
|
|
||||||
<view class="featured-card-copy">
|
|
||||||
<text class="featured-card-subtitle">12箭练习</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mode-grid">
|
<view class="mode-grid">
|
||||||
|
<view
|
||||||
|
class="mode-card"
|
||||||
|
@click="$clickSound(openRoutineTraining)"
|
||||||
|
>
|
||||||
|
<view class="mode-card-copy">
|
||||||
|
<image
|
||||||
|
class="mode-card-title-image"
|
||||||
|
src="https://static.shelingxingqiu.com/shootmini/static/training-home/ziyouxunlian.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
<text class="mode-card-progress">无级别限制</text>
|
||||||
|
</view>
|
||||||
|
<image
|
||||||
|
class="mode-card-icon"
|
||||||
|
src="https://static.shelingxingqiu.com/shootmini/static/training-home/img_2.png"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="item in visibleTrainingItems"
|
v-for="item in visibleTrainingItems"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="mode-card"
|
class="mode-card"
|
||||||
@click="openTrainingItem(item)"
|
@click="$clickSound(() => openTrainingItem(item))"
|
||||||
>
|
>
|
||||||
<view v-if="item.id === recommendedTrainingId" class="mode-tag">
|
<view v-if="item.id === recommendedTrainingId" class="mode-tag">
|
||||||
推荐
|
推荐
|
||||||
@@ -572,6 +580,7 @@ onShow(async () => {
|
|||||||
</view>
|
</view>
|
||||||
<TargetPicker
|
<TargetPicker
|
||||||
:show="showRoutineTargetPicker"
|
:show="showRoutineTargetPicker"
|
||||||
|
:clickSound="true"
|
||||||
:onClose="() => (showRoutineTargetPicker = false)"
|
:onClose="() => (showRoutineTargetPicker = false)"
|
||||||
:onConfirm="handleRoutineTargetConfirm"
|
:onConfirm="handleRoutineTargetConfirm"
|
||||||
/>
|
/>
|
||||||
@@ -742,7 +751,7 @@ onShow(async () => {
|
|||||||
|
|
||||||
.radar-section {
|
.radar-section {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-top: 34rpx;
|
padding-top: 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.record-bubble {
|
.record-bubble {
|
||||||
@@ -859,52 +868,6 @@ onShow(async () => {
|
|||||||
width: 92rpx;
|
width: 92rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.featured-card {
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
height: 150rpx;
|
|
||||||
margin-top: 70rpx;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.featured-card-bg {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.featured-card-mask {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
width: 278rpx;
|
|
||||||
height: 150rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.featured-card-copy {
|
|
||||||
position: absolute;
|
|
||||||
left: 174rpx;
|
|
||||||
top: 58rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.featured-card-title {
|
|
||||||
display: block;
|
|
||||||
color: #895409;
|
|
||||||
font-size: 34rpx;
|
|
||||||
font-family: "AlimamaShuHeiTi-Bold", "PingFang SC", sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
line-height: 42rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.featured-card-subtitle {
|
|
||||||
display: block;
|
|
||||||
margin-top: 10rpx;
|
|
||||||
color: #895409;
|
|
||||||
font-size: 22rpx;
|
|
||||||
line-height: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mode-grid {
|
.mode-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
@@ -914,11 +877,11 @@ onShow(async () => {
|
|||||||
|
|
||||||
.mode-card {
|
.mode-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 150rpx;
|
height: 130rpx;
|
||||||
box-shadow: inset 2rpx 2rpx 6rpx 0rpx rgba(255, 255, 255, 0.27);
|
box-shadow: inset 2rpx 2rpx 6rpx 0rpx rgba(255, 255, 255, 0.27);
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
border: 2rpx solid rgba(235, 184, 123, 0.5);
|
border: 2rpx solid rgba(235, 184, 123, 0.5);
|
||||||
background: rgba(0, 0, 0, 0.5);
|
/* background: rgba(0, 0, 0, 0.5); */
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -927,8 +890,8 @@ onShow(async () => {
|
|||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 72rpx;
|
width: 72rpx;
|
||||||
height: 34rpx;
|
height: 28rpx;
|
||||||
line-height: 34rpx;
|
line-height: 28rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 20rpx;
|
font-size: 20rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
@@ -939,7 +902,7 @@ onShow(async () => {
|
|||||||
.mode-card-copy {
|
.mode-card-copy {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 30rpx;
|
left: 30rpx;
|
||||||
top: 40rpx;
|
top: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-card-title {
|
.mode-card-title {
|
||||||
@@ -967,16 +930,16 @@ onShow(async () => {
|
|||||||
display: block;
|
display: block;
|
||||||
margin-top: 14rpx;
|
margin-top: 14rpx;
|
||||||
color: #fcce96;
|
color: #fcce96;
|
||||||
font-size: 22rpx;
|
font-size: 20rpx;
|
||||||
line-height: 32rpx;
|
line-height: 28rpx;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-card-icon {
|
.mode-card-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 12rpx;
|
right: 18rpx;
|
||||||
top: 14rpx;
|
top: 8rpx;
|
||||||
width: 124rpx;
|
width: 116rpx;
|
||||||
height: 124rpx;
|
height: 116rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,13 +4,21 @@ 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";
|
||||||
import TestDistance from "./components/TestDistance.vue";
|
import TestDistance from "./components/TestDistance.vue";
|
||||||
import BubbleTip from "./components/BubbleTip.vue";
|
import BubbleTip from "./components/BubbleTip.vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager, {
|
||||||
|
getPrecisionShotAudioKeys,
|
||||||
|
getRhythmShotAudioKeys,
|
||||||
|
getStabilityShotAudioKeys,
|
||||||
|
getTrainingStartAudioKey,
|
||||||
|
RHYTHM_SHOOT_WINDOW_AUDIO_KEY,
|
||||||
|
STABILITY_ENERGY_50_AUDIO_KEY,
|
||||||
|
STABILITY_ENERGY_70_AUDIO_KEY,
|
||||||
|
} from "@/audioManager";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createPractiseV2API,
|
createPractiseV2API,
|
||||||
@@ -23,12 +31,13 @@ import {
|
|||||||
import {
|
import {
|
||||||
connectMatchWebSocket,
|
connectMatchWebSocket,
|
||||||
closeMatchWebSocket,
|
closeMatchWebSocket,
|
||||||
|
requestPracticeInfoSync,
|
||||||
setMatchAppHideResumable,
|
setMatchAppHideResumable,
|
||||||
MATCH_WS_PRACTICE_SYNC_EVENT,
|
MATCH_WS_PRACTICE_SYNC_EVENT,
|
||||||
MATCH_WS_STATE_EVENT,
|
MATCH_WS_STATE_EVENT,
|
||||||
} from "@/matchWebsocket";
|
} from "@/matchWebsocket";
|
||||||
import { sharePractiseData } from "@/canvas";
|
import { sharePractiseData } from "@/canvas";
|
||||||
import { wxShare, debounce, getDirectionText } from "@/util";
|
import { wxShare, debounce, getDirectionText, capsuleHeight } from "@/util";
|
||||||
import { MESSAGETYPESV2, roundsName } from "@/constants";
|
import { MESSAGETYPESV2, roundsName } from "@/constants";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -38,6 +47,7 @@ const { user } = storeToRefs(store);
|
|||||||
|
|
||||||
const sound = ref(true);
|
const sound = ref(true);
|
||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
|
const practiceStarting = ref(false);
|
||||||
const pageStages = Object.freeze({
|
const pageStages = Object.freeze({
|
||||||
DISTANCE: "distance",
|
DISTANCE: "distance",
|
||||||
SHOOTING: "shooting",
|
SHOOTING: "shooting",
|
||||||
@@ -46,8 +56,29 @@ const pageStages = Object.freeze({
|
|||||||
});
|
});
|
||||||
const pageStage = ref(pageStages.LOADING);
|
const pageStage = ref(pageStages.LOADING);
|
||||||
const scores = ref([]);
|
const scores = ref([]);
|
||||||
|
// 复用金币模块的标题视觉,但保留练习页默认 Header,避免影响返回按钮。
|
||||||
|
const rhythmHeaderTitleStyle = Object.freeze({
|
||||||
|
position: "fixed",
|
||||||
|
top: `${capsuleHeight}px`,
|
||||||
|
left: "50%",
|
||||||
|
width: "430rpx",
|
||||||
|
height: "50px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
transform: "translateX(-50%)",
|
||||||
|
color: "#e7ba80",
|
||||||
|
fontSize: "30rpx",
|
||||||
|
lineHeight: "42rpx",
|
||||||
|
fontWeight: 500,
|
||||||
|
textAlign: "center",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
zIndex: 20,
|
||||||
|
});
|
||||||
// 只在实时 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);
|
||||||
@@ -60,6 +91,17 @@ const tips = ref("");
|
|||||||
const targetType = ref(defaultTargetType);
|
const targetType = ref(defaultTargetType);
|
||||||
const trainingParams = ref({});
|
const trainingParams = ref({});
|
||||||
const practiceInfo = ref({});
|
const practiceInfo = ref({});
|
||||||
|
const simulatorTargetType = computed(() => {
|
||||||
|
const currentTargetType = Number(practiceInfo.value.targetType);
|
||||||
|
if ([20, 40].includes(currentTargetType)) return currentTargetType;
|
||||||
|
return [2, 40].includes(Number(targetType.value)) ? 40 : 20;
|
||||||
|
});
|
||||||
|
const rhythmServerTimestamp = ref(0);
|
||||||
|
const rhythmFallbackWindowStart = ref(0);
|
||||||
|
const rhythmFallbackTimestamp = ref(0);
|
||||||
|
const rhythmHasActiveServerAnchor = ref(false);
|
||||||
|
// 节奏训练目标箭数以服务端 total_arrows 为准;首帧缺失时用 arrows_left 初始化并保持稳定。
|
||||||
|
const rhythmTargetArrows = ref(0);
|
||||||
// 服务端状态立即落到 practiceInfo,精准训练的目标区域单独延迟展示。
|
// 服务端状态立即落到 practiceInfo,精准训练的目标区域单独延迟展示。
|
||||||
const visiblePrecisionTarget = ref({
|
const visiblePrecisionTarget = ref({
|
||||||
randomBlock: 0,
|
randomBlock: 0,
|
||||||
@@ -97,6 +139,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 +150,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);
|
||||||
@@ -215,6 +272,96 @@ const loadNextDifficultyState = (result = {}) => {
|
|||||||
// time_limit 缺失或非正数都表示整局不限时。
|
// time_limit 缺失或非正数都表示整局不限时。
|
||||||
const timeLimit = computed(() => getPositiveInteger(practiceInfo.value.timeLimit));
|
const timeLimit = computed(() => getPositiveInteger(practiceInfo.value.timeLimit));
|
||||||
const hasTimeLimit = computed(() => timeLimit.value > 0);
|
const hasTimeLimit = computed(() => timeLimit.value > 0);
|
||||||
|
const isRhythmTraining = computed(() => trainingType.value === "rhythm");
|
||||||
|
const isStabilityTraining = computed(
|
||||||
|
() => trainingType.value === "stability"
|
||||||
|
);
|
||||||
|
const rhythmRoundTime = computed(() =>
|
||||||
|
getPositiveInteger(practiceInfo.value.roundTime) ||
|
||||||
|
getPositiveInteger(trainingParams.value.roundTime)
|
||||||
|
);
|
||||||
|
const rhythmShootTime = computed(() =>
|
||||||
|
getPositiveInteger(practiceInfo.value.shootTime) ||
|
||||||
|
getPositiveInteger(trainingParams.value.shootTime)
|
||||||
|
);
|
||||||
|
const rhythmShootWindowStart = computed(() => {
|
||||||
|
if (rhythmHasActiveServerAnchor.value) {
|
||||||
|
return practiceInfo.value.shootWindowStart || 0;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
rhythmFallbackWindowStart.value ||
|
||||||
|
practiceInfo.value.shootWindowStart ||
|
||||||
|
0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const rhythmCountdownTimestamp = computed(() =>
|
||||||
|
rhythmHasActiveServerAnchor.value
|
||||||
|
? rhythmServerTimestamp.value
|
||||||
|
: rhythmFallbackTimestamp.value || rhythmServerTimestamp.value
|
||||||
|
);
|
||||||
|
const rhythmInShootWindow = computed(
|
||||||
|
() => practiceInfo.value.inShootWindow === true
|
||||||
|
);
|
||||||
|
const rhythmHitReq = computed(
|
||||||
|
() =>
|
||||||
|
getPositiveInteger(practiceInfo.value.hitReq) ||
|
||||||
|
getPositiveInteger(trainingParams.value.hitReq)
|
||||||
|
);
|
||||||
|
|
||||||
|
const stabilityEnergyReqPercent = computed(() =>
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(
|
||||||
|
100,
|
||||||
|
getPracticeNumber(
|
||||||
|
practiceInfo.value.energyReqPercent,
|
||||||
|
trainingParams.value.energyReqPercent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const stabilityScoreSlot = computed(() =>
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
getPracticeNumber(
|
||||||
|
practiceInfo.value.scoreSlot,
|
||||||
|
trainingParams.value.scoreSlot
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const stabilityCurrentEnergy = computed(() => {
|
||||||
|
const currentEnergy = Math.max(
|
||||||
|
0,
|
||||||
|
getPracticeNumber(practiceInfo.value.currentEnergy)
|
||||||
|
);
|
||||||
|
return stabilityScoreSlot.value > 0
|
||||||
|
? Math.min(stabilityScoreSlot.value, currentEnergy)
|
||||||
|
: currentEnergy;
|
||||||
|
});
|
||||||
|
const stabilityEnergyPercent = computed(() => {
|
||||||
|
if (stabilityScoreSlot.value <= 0) return 0;
|
||||||
|
return Math.min(
|
||||||
|
100,
|
||||||
|
(stabilityCurrentEnergy.value / stabilityScoreSlot.value) * 100
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const initializeRhythmFirstRoundCountdown = () => {
|
||||||
|
rhythmHasActiveServerAnchor.value = false;
|
||||||
|
rhythmFallbackWindowStart.value = 0;
|
||||||
|
rhythmFallbackTimestamp.value = 0;
|
||||||
|
if (!isRhythmTraining.value) return;
|
||||||
|
|
||||||
|
const roundTime = rhythmRoundTime.value;
|
||||||
|
const shootTime = rhythmShootTime.value;
|
||||||
|
if (!roundTime || !shootTime || shootTime > roundTime) return;
|
||||||
|
|
||||||
|
const localNow = Date.now();
|
||||||
|
rhythmFallbackTimestamp.value = localNow;
|
||||||
|
// shootWindowStart 位于整轮最后 shootTime 秒的起点。
|
||||||
|
rhythmFallbackWindowStart.value =
|
||||||
|
localNow + (roundTime - shootTime) * 1000;
|
||||||
|
};
|
||||||
|
|
||||||
const precisionBlocks = computed(() => {
|
const precisionBlocks = computed(() => {
|
||||||
if (useHighlightTest.value) {
|
if (useHighlightTest.value) {
|
||||||
@@ -253,17 +400,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,40 +434,94 @@ 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: "箭" },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trainingType.value === "rhythm") {
|
||||||
|
const targetArrows = getPositiveInteger(rhythmTargetArrows.value);
|
||||||
|
const arrowsLeft = Math.min(
|
||||||
|
targetArrows,
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
getPracticeNumber(practiceInfo.value.arrowsLeft, targetArrows)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const completedArrows = targetArrows - arrowsLeft;
|
||||||
|
const hitReq = rhythmHitReq.value;
|
||||||
|
|
||||||
|
return {
|
||||||
|
inline: true,
|
||||||
|
details: [
|
||||||
|
{ text: "在进度条读取到高亮区间时射箭命中" },
|
||||||
|
{
|
||||||
|
text: hitReq > 0 ? `${hitReq}环内` : "指定区域",
|
||||||
|
highlight: true,
|
||||||
|
},
|
||||||
|
{ text: ",需完成" },
|
||||||
|
{ text: `(${completedArrows}/${targetArrows})`, highlight: true },
|
||||||
|
{ text: "箭" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trainingType.value === "stability") {
|
||||||
|
const hitReq = getPracticeNumber(
|
||||||
|
practiceInfo.value.hitReq,
|
||||||
|
trainingParams.value.hitReq
|
||||||
|
);
|
||||||
|
const stabilityTimeLimit = getPracticeNumber(
|
||||||
|
practiceInfo.value.timeLimit,
|
||||||
|
trainingParams.value.timeLimit
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
inline: true,
|
||||||
|
details: [
|
||||||
|
{ text: stabilityTimeLimit > 0 ? "在" : "" },
|
||||||
|
{
|
||||||
|
text: stabilityTimeLimit > 0 ? `${stabilityTimeLimit}秒` : "不限时",
|
||||||
|
highlight: true,
|
||||||
|
},
|
||||||
|
{ text: stabilityTimeLimit > 0 ? "内射箭,命中" : "射箭,命中" },
|
||||||
|
{ text: `${hitReq}环`, highlight: true },
|
||||||
|
{ text: "可获得能量,计时结束能量需要大于" },
|
||||||
|
{
|
||||||
|
text: `${stabilityEnergyReqPercent.value}%`,
|
||||||
|
highlight: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -348,6 +555,22 @@ const practiceInfoFields = [
|
|||||||
"blocks",
|
"blocks",
|
||||||
"randomBlock",
|
"randomBlock",
|
||||||
"randomRingArea",
|
"randomRingArea",
|
||||||
|
"roundTime",
|
||||||
|
"shootTime",
|
||||||
|
"shootWindowStart",
|
||||||
|
"inShootWindow",
|
||||||
|
"scoreSlot",
|
||||||
|
"currentEnergy",
|
||||||
|
"energyCostPerSec",
|
||||||
|
"energyPerHit",
|
||||||
|
"energyReqPercent",
|
||||||
|
"deltaCurrentEnergy",
|
||||||
|
"maxEnergyPercent",
|
||||||
|
"qualifiedArrows",
|
||||||
|
"qualifiedRate",
|
||||||
|
"deltaMaxEnergyPercent",
|
||||||
|
"deltaQualifiedArrows",
|
||||||
|
"deltaQualifiedRate",
|
||||||
"timeLimit",
|
"timeLimit",
|
||||||
"completed",
|
"completed",
|
||||||
"totalArrows",
|
"totalArrows",
|
||||||
@@ -356,13 +579,17 @@ const practiceInfoFields = [
|
|||||||
"stability",
|
"stability",
|
||||||
"maxCombo",
|
"maxCombo",
|
||||||
"totalHits",
|
"totalHits",
|
||||||
|
"hitRate",
|
||||||
"deltaTotalHits",
|
"deltaTotalHits",
|
||||||
"deltaDuration",
|
"deltaDuration",
|
||||||
|
"deltaHitRate",
|
||||||
"deltaMaxCombo",
|
"deltaMaxCombo",
|
||||||
"deltaTotalRings",
|
"deltaTotalRings",
|
||||||
"deltaTotalArrows",
|
"deltaTotalArrows",
|
||||||
"deltaAverageRing",
|
"deltaAverageRing",
|
||||||
"deltaStability",
|
"deltaStability",
|
||||||
|
"tenRingCount",
|
||||||
|
"deltaTenRingCount",
|
||||||
"beforeExp",
|
"beforeExp",
|
||||||
"beforeLevel",
|
"beforeLevel",
|
||||||
"currentExp",
|
"currentExp",
|
||||||
@@ -383,14 +610,30 @@ const practiceResultFields = [
|
|||||||
"stability",
|
"stability",
|
||||||
"maxCombo",
|
"maxCombo",
|
||||||
"totalHits",
|
"totalHits",
|
||||||
|
"hitRate",
|
||||||
"currentRings",
|
"currentRings",
|
||||||
|
"scoreSlot",
|
||||||
|
"currentEnergy",
|
||||||
|
"energyCostPerSec",
|
||||||
|
"energyPerHit",
|
||||||
|
"energyReqPercent",
|
||||||
|
"deltaCurrentEnergy",
|
||||||
|
"maxEnergyPercent",
|
||||||
|
"qualifiedArrows",
|
||||||
|
"qualifiedRate",
|
||||||
|
"deltaMaxEnergyPercent",
|
||||||
|
"deltaQualifiedArrows",
|
||||||
|
"deltaQualifiedRate",
|
||||||
"deltaTotalHits",
|
"deltaTotalHits",
|
||||||
"deltaDuration",
|
"deltaDuration",
|
||||||
|
"deltaHitRate",
|
||||||
"deltaMaxCombo",
|
"deltaMaxCombo",
|
||||||
"deltaTotalRings",
|
"deltaTotalRings",
|
||||||
"deltaTotalArrows",
|
"deltaTotalArrows",
|
||||||
"deltaAverageRing",
|
"deltaAverageRing",
|
||||||
"deltaStability",
|
"deltaStability",
|
||||||
|
"tenRingCount",
|
||||||
|
"deltaTenRingCount",
|
||||||
"beforeExp",
|
"beforeExp",
|
||||||
"beforeLevel",
|
"beforeLevel",
|
||||||
"currentExp",
|
"currentExp",
|
||||||
@@ -400,7 +643,72 @@ const practiceResultFields = [
|
|||||||
"details",
|
"details",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const cacheRhythmTrainingConfig = (message = {}) => {
|
||||||
|
const messageTrainingType = String(
|
||||||
|
message.trainingType ?? message.training_type ?? trainingType.value
|
||||||
|
).trim();
|
||||||
|
if (messageTrainingType !== "rhythm") return;
|
||||||
|
|
||||||
|
const roundTime = getPositiveInteger(
|
||||||
|
message.roundTime ?? message.round_time
|
||||||
|
);
|
||||||
|
const shootTime = getPositiveInteger(
|
||||||
|
message.shootTime ?? message.shoot_time
|
||||||
|
);
|
||||||
|
const hitReq = getPositiveInteger(message.hitReq ?? message.hit_req);
|
||||||
|
const nextConfig = {};
|
||||||
|
|
||||||
|
// 固定训练配置单独缓存,避免后续部分快照清空 practiceInfo 时丢失。
|
||||||
|
if (roundTime > 0) nextConfig.roundTime = roundTime;
|
||||||
|
if (shootTime > 0) nextConfig.shootTime = shootTime;
|
||||||
|
if (hitReq > 0) nextConfig.hitReq = hitReq;
|
||||||
|
if (Object.keys(nextConfig).length === 0) return;
|
||||||
|
|
||||||
|
trainingParams.value = {
|
||||||
|
...trainingParams.value,
|
||||||
|
...nextConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 开始后配置才到达时补建首轮本地锚点;已有服务端锚点时不重置。
|
||||||
|
if (
|
||||||
|
start.value &&
|
||||||
|
!rhythmHasActiveServerAnchor.value &&
|
||||||
|
!rhythmFallbackWindowStart.value &&
|
||||||
|
rhythmRoundTime.value > 0 &&
|
||||||
|
rhythmShootTime.value > 0
|
||||||
|
) {
|
||||||
|
initializeRhythmFirstRoundCountdown();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const cacheRhythmTargetArrows = (message = {}) => {
|
||||||
|
const messageTrainingType = String(
|
||||||
|
message.trainingType ?? message.training_type ?? trainingType.value
|
||||||
|
).trim();
|
||||||
|
if (messageTrainingType !== "rhythm") return;
|
||||||
|
|
||||||
|
const totalArrows = getPositiveInteger(
|
||||||
|
message.totalArrows ?? message.total_arrows
|
||||||
|
);
|
||||||
|
if (totalArrows > 0) {
|
||||||
|
rhythmTargetArrows.value = totalArrows;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 兼容服务端首帧 total_arrows 暂为 0:只初始化一次,避免剩余数递减时分母跟着变化。
|
||||||
|
if (rhythmTargetArrows.value === 0) {
|
||||||
|
rhythmTargetArrows.value = getPositiveInteger(
|
||||||
|
message.arrowsLeft ?? message.arrows_left
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const syncPracticeInfo = (message = {}) => {
|
const syncPracticeInfo = (message = {}) => {
|
||||||
|
cacheRhythmTrainingConfig(message);
|
||||||
|
cacheRhythmTargetArrows(message);
|
||||||
|
const messageTrainingType = String(
|
||||||
|
message.trainingType ?? message.training_type ?? trainingType.value
|
||||||
|
).trim();
|
||||||
const nextInfo = practiceInfoFields.reduce((result, field) => {
|
const nextInfo = practiceInfoFields.reduce((result, field) => {
|
||||||
if (Object.prototype.hasOwnProperty.call(message, field)) {
|
if (Object.prototype.hasOwnProperty.call(message, field)) {
|
||||||
result[field] = message[field];
|
result[field] = message[field];
|
||||||
@@ -408,6 +716,24 @@ const syncPracticeInfo = (message = {}) => {
|
|||||||
return result;
|
return result;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
const isStabilityEnergySnapshot =
|
||||||
|
messageTrainingType === "stability" &&
|
||||||
|
(Object.prototype.hasOwnProperty.call(message, "currentEnergy") ||
|
||||||
|
message.type === undefined ||
|
||||||
|
[
|
||||||
|
MESSAGETYPESV2.BattleStart,
|
||||||
|
MESSAGETYPESV2.ShootResult,
|
||||||
|
MESSAGETYPESV2.BattleEnd,
|
||||||
|
].includes(message.type));
|
||||||
|
|
||||||
|
if (isStabilityEnergySnapshot) {
|
||||||
|
// BattleStart/ShootResult/PracticeEnd/同步消息都是稳定训练完整快照。
|
||||||
|
// current_energy 为 0 时 protobuf 不编码,不能沿用上一份非零能量。
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(nextInfo, "currentEnergy")) {
|
||||||
|
nextInfo.currentEnergy = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isPrecisionSnapshot =
|
const isPrecisionSnapshot =
|
||||||
(message.type === MESSAGETYPESV2.BattleStart ||
|
(message.type === MESSAGETYPESV2.BattleStart ||
|
||||||
message.type === MESSAGETYPESV2.ShootResult) &&
|
message.type === MESSAGETYPESV2.ShootResult) &&
|
||||||
@@ -445,16 +771,28 @@ const buildShootResultAudioKeys = (message = {}) => {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = [
|
const directionText =
|
||||||
arrow.ring ? `${arrow.ringX ? "X" : arrow.ring}环` : "未上靶",
|
arrow.angle !== null && arrow.angle !== undefined
|
||||||
];
|
? getDirectionText(arrow.angle)
|
||||||
if (arrow.angle !== null && arrow.angle !== undefined) {
|
: "";
|
||||||
keys.push(`向${getDirectionText(arrow.angle)}调整`);
|
return getPrecisionShotAudioKeys(arrow, directionText);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildRhythmShootResultAudioKeys = (message = {}) => {
|
||||||
|
const latestDetail =
|
||||||
|
Array.isArray(message.details) && message.details.length > 0
|
||||||
|
? message.details[message.details.length - 1]
|
||||||
|
: null;
|
||||||
|
const arrow = message.shootData || latestDetail;
|
||||||
|
if (!arrow) return [];
|
||||||
|
if (
|
||||||
|
arrow.playerId !== undefined &&
|
||||||
|
arrow.playerId !== null &&
|
||||||
|
String(arrow.playerId) !== String(user.value?.id)
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
if (arrow.threeConsecutive10Rings === true) {
|
return getRhythmShotAudioKeys(arrow);
|
||||||
keys.push("tententen");
|
|
||||||
}
|
|
||||||
return keys;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const playAudioKeysAndWait = (keys) => {
|
const playAudioKeysAndWait = (keys) => {
|
||||||
@@ -563,7 +901,10 @@ const commitPrecisionTargetAfterPresentation = async ({
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
visiblePrecisionTarget.value = target;
|
applyVisiblePrecisionTarget(target);
|
||||||
|
if (precisionRandomBlock.value > 0) {
|
||||||
|
precisionTargetRefreshToken.value += 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const createPracticeEndSnapshot = (message = {}) => {
|
const createPracticeEndSnapshot = (message = {}) => {
|
||||||
@@ -679,6 +1020,16 @@ const onPracticeInfoSync = (payload = {}) => {
|
|||||||
|
|
||||||
const snapshot = payload.practiceInfo;
|
const snapshot = payload.practiceInfo;
|
||||||
if (!snapshot || typeof snapshot !== "object") return;
|
if (!snapshot || typeof snapshot !== "object") return;
|
||||||
|
if (
|
||||||
|
start.value &&
|
||||||
|
(snapshot.trainingType === "rhythm" || isRhythmTraining.value) &&
|
||||||
|
Number(snapshot.shootWindowStart) > 0
|
||||||
|
) {
|
||||||
|
rhythmHasActiveServerAnchor.value = true;
|
||||||
|
}
|
||||||
|
if (payload.timestamp !== undefined && payload.timestamp !== null) {
|
||||||
|
rhythmServerTimestamp.value = payload.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
const shouldShowDistance =
|
const shouldShowDistance =
|
||||||
waitingPracticeSync && pageStage.value === pageStages.LOADING;
|
waitingPracticeSync && pageStage.value === pageStages.LOADING;
|
||||||
@@ -765,6 +1116,8 @@ const connectPracticeServer = ({
|
|||||||
userId: user.value.id,
|
userId: user.value.id,
|
||||||
requestPracticeInfoOnOpen: true,
|
requestPracticeInfoOnOpen: true,
|
||||||
appHideResumable: appHideResumable.value,
|
appHideResumable: appHideResumable.value,
|
||||||
|
practiceEndAudioKey: "练习结束",
|
||||||
|
trainingType: trainingType.value,
|
||||||
});
|
});
|
||||||
connectionClosed.value = false;
|
connectionClosed.value = false;
|
||||||
return true;
|
return true;
|
||||||
@@ -990,16 +1343,58 @@ onLoad((options = {}) => {
|
|||||||
toRouteNumber(trainingContext.difficultyLevel)
|
toRouteNumber(trainingContext.difficultyLevel)
|
||||||
),
|
),
|
||||||
recordId: options.recordId || "",
|
recordId: options.recordId || "",
|
||||||
hitReq: toRouteNumber(options.hitReq),
|
hitReq: toRouteNumber(
|
||||||
|
options.hitReq,
|
||||||
|
toRouteNumber(trainingContext.hitReq)
|
||||||
|
),
|
||||||
totalReq: toRouteNumber(options.totalReq),
|
totalReq: toRouteNumber(options.totalReq),
|
||||||
blocks: toRouteNumber(options.blocks),
|
blocks: toRouteNumber(options.blocks),
|
||||||
mode: toRouteNumber(options.mode),
|
mode: toRouteNumber(options.mode),
|
||||||
|
roundTime: toRouteNumber(
|
||||||
|
options.roundTime,
|
||||||
|
toRouteNumber(trainingContext.roundTime)
|
||||||
|
),
|
||||||
|
shootTime: toRouteNumber(
|
||||||
|
options.shootTime,
|
||||||
|
toRouteNumber(trainingContext.shootTime)
|
||||||
|
),
|
||||||
|
energyPerHit: toRouteNumber(
|
||||||
|
options.energyPerHit,
|
||||||
|
toRouteNumber(trainingContext.energyPerHit)
|
||||||
|
),
|
||||||
|
energyCostPerSec: toRouteNumber(
|
||||||
|
options.energyCostPerSec,
|
||||||
|
toRouteNumber(trainingContext.energyCostPerSec)
|
||||||
|
),
|
||||||
|
energyReqPercent: toRouteNumber(
|
||||||
|
options.energyReqPercent,
|
||||||
|
toRouteNumber(trainingContext.energyReqPercent)
|
||||||
|
),
|
||||||
|
scoreSlot: toRouteNumber(
|
||||||
|
options.scoreSlot,
|
||||||
|
toRouteNumber(trainingContext.scoreSlot)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
practiseId.value = trainingContext.practiceId || "";
|
practiseId.value = trainingContext.practiceId || "";
|
||||||
serverAddr.value = trainingContext.serverAddr || "";
|
serverAddr.value = trainingContext.serverAddr || "";
|
||||||
|
|
||||||
|
const startAudioKey = getTrainingStartAudioKey(trainingParams.value.type);
|
||||||
|
const warmupKeys = [startAudioKey, "胜利", "失败"];
|
||||||
|
if (trainingParams.value.type === "precision") {
|
||||||
|
warmupKeys.push("Bingo命中目标", "未命中");
|
||||||
|
} else if (trainingParams.value.type === "rhythm") {
|
||||||
|
warmupKeys.push(RHYTHM_SHOOT_WINDOW_AUDIO_KEY, "Perfect", "miss");
|
||||||
|
} else if (trainingParams.value.type === "stability") {
|
||||||
|
warmupKeys.push(
|
||||||
|
STABILITY_ENERGY_50_AUDIO_KEY,
|
||||||
|
STABILITY_ENERGY_70_AUDIO_KEY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void audioManager.warmKeys(warmupKeys.filter(Boolean));
|
||||||
});
|
});
|
||||||
|
|
||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
|
if (practiceStarting.value) return;
|
||||||
if (
|
if (
|
||||||
!practiseId.value ||
|
!practiseId.value ||
|
||||||
practiceEnded.value ||
|
practiceEnded.value ||
|
||||||
@@ -1013,6 +1408,7 @@ const onReady = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
practiceStarting.value = true;
|
||||||
pageStage.value = pageStages.LOADING;
|
pageStage.value = pageStages.LOADING;
|
||||||
clearHighlightTestTimer();
|
clearHighlightTestTimer();
|
||||||
useHighlightTest.value = false;
|
useHighlightTest.value = false;
|
||||||
@@ -1023,15 +1419,23 @@ const onReady = async () => {
|
|||||||
practiseResult.value = {};
|
practiseResult.value = {};
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
shotEffectToken.value = 0;
|
shotEffectToken.value = 0;
|
||||||
|
initializeRhythmFirstRoundCountdown();
|
||||||
start.value = true;
|
start.value = true;
|
||||||
pageStage.value = pageStages.SHOOTING;
|
pageStage.value = pageStages.SHOOTING;
|
||||||
setPracticeAppHideResumable(true);
|
setPracticeAppHideResumable(true);
|
||||||
audioManager.play("练习开始");
|
// 先由本地锚点保证首轮立即显示,再用最新服务端快照无感校准。
|
||||||
|
requestPracticeInfoSync();
|
||||||
|
// 开始接口成功即进入正式训练,直接播放对应提示,避免依赖 BattleStart 消息。
|
||||||
|
audioManager.play(
|
||||||
|
getTrainingStartAudioKey(trainingType.value, "练习开始")
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
start.value = false;
|
start.value = false;
|
||||||
pageStage.value = pageStages.DISTANCE;
|
pageStage.value = pageStages.DISTANCE;
|
||||||
setPracticeAppHideResumable(true);
|
setPracticeAppHideResumable(true);
|
||||||
throw error;
|
throw error;
|
||||||
|
} finally {
|
||||||
|
practiceStarting.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1054,6 +1458,7 @@ const enterPracticeResult = (result = {}) => {
|
|||||||
clearPracticeRuntimeContext();
|
clearPracticeRuntimeContext();
|
||||||
closePracticeConnection("training-practice-result");
|
closePracticeConnection("training-practice-result");
|
||||||
pageStage.value = pageStages.RESULT;
|
pageStage.value = pageStages.RESULT;
|
||||||
|
audioManager.play(result.completed === true ? "胜利" : "失败");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1086,7 +1491,27 @@ const onOver = async () => {
|
|||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(msg) {
|
||||||
const previousScoreLength = scores.value.length;
|
const previousScoreLength = scores.value.length;
|
||||||
|
const incomingRhythmWindowStart = Number(msg.shootWindowStart);
|
||||||
|
const currentRhythmWindowStart = Number(rhythmShootWindowStart.value);
|
||||||
|
const shouldSyncRhythmAnchor =
|
||||||
|
start.value &&
|
||||||
|
isRhythmTraining.value &&
|
||||||
|
incomingRhythmWindowStart > 0 &&
|
||||||
|
(!rhythmHasActiveServerAnchor.value ||
|
||||||
|
incomingRhythmWindowStart !== currentRhythmWindowStart);
|
||||||
|
|
||||||
|
// 报靶消息的时间戳包含传输延迟,同一轮内不重复校时,避免秒数回跳。
|
||||||
|
if (
|
||||||
|
shouldSyncRhythmAnchor &&
|
||||||
|
msg.timestamp !== undefined &&
|
||||||
|
msg.timestamp !== null
|
||||||
|
) {
|
||||||
|
rhythmServerTimestamp.value = msg.timestamp;
|
||||||
|
}
|
||||||
syncPracticeInfo(msg);
|
syncPracticeInfo(msg);
|
||||||
|
if (shouldSyncRhythmAnchor) {
|
||||||
|
rhythmHasActiveServerAnchor.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||||
invalidateShotPresentations();
|
invalidateShotPresentations();
|
||||||
@@ -1101,6 +1526,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") {
|
||||||
@@ -1124,6 +1550,38 @@ async function onReceiveMessage(msg) {
|
|||||||
audioPromise,
|
audioPromise,
|
||||||
effectPromise,
|
effectPromise,
|
||||||
});
|
});
|
||||||
|
} else if (trainingType.value === "rhythm") {
|
||||||
|
const audioKeys = buildRhythmShootResultAudioKeys(msg);
|
||||||
|
if (audioKeys.length > 0) {
|
||||||
|
audioManager.play(audioKeys, false);
|
||||||
|
}
|
||||||
|
if (hasNewShot) {
|
||||||
|
shotEffectToken.value += 1;
|
||||||
|
}
|
||||||
|
} else if (trainingType.value === "stability") {
|
||||||
|
const hasStabilityShot =
|
||||||
|
msg.stabilityHasNewShot === true || hasNewShot;
|
||||||
|
const latestDetail =
|
||||||
|
Array.isArray(msg.details) && msg.details.length > 0
|
||||||
|
? msg.details[msg.details.length - 1]
|
||||||
|
: null;
|
||||||
|
const arrow = msg.shootData || latestDetail;
|
||||||
|
const audioKeys = hasStabilityShot
|
||||||
|
? getStabilityShotAudioKeys(arrow)
|
||||||
|
: [];
|
||||||
|
const milestoneAudioKey = String(
|
||||||
|
msg.stabilityMilestoneAudioKey || ""
|
||||||
|
).trim();
|
||||||
|
|
||||||
|
// WebSocket 管理器负责阈值判定并把同一语音 key 用于 ACK;这里按
|
||||||
|
// 环数/最高跨越阈值的顺序一次入队。
|
||||||
|
if (milestoneAudioKey) audioKeys.push(milestoneAudioKey);
|
||||||
|
if (audioKeys.length > 0) {
|
||||||
|
audioManager.play(audioKeys, false);
|
||||||
|
}
|
||||||
|
if (hasStabilityShot) {
|
||||||
|
shotEffectToken.value += 1;
|
||||||
|
}
|
||||||
} else if (hasNewShot) {
|
} else if (hasNewShot) {
|
||||||
shotEffectToken.value += 1;
|
shotEffectToken.value += 1;
|
||||||
}
|
}
|
||||||
@@ -1170,6 +1628,11 @@ async function onRetry() {
|
|||||||
practiseResult.value = {};
|
practiseResult.value = {};
|
||||||
practiceEndSnapshot.value = {};
|
practiceEndSnapshot.value = {};
|
||||||
practiceInfo.value = {};
|
practiceInfo.value = {};
|
||||||
|
rhythmServerTimestamp.value = 0;
|
||||||
|
rhythmFallbackWindowStart.value = 0;
|
||||||
|
rhythmFallbackTimestamp.value = 0;
|
||||||
|
rhythmHasActiveServerAnchor.value = false;
|
||||||
|
rhythmTargetArrows.value = 0;
|
||||||
invalidateShotPresentations({ resetVisible: true });
|
invalidateShotPresentations({ resetVisible: true });
|
||||||
start.value = false;
|
start.value = false;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
@@ -1192,7 +1655,7 @@ function onAudioEnded(key) {
|
|||||||
Array.from(audioWaiters).forEach((waiter) => {
|
Array.from(audioWaiters).forEach((waiter) => {
|
||||||
if (waiter.expectedKey === key) waiter.done();
|
if (waiter.expectedKey === key) waiter.done();
|
||||||
});
|
});
|
||||||
if (String(key || "").includes("比赛结束")) {
|
if (["比赛结束", "练习结束"].includes(String(key || ""))) {
|
||||||
void onOver();
|
void onOver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1292,11 +1755,27 @@ onBeforeUnmount(() => {
|
|||||||
:showBottom="isDistanceStage"
|
:showBottom="isDistanceStage"
|
||||||
:scroll="!isShootingStage"
|
:scroll="!isShootingStage"
|
||||||
:onBack="exitPractice"
|
:onBack="exitPractice"
|
||||||
|
:title="
|
||||||
|
isShootingStage
|
||||||
|
? isRhythmTraining
|
||||||
|
? '节奏训练'
|
||||||
|
: isStabilityTraining
|
||||||
|
? '稳定训练'
|
||||||
|
: ''
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
:titleStyle="
|
||||||
|
isShootingStage && (isRhythmTraining || isStabilityTraining)
|
||||||
|
? rhythmHeaderTitleStyle
|
||||||
|
: {}
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<view class="practise-content">
|
<view class="practise-content">
|
||||||
<TestDistance
|
<TestDistance
|
||||||
v-if="isDistanceStage"
|
v-if="isDistanceStage"
|
||||||
:targetType="practiceInfo.targetType"
|
:targetType="simulatorTargetType"
|
||||||
|
:autoStart="true"
|
||||||
|
@passed="onReady"
|
||||||
/>
|
/>
|
||||||
<view v-else-if="isShootingStage" class="shooting-layout">
|
<view v-else-if="isShootingStage" class="shooting-layout">
|
||||||
<view class="shooting-fixed">
|
<view class="shooting-fixed">
|
||||||
@@ -1305,9 +1784,21 @@ onBeforeUnmount(() => {
|
|||||||
:total="timeLimit"
|
:total="timeLimit"
|
||||||
:countdownEnabled="hasTimeLimit"
|
:countdownEnabled="hasTimeLimit"
|
||||||
:trainingType="trainingType"
|
:trainingType="trainingType"
|
||||||
|
:roundTime="rhythmRoundTime"
|
||||||
|
:shootTime="rhythmShootTime"
|
||||||
|
:shootWindowStart="rhythmShootWindowStart"
|
||||||
|
:inShootWindow="rhythmInShootWindow"
|
||||||
|
:serverTimestamp="rhythmCountdownTimestamp"
|
||||||
|
:hitReq="rhythmHitReq"
|
||||||
|
:energyPercent="stabilityEnergyPercent"
|
||||||
|
:energyReqPercent="stabilityEnergyReqPercent"
|
||||||
:isVip="isVip"
|
:isVip="isVip"
|
||||||
:isSvip="isSvip"
|
:isSvip="isSvip"
|
||||||
:externalShootResultAudio="trainingType === 'precision'"
|
:externalShootResultAudio="
|
||||||
|
trainingType === 'precision' ||
|
||||||
|
trainingType === 'rhythm' ||
|
||||||
|
trainingType === 'stability'
|
||||||
|
"
|
||||||
:onStop="onTimeLimitReached"
|
:onStop="onTimeLimitReached"
|
||||||
/>
|
/>
|
||||||
<view class="user-row">
|
<view class="user-row">
|
||||||
@@ -1323,12 +1814,14 @@ onBeforeUnmount(() => {
|
|||||||
:currentRound="scores.length % 3"
|
:currentRound="scores.length % 3"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
:isSvip="isSvip"
|
:isSvip="isSvip"
|
||||||
|
:targetType="simulatorTargetType"
|
||||||
:shotEffectToken="shotEffectToken"
|
:shotEffectToken="shotEffectToken"
|
||||||
:showCrosshair="false"
|
:showCrosshair="false"
|
||||||
: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">
|
||||||
@@ -1347,7 +1840,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"
|
||||||
@@ -1355,6 +1848,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"
|
||||||
@@ -1364,14 +1859,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>
|
||||||
@@ -1384,7 +1888,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
|
||||||
@@ -1492,6 +2000,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;
|
||||||
@@ -1501,6 +2015,9 @@ onBeforeUnmount(() => {
|
|||||||
.sound-btn {
|
.sound-btn {
|
||||||
width: 76rpx;
|
width: 76rpx;
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1513,7 +2030,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{
|
||||||
@@ -1528,11 +2045,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;
|
||||||
@@ -1543,6 +2062,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;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Container from "@/components/Container.vue";
|
|||||||
import UserHeader from "@/components/UserHeader.vue";
|
import UserHeader from "@/components/UserHeader.vue";
|
||||||
import UserItem from "@/components/UserItem.vue";
|
import UserItem from "@/components/UserItem.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import { getMyGoldAPI } from "@/apis";
|
||||||
import { canEenter } from "@/util";
|
import { canEenter } from "@/util";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -24,6 +25,21 @@ const toFristTryPage = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const toCoinPage = () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/coin/nearby-stores",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const showCoinEntry = ref(false);
|
||||||
|
const loadCoinEntryVisibility = async () => {
|
||||||
|
showCoinEntry.value = false;
|
||||||
|
try {
|
||||||
|
const result = await getMyGoldAPI();
|
||||||
|
showCoinEntry.value = result?.hasTempBind === true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载金币入口状态失败", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
const toBeVipPage = () => {
|
const toBeVipPage = () => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/member/be-vip",
|
url: "/pages/member/be-vip",
|
||||||
@@ -54,6 +70,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 = () => {
|
||||||
@@ -64,6 +85,7 @@ const logout = () => {
|
|||||||
updateUser();
|
updateUser();
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
loadCoinEntryVisibility();
|
||||||
const accountInfo = uni.getAccountInfoSync();
|
const accountInfo = uni.getAccountInfoSync();
|
||||||
const envVersion = accountInfo.miniProgram.envVersion;
|
const envVersion = accountInfo.miniProgram.envVersion;
|
||||||
if (envVersion !== "release") showLogout.value = true;
|
if (envVersion !== "release") showLogout.value = true;
|
||||||
@@ -77,7 +99,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"
|
||||||
@@ -103,8 +125,26 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
|||||||
<text v-if="user.trio > 0" :style="{ color: '#259249' }">已完成</text>
|
<text v-if="user.trio > 0" :style="{ color: '#259249' }">已完成</text>
|
||||||
<text v-else :style="{ color: '#CC311F' }">未完成</text>
|
<text v-else :style="{ color: '#CC311F' }">未完成</text>
|
||||||
</UserItem>
|
</UserItem>
|
||||||
|
<UserItem
|
||||||
|
v-if="showCoinEntry"
|
||||||
|
title="我的金币"
|
||||||
|
:onClick="toCoinPage"
|
||||||
|
/>
|
||||||
<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 +155,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 +164,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 +188,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 +216,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>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 156 KiB |