Merge branch 'test' into feat-prac
This commit is contained in:
@@ -82,7 +82,7 @@ const checkBowData = () => {
|
||||
<view class="container">
|
||||
<block v-if="data.mode <= 3">
|
||||
<view class="header-team" :style="{ marginTop: '25%' }">
|
||||
<image src="../static/battle-result.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/battle-result.png" mode="widthFix" />
|
||||
<view class="header-solo" v-if="data.mode === 1">
|
||||
<text
|
||||
:style="{
|
||||
@@ -107,7 +107,7 @@ const checkBowData = () => {
|
||||
</view>
|
||||
<view class="header-mvp" v-if="data.mode === 2 || data.mode === 3">
|
||||
<image
|
||||
:src="`../static/${data.winTeam === 1 ? 'blue' : 'red'}-team-win.png`"
|
||||
:src="`https://static.shelingxingqiu.com/shootmini/static/${data.winTeam === 1 ? 'blue' : 'red'}-team-win.png`"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<view
|
||||
@@ -117,8 +117,8 @@ const checkBowData = () => {
|
||||
}deg)`,
|
||||
}"
|
||||
>
|
||||
<view v-if="data.mvp && data.mvp.totalRings">
|
||||
<image src="../static/title-mvp.png" mode="widthFix" />
|
||||
<view v-if="data.mvp && data.mvp.player_match_result.total_ring">
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/title-mvp.png" mode="widthFix" />
|
||||
<text
|
||||
>斩获<text
|
||||
:style="{
|
||||
@@ -127,7 +127,7 @@ const checkBowData = () => {
|
||||
margin: '0 3px',
|
||||
fontWeight: '600',
|
||||
}"
|
||||
>{{ data.mvp.totalRings }}</text
|
||||
>{{ data.mvp.player_match_result.total_ring }}</text
|
||||
>环</text
|
||||
>
|
||||
</view>
|
||||
@@ -153,7 +153,7 @@ const checkBowData = () => {
|
||||
</view>
|
||||
</view>
|
||||
<view class="battle-winner">
|
||||
<image src="../static/shining-bg.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/shining-bg.png" mode="widthFix" />
|
||||
<image
|
||||
:src="ifWin ? '../static/you-win.png' : '../static/you-lost.png'"
|
||||
mode="widthFix"
|
||||
@@ -173,7 +173,7 @@ const checkBowData = () => {
|
||||
<block v-else>
|
||||
<view class="header-melee">
|
||||
<view />
|
||||
<image src="../static/battle-result.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/battle-result.png" mode="widthFix" />
|
||||
<view />
|
||||
</view>
|
||||
<view
|
||||
@@ -248,7 +248,7 @@ const checkBowData = () => {
|
||||
class="battle-e"
|
||||
:style="{ marginTop: data.mode > 3 ? '20px' : '20vw' }"
|
||||
>
|
||||
<image src="../static/row-yellow-bg.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/row-yellow-bg.png" mode="widthFix" />
|
||||
<view class="team-avatar">
|
||||
<Avatar
|
||||
:src="user.avatar"
|
||||
|
||||
+312
-46
@@ -1,23 +1,27 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed, onBeforeUnmount } from "vue";
|
||||
import { onShow, onLoad, onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import { onShow, onHide, onLoad, onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import PlayerSeats from "@/components/PlayerSeats.vue";
|
||||
import GuideTwo from "@/components/GuideTwo.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import ModalDialog from "@/components/ModalDialog.vue";
|
||||
import {
|
||||
getRoomAPI,
|
||||
exitRoomAPI,
|
||||
chooseTeamAPI,
|
||||
getReadyAPI,
|
||||
kickPlayerAPI,
|
||||
getBattleAPI,
|
||||
} from "@/apis";
|
||||
import { debounce, isLimitError } from "@/util";
|
||||
import { MESSAGETYPES, MESSAGETYPESV2 } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
import audioManager from "@/audioManager";
|
||||
import { returnToBattle } from "@/utils/matchReturn";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
|
||||
@@ -29,6 +33,20 @@ const players = ref([]);
|
||||
const blueTeam = ref([]);
|
||||
const redTeam = ref([]);
|
||||
|
||||
const isMember = (player = {}) => player.vip === true || player.sVip === true;
|
||||
|
||||
const getMemberNicknameClass = (player = {}) => [
|
||||
"member-nickname",
|
||||
player.vip === true && player.sVip !== true ? "member-nickname--vip" : "",
|
||||
player.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
const normalizeRoomPlayer = (member = {}) => ({
|
||||
...(member.userInfo || {}),
|
||||
vip: member.vip ?? member.userInfo?.vip,
|
||||
sVip: member.sVip ?? member.userInfo?.sVip,
|
||||
});
|
||||
|
||||
/**
|
||||
* 根据对战类型和房间人数动态生成页面标题
|
||||
* battleType=1: 组队对战;count 2/4/6 分别对应 1v1/2v2/3v3
|
||||
@@ -56,17 +74,153 @@ const ready = ref(false);
|
||||
const allReady = ref(false);
|
||||
const timer = ref(null);
|
||||
const goBattle = ref(false);
|
||||
const showLimitModal = ref(false);
|
||||
const readySubmitting = ref(false);
|
||||
const navigationPending = ref(false);
|
||||
let pageMounted = false;
|
||||
let pageVisible = false;
|
||||
let foregroundGeneration = 0;
|
||||
const MATCH_INFO_RETRY_DELAY_MS = 500;
|
||||
/** 从结算页返回时为 true,跳过进场靶纸语音 */
|
||||
const skipTargetAudio = ref(false);
|
||||
|
||||
const wait = (delay) =>
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve, delay);
|
||||
});
|
||||
|
||||
const isCurrentForeground = (generation) =>
|
||||
pageMounted &&
|
||||
pageVisible &&
|
||||
generation === foregroundGeneration &&
|
||||
!navigationPending.value;
|
||||
|
||||
const redirectOnce = (url) =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (navigationPending.value) {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
navigationPending.value = true;
|
||||
uni.redirectTo({
|
||||
url,
|
||||
success: resolve,
|
||||
fail: (error) => {
|
||||
navigationPending.value = false;
|
||||
goBattle.value = false;
|
||||
reject(error);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
async function queryCurrentBattle(generation) {
|
||||
try {
|
||||
return await getBattleAPI();
|
||||
} catch (error) {
|
||||
await wait(MATCH_INFO_RETRY_DELAY_MS);
|
||||
if (!isCurrentForeground(generation)) throw error;
|
||||
return getBattleAPI();
|
||||
}
|
||||
}
|
||||
|
||||
async function returnToCurrentBattle(battle) {
|
||||
if (!battle?.matchId || navigationPending.value) return false;
|
||||
|
||||
goBattle.value = true;
|
||||
try {
|
||||
const returned = await returnToBattle(battle, redirectOnce);
|
||||
if (!returned) goBattle.value = false;
|
||||
return returned;
|
||||
} catch (error) {
|
||||
goBattle.value = false;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function reconcileBattleRoom(generation) {
|
||||
let battle = null;
|
||||
try {
|
||||
battle = await queryCurrentBattle(generation);
|
||||
} catch (error) {
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
console.log("resume room match info error", error);
|
||||
uni.showToast({
|
||||
title: "比赛状态查询失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
if (battle?.matchId) {
|
||||
try {
|
||||
await returnToCurrentBattle(battle);
|
||||
} catch (error) {
|
||||
console.log("return to room battle error", error);
|
||||
uni.showToast({
|
||||
title: "进入比赛失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let roomStarted = false;
|
||||
try {
|
||||
roomStarted = await refreshRoomData();
|
||||
} catch (error) {
|
||||
if (isCurrentForeground(generation)) {
|
||||
console.log("refresh room data error", error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCurrentForeground(generation) || !roomStarted) return;
|
||||
|
||||
await wait(MATCH_INFO_RETRY_DELAY_MS);
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
|
||||
try {
|
||||
battle = await queryCurrentBattle(generation);
|
||||
} catch (error) {
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
console.log("retry room match info error", error);
|
||||
uni.showToast({
|
||||
title: "比赛状态查询失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
if (battle?.matchId) {
|
||||
try {
|
||||
await returnToCurrentBattle(battle);
|
||||
} catch (error) {
|
||||
console.log("return to room battle error", error);
|
||||
uni.showToast({
|
||||
title: "进入比赛失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: "比赛正在创建,请稍候",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 从服务端刷新当前房间数据,更新成员列表、准备状态等信息
|
||||
* 仅在 roomNumber 有效且房间未开始时执行
|
||||
*/
|
||||
async function refreshRoomData() {
|
||||
if (!roomNumber.value) return;
|
||||
if (!roomNumber.value) return false;
|
||||
const result = await getRoomAPI(roomNumber.value);
|
||||
if (result.started) return;
|
||||
if (result.started) return true;
|
||||
room.value = result;
|
||||
// 加入者通过 API 返回的 targetType 字段同步靶纸尺寸,并持久化到本地缓存
|
||||
if (result.targetType) {
|
||||
@@ -91,13 +245,16 @@ async function refreshRoomData() {
|
||||
return false;
|
||||
});
|
||||
members.some((m) => {
|
||||
if (m.userInfo.id === result.creator) {
|
||||
const player = normalizeRoomPlayer(m);
|
||||
if (player.id === result.creator) {
|
||||
owner.value = {
|
||||
id: m.userInfo.id,
|
||||
name: m.userInfo.name,
|
||||
avatar: m.userInfo.avatar,
|
||||
rankLvl: m.userInfo.rankLvl,
|
||||
ready: !!m.userInfo.state,
|
||||
id: player.id,
|
||||
name: player.name,
|
||||
avatar: player.avatar,
|
||||
rankLvl: player.rankLvl,
|
||||
vip: player.vip,
|
||||
sVip: player.sVip,
|
||||
ready: !!player.state,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
@@ -105,13 +262,16 @@ async function refreshRoomData() {
|
||||
});
|
||||
if (result.battleType === 1 && result.count === 2) {
|
||||
result.members.forEach((m) => {
|
||||
if (m.userInfo.id !== owner.value.id) {
|
||||
const player = normalizeRoomPlayer(m);
|
||||
if (player.id !== owner.value.id) {
|
||||
opponent.value = {
|
||||
id: m.userInfo.id,
|
||||
name: m.userInfo.name,
|
||||
avatar: m.userInfo.avatar,
|
||||
rankLvl: m.userInfo.rankLvl,
|
||||
ready: !!m.userInfo.state,
|
||||
id: player.id,
|
||||
name: player.name,
|
||||
avatar: player.avatar,
|
||||
rankLvl: player.rankLvl,
|
||||
vip: player.vip,
|
||||
sVip: player.sVip,
|
||||
ready: !!player.state,
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -121,12 +281,12 @@ async function refreshRoomData() {
|
||||
(m) => m.userInfo.id === result.creator
|
||||
);
|
||||
if (ownerIndex !== -1) {
|
||||
players.value.push(result.members[ownerIndex].userInfo);
|
||||
players.value.push(normalizeRoomPlayer(result.members[ownerIndex]));
|
||||
} else {
|
||||
players.value.push({});
|
||||
}
|
||||
result.members.forEach((m, index) => {
|
||||
if (ownerIndex !== index) players.value.push(m.userInfo);
|
||||
if (ownerIndex !== index) players.value.push(normalizeRoomPlayer(m));
|
||||
});
|
||||
} else {
|
||||
players.value = new Array(result.count).fill({});
|
||||
@@ -134,21 +294,47 @@ async function refreshRoomData() {
|
||||
}
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
// timer.value = setTimeout(refreshRoomData, 2000);
|
||||
return false;
|
||||
}
|
||||
|
||||
const getReady = async () => {
|
||||
await getReadyAPI(roomNumber.value);
|
||||
const getReady = debounce(async () => {
|
||||
if (readySubmitting.value) return;
|
||||
readySubmitting.value = true;
|
||||
try {
|
||||
await getReadyAPI(roomNumber.value);
|
||||
ready.value = true;
|
||||
} catch (error) {
|
||||
if (isLimitError(error)) {
|
||||
showLimitModal.value = true;
|
||||
return;
|
||||
}
|
||||
console.log("room ready error", error);
|
||||
} finally {
|
||||
readySubmitting.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const closeLimitModal = () => {
|
||||
showLimitModal.value = false;
|
||||
};
|
||||
|
||||
const goVipPage = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.navigateTo({
|
||||
url: "/pages/member/be-vip",
|
||||
});
|
||||
};
|
||||
|
||||
const refreshMembers = (members = []) => {
|
||||
blueTeam.value = [];
|
||||
redTeam.value = [];
|
||||
members.forEach((m, index) => {
|
||||
players.value[index] = { ...m.userInfo, groupType: m.groupType };
|
||||
const player = { ...normalizeRoomPlayer(m), groupType: m.groupType };
|
||||
players.value[index] = player;
|
||||
if (m.groupType === 1) {
|
||||
blueTeam.value.push({ ...m.userInfo, groupType: 1 });
|
||||
blueTeam.value.push({ ...player, groupType: 1 });
|
||||
} else if (m.groupType === 2) {
|
||||
redTeam.value.push({ ...m.userInfo, groupType: 2 });
|
||||
redTeam.value.push({ ...player, groupType: 2 });
|
||||
}
|
||||
});
|
||||
for (let i = 0; i < room.value.count / 2; i++) {
|
||||
@@ -190,17 +376,22 @@ async function onReceiveMessage(message) {
|
||||
}
|
||||
});
|
||||
} else if (message.type === MESSAGETYPESV2.AboutToStart) {
|
||||
if (navigationPending.value) return;
|
||||
const matchId = message.matchId || message.id;
|
||||
if (!matchId) return;
|
||||
goBattle.value = true;
|
||||
let url = "";
|
||||
if (message.mode <= 3) {
|
||||
uni.setStorageSync("blue-team", message.teams[1].players || []);
|
||||
uni.setStorageSync("red-team", message.teams[2].players || []);
|
||||
uni.redirectTo({
|
||||
url: "/pages/team-battle/index?battleId=" + message.matchId,
|
||||
});
|
||||
url = "/pages/team-battle/index?battleId=" + matchId;
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: "/pages/melee-battle?battleId=" + message.matchId,
|
||||
});
|
||||
url = "/pages/melee-battle?battleId=" + matchId;
|
||||
}
|
||||
try {
|
||||
await redirectOnce(url);
|
||||
} catch (error) {
|
||||
console.log("redirect to room battle error", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -295,7 +486,15 @@ onShareAppMessage(() => {
|
||||
*/
|
||||
onShow(() => {
|
||||
goBattle.value = false;
|
||||
refreshRoomData();
|
||||
navigationPending.value = false;
|
||||
pageVisible = true;
|
||||
const generation = ++foregroundGeneration;
|
||||
if (pageMounted) void reconcileBattleRoom(generation);
|
||||
});
|
||||
|
||||
onHide(() => {
|
||||
pageVisible = false;
|
||||
foregroundGeneration += 1;
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -319,6 +518,10 @@ onLoad(async (options) => {
|
||||
const stored = uni.getStorageSync(`targetSize_${roomNumber.value}`);
|
||||
if (stored) targetSize.value = stored;
|
||||
}
|
||||
if (pageMounted && pageVisible) {
|
||||
const generation = ++foregroundGeneration;
|
||||
void reconcileBattleRoom(generation);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -330,6 +533,8 @@ onMounted(() => {
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
pageMounted = true;
|
||||
if (pageVisible) void reconcileBattleRoom(foregroundGeneration);
|
||||
// 页面加载完成 1 秒后根据靶纸尺寸播报对应语音;从结算页返回时跳过
|
||||
setTimeout(() => {
|
||||
if (!skipTargetAudio.value) {
|
||||
@@ -340,6 +545,9 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
pageMounted = false;
|
||||
pageVisible = false;
|
||||
foregroundGeneration += 1;
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false,
|
||||
});
|
||||
@@ -367,18 +575,36 @@ onBeforeUnmount(() => {
|
||||
<view v-if="owner.id" class="player" :style="{ transform: 'translateY(-60px)' }">
|
||||
<Avatar :src="owner.avatar" :size="60" />
|
||||
<text>管理员</text>
|
||||
<text>{{ owner.name }}</text>
|
||||
<view
|
||||
v-if="isMember(owner)"
|
||||
:class="['room-player-name', ...getMemberNicknameClass(owner)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ owner.name }}</text>
|
||||
<text v-if="owner.sVip === true" class="member-nickname__shine">
|
||||
{{ owner.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="room-player-name">{{ owner.name }}</text>
|
||||
</view>
|
||||
<view v-else class="no-player" :style="{ transform: 'translateY(-60px)' }">
|
||||
<image src="../static/question-mark.png" mode="widthFix" />
|
||||
</view>
|
||||
<image src="../static/versus.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/versus.png" mode="widthFix" />
|
||||
<view v-if="opponent.id" class="player" :style="{ transform: 'translateY(60px)' }">
|
||||
<Avatar :src="opponent.avatar" :size="60" />
|
||||
<text class="ready" :style="{ opacity: opponent.ready ? 1 : 0 }">
|
||||
已准备
|
||||
</text>
|
||||
<text>{{ opponent.name }}</text>
|
||||
<view
|
||||
v-if="isMember(opponent)"
|
||||
:class="['room-player-name', ...getMemberNicknameClass(opponent)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ opponent.name }}</text>
|
||||
<text v-if="opponent.sVip === true" class="member-nickname__shine">
|
||||
{{ opponent.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="room-player-name">{{ opponent.name }}</text>
|
||||
<button v-if="owner.id === user.id" hover-class="none" class="remove-player"
|
||||
@click="() => removePlayer(opponent)">
|
||||
<image src="../static/close-white.png" mode="widthFix" />
|
||||
@@ -392,8 +618,8 @@ onBeforeUnmount(() => {
|
||||
<block v-if="room.battleType === 1 && room.count >= 4">
|
||||
<view class="all-players">
|
||||
<image src="https://static.shelingxingqiu.com/attachment/2025-08-13/dc0x1p59iab6cvbhqc.png" mode="widthFix" />
|
||||
<image v-if="room.count === 4" src="../static/title-2v2.png" mode="widthFix" />
|
||||
<image v-if="room.count === 6" src="../static/title-3v3.png" mode="widthFix" />
|
||||
<image v-if="room.count === 4" src="https://static.shelingxingqiu.com/shootmini/static/title-2v2.png" mode="widthFix" />
|
||||
<image v-if="room.count === 6" src="https://static.shelingxingqiu.com/shootmini/static/title-3v3.png" mode="widthFix" />
|
||||
<view>
|
||||
<view v-for="(item, index) in players" :key="index">
|
||||
<Avatar v-if="item.id" :src="item.avatar" :size="36" />
|
||||
@@ -412,8 +638,17 @@ onBeforeUnmount(() => {
|
||||
<button hover-class="none" v-if="item.id === user.id" @click="chooseTeam(0)">
|
||||
<image src="../static/close-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<view v-if="item.id">
|
||||
<view
|
||||
v-if="item.id && isMember(item)"
|
||||
:class="['team-player-name', 'truncate', ...getMemberNicknameClass(item)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<view v-if="item.id" class="team-player-avatar">
|
||||
<Avatar :src="item.avatar" :size="36" />
|
||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
||||
</view>
|
||||
@@ -424,14 +659,23 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
<view>
|
||||
<view v-for="(item, index) in blueTeam" :key="index" class="choose-side-right-item">
|
||||
<view v-if="item.id">
|
||||
<view v-if="item.id" class="team-player-avatar">
|
||||
<Avatar :src="item.avatar" :size="36" />
|
||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
||||
</view>
|
||||
<button v-else hover-class="none" @click="chooseTeam(1)">
|
||||
<image src="../static/add-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<view
|
||||
v-if="item.id && isMember(item)"
|
||||
:class="['team-player-name', 'truncate', ...getMemberNicknameClass(item)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<button hover-class="none" v-if="item.id === user.id" @click="chooseTeam(0)">
|
||||
<image src="../static/close-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
@@ -443,7 +687,10 @@ onBeforeUnmount(() => {
|
||||
<PlayerSeats v-if="room.battleType === 2" :total="room.count || 10" :players="players"
|
||||
:removePlayer="removePlayer" :isOwner="owner.id === user.id" />
|
||||
<view>
|
||||
<SButton :disabled="!canClick" :onClick="() => $clickSound(getReady)">
|
||||
<SButton
|
||||
:disabled="!canClick || readySubmitting"
|
||||
:onClick="() => { $clickSound(); return getReady(); }"
|
||||
>
|
||||
{{
|
||||
allReady.value
|
||||
? "即将进入对局..."
|
||||
@@ -456,6 +703,14 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
</view>
|
||||
</Container>
|
||||
<ModalDialog
|
||||
:show="showLimitModal"
|
||||
:content="'今日约战次数已经用完\n开通会员可增加次数'"
|
||||
cancelText="知道了"
|
||||
confirmText="去开通"
|
||||
:onCancel="closeLimitModal"
|
||||
:onConfirm="goVipPage"
|
||||
/>
|
||||
<!-- 踢出玩家二次确认弹窗(不传 onClose,屏蔽 X 关闭按钮) -->
|
||||
<ScreenHint :show="showKickConfirm">
|
||||
<view class="kick-confirm">
|
||||
@@ -554,11 +809,12 @@ onBeforeUnmount(() => {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.player>text:nth-child(3) {
|
||||
.room-player-name {
|
||||
margin-top: 6rpx;
|
||||
}
|
||||
|
||||
.player>text {
|
||||
.player>text,
|
||||
.room-player-name {
|
||||
max-width: 100px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
@@ -566,6 +822,12 @@ onBeforeUnmount(() => {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.room-player-name .member-nickname__text,
|
||||
.room-player-name .member-nickname__shine {
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.player .ready {
|
||||
background-color: #2c261fb3 !important;
|
||||
border: 1rpx solid #a3793f66 !important;
|
||||
@@ -813,12 +1075,18 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
.choose-side-left-item>text,
|
||||
.choose-side-right-item>text {
|
||||
.choose-side-right-item>text,
|
||||
.team-player-name {
|
||||
margin: 10px;
|
||||
max-width: 100px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.team-player-name .member-nickname__text,
|
||||
.team-player-name .member-nickname__shine {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.choose-side-left-item>button:first-child,
|
||||
.choose-side-right-item>button:last-child {
|
||||
position: absolute;
|
||||
@@ -855,15 +1123,13 @@ onBeforeUnmount(() => {
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.choose-side-left-item>view,
|
||||
.choose-side-right-item>view {
|
||||
.team-player-avatar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.choose-side-left-item>view>text,
|
||||
.choose-side-right-item>view>text {
|
||||
.team-player-avatar>text {
|
||||
font-size: 16rpx;
|
||||
border-radius: 20rpx;
|
||||
line-height: 26rpx;
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import Container from "@/components/Container.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import Signin from "@/components/Signin.vue";
|
||||
import UserHeader from "@/components/UserHeader.vue";
|
||||
import { createOrderAPI, getHomeData, getVIPDescAPI } from "@/apis";
|
||||
import { formatTimestamp } from "@/util";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user, config } = storeToRefs(store);
|
||||
const { updateUser } = store;
|
||||
|
||||
const selectedVIP = ref(0);
|
||||
const showModal = ref(false);
|
||||
const lastDate = ref(user.value.expiredAt);
|
||||
const refreshing = ref(false);
|
||||
const timer = ref(null);
|
||||
const richContent = ref("");
|
||||
|
||||
const onPay = async () => {
|
||||
if (!user.value.id) {
|
||||
showModal.value = true;
|
||||
} else if (config.value.vipMenus[selectedVIP.value]) {
|
||||
if (config.value.vipMenus[selectedVIP.value].id) {
|
||||
const result = await createOrderAPI(
|
||||
config.value.vipMenus[selectedVIP.value].id
|
||||
);
|
||||
if (!result.pay) return;
|
||||
const params = result.pay.order.jsApi.params;
|
||||
if (params) {
|
||||
wx.requestPayment({
|
||||
timeStamp: params.timeStamp, // 时间戳
|
||||
nonceStr: params.nonceStr, // 随机字符串
|
||||
package: params.package, // 统一下单接口返回的 prepay_id 参数值,格式:prepay_id=***
|
||||
paySign: params.paySign, // 签名
|
||||
signType: "RSA", // 签名类型,默认为RSA
|
||||
async success(res) {
|
||||
uni.showToast({
|
||||
title: "支付成功",
|
||||
icon: "none",
|
||||
});
|
||||
timer.value = setInterval(async () => {
|
||||
refreshing.value = true;
|
||||
const result = await getHomeData();
|
||||
if (result.user.expiredAt > lastDate.value) {
|
||||
refreshing.value = false;
|
||||
if (result.user) updateUser(result.user);
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
fail(res) {
|
||||
console.log("pay error", res);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const result = await getVIPDescAPI();
|
||||
richContent.value = result.describe;
|
||||
});
|
||||
|
||||
const toOrderPage = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/orders",
|
||||
});
|
||||
};
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="会员说明">
|
||||
<view v-if="user.id" class="header">
|
||||
<view>
|
||||
<Avatar :src="user.avatar" :size="35" />
|
||||
<text class="truncate">{{ user.nickName }}</text>
|
||||
<image
|
||||
class="user-name-image"
|
||||
src="../static/vip1.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<block v-if="refreshing">
|
||||
<image
|
||||
src="../static/btn-loading.png"
|
||||
mode="widthFix"
|
||||
class="loading"
|
||||
/>
|
||||
</block>
|
||||
<block v-else>
|
||||
<text v-if="user.expiredAt">
|
||||
{{ formatTimestamp(user.expiredAt) }} 到期
|
||||
</text>
|
||||
</block>
|
||||
</view>
|
||||
<view
|
||||
class="container"
|
||||
:style="{ height: !user.id ? 'calc(100% - 10px)' : 'calc(100% - 62px)' }"
|
||||
>
|
||||
<view class="content vip-content">
|
||||
<view class="title-bar">
|
||||
<view />
|
||||
<text>VIP 介绍</text>
|
||||
</view>
|
||||
<view :style="{ marginTop: '10rpx' }">
|
||||
<rich-text :nodes="richContent" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="title-bar">
|
||||
<view />
|
||||
<text>会员续费</text>
|
||||
</view>
|
||||
<view class="vip-items">
|
||||
<view
|
||||
v-for="(item, index) in config.vipMenus || []"
|
||||
:key="index"
|
||||
:style="{
|
||||
color: selectedVIP === index ? '#fff' : '#333333',
|
||||
borderColor: selectedVIP === index ? '#FF7D57' : '#eee',
|
||||
background:
|
||||
selectedVIP === index
|
||||
? '#FF7D57'
|
||||
: 'linear-gradient(180deg, #fbfbfb 0%, #f5f5f5 100%)',
|
||||
}"
|
||||
@click="() => (selectedVIP = index)"
|
||||
>
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<SButton :onClick="onPay">支付</SButton>
|
||||
<view class="my-orders" v-if="user.id">
|
||||
<view @click="toOrderPage">
|
||||
<text>我的订单</text>
|
||||
<image src="../static/enter-arrow-blue.png" mode="widthFix" />
|
||||
</view>
|
||||
</view>
|
||||
<Signin :show="showModal" :onClose="() => (showModal = false)" />
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header {
|
||||
width: calc(100% - 30px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
color: #fff;
|
||||
padding: 15px;
|
||||
padding-top: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.header > view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.header > view > text {
|
||||
margin-left: 10px;
|
||||
max-width: 120px;
|
||||
text-align: left;
|
||||
}
|
||||
.header > view > image {
|
||||
margin-left: 5px;
|
||||
width: 20px;
|
||||
}
|
||||
.header > text:nth-child(2) {
|
||||
color: #fed847;
|
||||
}
|
||||
.container {
|
||||
width: 100%;
|
||||
background-color: #f5f5f5;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
padding: 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.title-bar {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #000;
|
||||
}
|
||||
.title-bar > view:first-child {
|
||||
width: 5px;
|
||||
height: 15px;
|
||||
border-radius: 10px;
|
||||
background-color: #fed847;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.content > view:nth-child(2) {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
.vip-items {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 23.5%);
|
||||
padding: 10px;
|
||||
row-gap: 5%;
|
||||
column-gap: 2%;
|
||||
}
|
||||
.vip-items > view {
|
||||
border: 1px solid #eee;
|
||||
padding: 12px 0;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
.vip-content {
|
||||
max-height: 62%;
|
||||
}
|
||||
.vip-content > view:nth-child(2) {
|
||||
overflow: auto;
|
||||
}
|
||||
.vip-content > view:nth-child(2)::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
color: transparent;
|
||||
}
|
||||
.my-orders {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
color: #39a8ff;
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.my-orders > view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.my-orders > view > image {
|
||||
width: 15px;
|
||||
}
|
||||
.loading {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-left: 10px;
|
||||
transition: all 0.3s ease;
|
||||
background-blend-mode: darken;
|
||||
animation: rotate 2s linear infinite;
|
||||
}
|
||||
</style>
|
||||
+80
-23
@@ -15,20 +15,21 @@ import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import audioManager from "@/audioManager";
|
||||
import {
|
||||
createPractiseAPI,
|
||||
startPractiseAPI,
|
||||
endPractiseAPI,
|
||||
getPractiseAPI,
|
||||
startPractiseAPI,
|
||||
laserAimAPI,
|
||||
laserCloseAPI,
|
||||
} from "@/apis";
|
||||
import { connectMatchWebSocket, closeMatchWebSocket } from "@/matchWebsocket";
|
||||
import { sharePractiseData } from "@/canvas";
|
||||
import { wxShare, debounce } from "@/util";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const { user, device } = storeToRefs(store);
|
||||
const scores = ref([]);
|
||||
const isSvip = ref(false);
|
||||
const step = ref(0);
|
||||
const total = 12;
|
||||
const stepButtonTexts = [
|
||||
@@ -48,6 +49,8 @@ const practiseId = ref("");
|
||||
const showGuide = ref(false);
|
||||
const laserActive = ref(false);
|
||||
const guideSwiperIndex = ref(0);
|
||||
const sharing = ref(false);
|
||||
const RESULT_TIP_CDN = "https://static.shelingxingqiu.com/shootmini/static";
|
||||
|
||||
const guideImages = [
|
||||
"https://static.shelingxingqiu.com/shootmini/static/target.png",
|
||||
@@ -102,20 +105,54 @@ const closeCalibrationLaser = async () => {
|
||||
};
|
||||
|
||||
const createPractise = async (arrows) => {
|
||||
const result = await createPractiseAPI(arrows, 1);
|
||||
closeMatchWebSocket({ reason: "practice-recreate" });
|
||||
const result = await createPractiseAPI(
|
||||
arrows,
|
||||
120,
|
||||
1,
|
||||
device.value.deviceId
|
||||
);
|
||||
if (result) practiseId.value = result.id;
|
||||
if (!result?.serverAddr) {
|
||||
uni.showToast({
|
||||
title: "练习连接信息异常,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return null;
|
||||
}
|
||||
connectMatchWebSocket({
|
||||
serverAddr: result.serverAddr,
|
||||
matchId: result.id,
|
||||
userId: user.value.id,
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const onOver = async () => {
|
||||
practiseResult.value = await getPractiseAPI(practiseId.value);
|
||||
const onOver = async (message) => {
|
||||
practiseResult.value = Array.isArray(message?.details)
|
||||
? message
|
||||
: await getPractiseAPI(practiseId.value);
|
||||
start.value = false;
|
||||
};
|
||||
|
||||
const beginPractise = async () => {
|
||||
if (!practiseId.value) {
|
||||
uni.showToast({
|
||||
title: "练习未创建,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
await startPractiseAPI(practiseId.value);
|
||||
return true;
|
||||
};
|
||||
|
||||
async function onReceiveMessage(msg) {
|
||||
if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
scores.value = msg.details;
|
||||
isSvip.value = msg.sVip === true;
|
||||
scores.value = Array.isArray(msg.details) ? msg.details : scores.value;
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||
setTimeout(onOver, 1500);
|
||||
setTimeout(() => onOver(msg), 1500);
|
||||
} else if (msg.type === MESSAGETYPESV2.TestDistance && step.value === 3) {
|
||||
if (msg.shootData.distance / 100 >= 5) {
|
||||
audioManager.play("距离合格");
|
||||
@@ -139,11 +176,23 @@ async function onReceiveMessage(msg) {
|
||||
}
|
||||
|
||||
const onClickShare = debounce(async () => {
|
||||
await sharePractiseData("shareCanvas", 1, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
if (sharing.value) return;
|
||||
sharing.value = true;
|
||||
try {
|
||||
await sharePractiseData("shareCanvas", 1, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "海报生成失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
sharing.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
void audioManager.warmAll();
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
@@ -159,7 +208,7 @@ onBeforeUnmount(async () => {
|
||||
uni.$off("share-image", onClickShare);
|
||||
await closeCalibrationLaser();
|
||||
audioManager.stopAll();
|
||||
endPractiseAPI();
|
||||
closeMatchWebSocket({ reason: "practice-leave" });
|
||||
});
|
||||
|
||||
const nextStep = async () => {
|
||||
@@ -182,16 +231,22 @@ const nextStep = async () => {
|
||||
btnDisabled.value = true;
|
||||
step.value = 3;
|
||||
title.value = "-感知距离";
|
||||
const result = await createPractiseAPI(total, 120);
|
||||
if (result) practiseId.value = result.id;
|
||||
const result = await createPractise(total);
|
||||
if (!result) {
|
||||
btnDisabled.value = false;
|
||||
step.value = 2;
|
||||
return;
|
||||
}
|
||||
} else if (step.value === 3) {
|
||||
showGuide.value = false;
|
||||
step.value = 4;
|
||||
title.value = "-小试牛刀";
|
||||
} else if (step.value === 4) {
|
||||
title.value = "小试牛刀";
|
||||
await startPractiseAPI();
|
||||
const result = await beginPractise();
|
||||
if (!result) return;
|
||||
scores.value = [];
|
||||
isSvip.value = false;
|
||||
step.value = 5;
|
||||
start.value = true;
|
||||
setTimeout(() => {
|
||||
@@ -218,11 +273,18 @@ const onClose = async () => {
|
||||
practiseResult.value = {};
|
||||
start.value = false;
|
||||
scores.value = [];
|
||||
isSvip.value = false;
|
||||
step.value = 4;
|
||||
const result = await createPractiseAPI(total, 120);
|
||||
if (result) practiseId.value = result.id;
|
||||
await createPractise(total);
|
||||
}
|
||||
};
|
||||
|
||||
const getResultTipSrc = (result = {}) => {
|
||||
const validCount = (result.details || []).filter(
|
||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||
).length;
|
||||
return `${RESULT_TIP_CDN}/${validCount < total ? "un" : ""}finish-tip.png`;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -331,6 +393,7 @@ const onClose = async () => {
|
||||
:currentRound="step === 5 ? scores.length : 0"
|
||||
:totalRound="step === 5 ? total : 0"
|
||||
:scores="scores"
|
||||
:isSvip="isSvip"
|
||||
/>
|
||||
<ScorePanel
|
||||
v-if="step === 5"
|
||||
@@ -344,13 +407,7 @@ const onClose = async () => {
|
||||
:total="total"
|
||||
:onClose="onClose"
|
||||
:result="practiseResult"
|
||||
:tipSrc="`../static/${
|
||||
practiseResult.details.filter(
|
||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||
).length < total
|
||||
? 'un'
|
||||
: ''
|
||||
}finish-tip.png`"
|
||||
:tipSrc="getResultTipSrc(practiseResult)"
|
||||
/>
|
||||
<canvas class="share-canvas" id="shareCanvas" type="2d"></canvas>
|
||||
</view>
|
||||
|
||||
@@ -27,6 +27,8 @@ const data = ref({});
|
||||
const showOverlay = ref(false);
|
||||
/** 自动关闭覆盖层的计时器 */
|
||||
const overlayTimer = ref(null);
|
||||
const overlayDelayTimer = ref(null);
|
||||
let loadGeneration = 0;
|
||||
/** 控制经验条是否执行进场动画(弹窗关闭后才置 true,避免动画被遮挡) */
|
||||
const showExpAnim = ref(false);
|
||||
|
||||
@@ -83,6 +85,13 @@ const mvpPlayer = computed(() => {
|
||||
return null;
|
||||
});
|
||||
|
||||
const mvpTotalRing = computed(
|
||||
() =>
|
||||
mvpPlayer.value?.playerMatchResult?.totalRing ??
|
||||
mvpPlayer.value?.totalRing ??
|
||||
0
|
||||
);
|
||||
|
||||
/**
|
||||
* MVP 玩家所在队伍编号(1=蓝队,2=红队)
|
||||
* 通过比对 mvpPlayer.id 与 blueTeamPlayers 确定,用于选择背景图(mvp-blue / mvp-red)
|
||||
@@ -92,6 +101,14 @@ const mvpTeam = computed(() => {
|
||||
return blueTeamPlayers.value.some((p) => p.id === mvpPlayer.value.id) ? 1 : 2;
|
||||
});
|
||||
|
||||
const isMember = (player = {}) => player.vip === true || player.sVip === true;
|
||||
|
||||
const getMemberNicknameClass = (player = {}) => [
|
||||
"member-nickname",
|
||||
player.vip === true && player.sVip !== true ? "member-nickname--vip" : "",
|
||||
player.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
/**
|
||||
* 激励语图片 URL(在 onLoad 中确定 ifWin 后赋值,避免 Math.random 放在 computed 里产生缓存不一致问题)
|
||||
*/
|
||||
@@ -128,6 +145,8 @@ const meleeRankList = computed(() => {
|
||||
id: p.id,
|
||||
avatar: p.avatar || "",
|
||||
name: p.name || "",
|
||||
vip: p.vip,
|
||||
sVip: p.sVip,
|
||||
// rank_lvl 字段可能缺失,缺失时显示空字符串,避免 getLvlName(undefined) 返回错误段位名
|
||||
lvlName: p.rank_lvl != null ? getLvlName(p.rank_lvl) : "",
|
||||
totalRing: resultItem.totalRing ?? 0,
|
||||
@@ -165,9 +184,11 @@ function getMeleeAvatarBorderColor(rank) {
|
||||
// ---- 生命周期 ----
|
||||
|
||||
onLoad(async (options) => {
|
||||
const currentLoadId = ++loadGeneration;
|
||||
if (!options.battleId) return;
|
||||
|
||||
const result = await getBattleAPI(options.battleId);
|
||||
if (currentLoadId !== loadGeneration) return;
|
||||
data.value = result;
|
||||
|
||||
// 从 teams 各队伍的 players 中找到当前用户,解析经验进度条所需字段
|
||||
@@ -209,7 +230,8 @@ onLoad(async (options) => {
|
||||
}
|
||||
|
||||
// 数据加载完成后延迟 1 秒再显示激励弹窗,避免进场时画面太杂
|
||||
setTimeout(() => {
|
||||
overlayDelayTimer.value = setTimeout(() => {
|
||||
overlayDelayTimer.value = null;
|
||||
showOverlay.value = true;
|
||||
// 弹窗显示后 2.5 秒自动关闭
|
||||
overlayTimer.value = setTimeout(() => {
|
||||
@@ -219,7 +241,15 @@ onLoad(async (options) => {
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (overlayTimer.value) clearTimeout(overlayTimer.value);
|
||||
loadGeneration += 1;
|
||||
if (overlayDelayTimer.value) {
|
||||
clearTimeout(overlayDelayTimer.value);
|
||||
overlayDelayTimer.value = null;
|
||||
}
|
||||
if (overlayTimer.value) {
|
||||
clearTimeout(overlayTimer.value);
|
||||
overlayTimer.value = null;
|
||||
}
|
||||
});
|
||||
|
||||
// ---- 方法 ----
|
||||
@@ -332,7 +362,20 @@ function goBack() {
|
||||
<view class="team-players team-players-blue">
|
||||
<view v-for="p in blueTeamPlayers" :key="p.id" class="player-item">
|
||||
<Avatar :src="p.avatar" :size="34" borderColor="#8FB4FD" />
|
||||
<text class="player-name player-name-blue">{{ p.name }}</text>
|
||||
<view
|
||||
v-if="isMember(p)"
|
||||
:class="[
|
||||
'player-name',
|
||||
'player-name-blue',
|
||||
...getMemberNicknameClass(p),
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ p.name }}</text>
|
||||
<text v-if="p.sVip === true" class="member-nickname__shine">
|
||||
{{ p.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="player-name player-name-blue">{{ p.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -340,7 +383,20 @@ function goBack() {
|
||||
<view class="team-players team-players-red">
|
||||
<view v-for="p in redTeamPlayers" :key="p.id" class="player-item">
|
||||
<Avatar :src="p.avatar" :size="34" borderColor="#E67470" />
|
||||
<text class="player-name player-name-red">{{ p.name }}</text>
|
||||
<view
|
||||
v-if="isMember(p)"
|
||||
:class="[
|
||||
'player-name',
|
||||
'player-name-red',
|
||||
...getMemberNicknameClass(p),
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ p.name }}</text>
|
||||
<text v-if="p.sVip === true" class="member-nickname__shine">
|
||||
{{ p.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="player-name player-name-red">{{ p.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -368,14 +424,14 @@ function goBack() {
|
||||
<!-- 背景图:蓝队用 mvp-blue.png,红队用 mvp-red.png(平行四边形渐变切图) -->
|
||||
<image
|
||||
class="mvp-bg"
|
||||
:src="mvpTeam === 1 ? '../static/mvp-blue.png' : '../static/mvp-red.png'"
|
||||
:src="mvpTeam === 1 ? 'https://static.shelingxingqiu.com/shootmini/static/mvp-blue.png' : 'https://static.shelingxingqiu.com/shootmini/static/mvp-red.png'"
|
||||
mode="scaleToFill"
|
||||
/>
|
||||
<!-- 左:MVP 标题图 + 斩获环数 -->
|
||||
<view class="mvp-info">
|
||||
<image class="mvp-badge" src="../static/mvp-tip.png" mode="widthFix" />
|
||||
<image class="mvp-badge" src="https://static.shelingxingqiu.com/shootmini/static/mvp-tip.png" mode="widthFix" />
|
||||
<view class="mvp-rings">
|
||||
斩获<text class="mvp-rings-num">{{ mvpPlayer.totalRing }}</text>环
|
||||
斩获<text class="mvp-rings-num">{{ mvpTotalRing }}</text>环
|
||||
</view>
|
||||
</view>
|
||||
<!-- 右:MVP 头像 + 名字,边框颜色跟随 MVP 所在队伍 -->
|
||||
@@ -385,7 +441,16 @@ function goBack() {
|
||||
:size="53"
|
||||
:borderColor="mvpTeam === 1 ? '#5FADFF' : '#FF6060'"
|
||||
/>
|
||||
<text class="mvp-name">{{ mvpPlayer.name }}</text>
|
||||
<view
|
||||
v-if="isMember(mvpPlayer)"
|
||||
:class="['mvp-name', ...getMemberNicknameClass(mvpPlayer)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ mvpPlayer.name }}</text>
|
||||
<text v-if="mvpPlayer.sVip === true" class="member-nickname__shine">
|
||||
{{ mvpPlayer.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="mvp-name">{{ mvpPlayer.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -394,7 +459,7 @@ function goBack() {
|
||||
<!-- 本场战绩标题:装饰横线 + 标题图 + 装饰横线 -->
|
||||
<view class="melee-title">
|
||||
<view class="melee-title-line" />
|
||||
<image class="melee-title-img" src="../static/battle-result.png" mode="scaleToFill" />
|
||||
<image class="melee-title-img" src="https://static.shelingxingqiu.com/shootmini/static/battle-result.png" mode="scaleToFill" />
|
||||
<view class="melee-title-line" />
|
||||
</view>
|
||||
|
||||
@@ -433,7 +498,16 @@ function goBack() {
|
||||
|
||||
<!-- 昵称 + 段位 -->
|
||||
<view class="rank-player-info">
|
||||
<text class="rank-player-name">{{ item.name }}</text>
|
||||
<view
|
||||
v-if="isMember(item)"
|
||||
:class="['rank-player-name', ...getMemberNicknameClass(item)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="rank-player-name">{{ item.name }}</text>
|
||||
<text class="rank-player-lvl">{{ item.lvlName }}</text>
|
||||
</view>
|
||||
|
||||
@@ -613,6 +687,12 @@ function goBack() {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.player-name .member-nickname__text,
|
||||
.player-name .member-nickname__shine {
|
||||
font-size: 22rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* ---- 得分行 ---- */
|
||||
.vs-scores-row {
|
||||
position: relative;
|
||||
@@ -752,6 +832,11 @@ function goBack() {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.mvp-name .member-nickname__text,
|
||||
.mvp-name .member-nickname__shine {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* ============================
|
||||
查看完整成绩链接
|
||||
============================ */
|
||||
@@ -1072,6 +1157,12 @@ function goBack() {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rank-player-name .member-nickname__text,
|
||||
.rank-player-name .member-nickname__shine {
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.rank-player-lvl {
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
|
||||
+107
-17
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import GuideTwo from "@/components/GuideTwo.vue";
|
||||
@@ -8,14 +8,16 @@ import SModal from "@/components/SModal.vue";
|
||||
import Signin from "@/components/Signin.vue";
|
||||
import CreateRoom from "@/components/CreateRoom.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import ModalDialog from "@/components/ModalDialog.vue";
|
||||
|
||||
import { getRoomAPI, joinRoomAPI, getBattleDataAPI } from "@/apis";
|
||||
import { debounce, canEenter } from "@/util";
|
||||
import { getRoomAPI, joinRoomAPI, getBattleDataAPI, getDailyCountAPI } from "@/apis";
|
||||
import { debounce, canEenter, getLimitCountText, isLimitReached } from "@/util";
|
||||
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user, device, online, game } = storeToRefs(store);
|
||||
const { user, device, online, game, dailyCount } = storeToRefs(store);
|
||||
const { updateDailyCount } = store;
|
||||
|
||||
const showModal = ref(false);
|
||||
const showSignin = ref(false);
|
||||
@@ -24,6 +26,13 @@ const roomNumber = ref("");
|
||||
const data = ref({});
|
||||
const roomID = ref("");
|
||||
const loading = ref(false);
|
||||
const showLimitModal = ref(false);
|
||||
const createRoomLoading = ref(false);
|
||||
const isSVip = computed(() => user.value.sVip === true);
|
||||
const isVip = computed(() => user.value.vip === true && !isSVip.value);
|
||||
const challengeLimitText = computed(() =>
|
||||
getLimitCountText("约战", dailyCount.value.challenge)
|
||||
);
|
||||
|
||||
const enterRoom = debounce(async (number) => {
|
||||
if (loading.value) return;
|
||||
@@ -37,6 +46,8 @@ const enterRoom = debounce(async (number) => {
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
let keepLoading = false;
|
||||
try {
|
||||
const room = await getRoomAPI(number);
|
||||
if (!room.number) {
|
||||
@@ -55,18 +66,55 @@ const enterRoom = debounce(async (number) => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
loading.value = true;
|
||||
keepLoading = true;
|
||||
uni.navigateTo({
|
||||
url: "/pages/battle-room?roomNumber=" + number,
|
||||
fail: () => {
|
||||
loading.value = false;
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
if (!keepLoading) loading.value = false;
|
||||
}
|
||||
});
|
||||
const onCreateRoom = async () => {
|
||||
const onCreateRoom = debounce(async () => {
|
||||
if (createRoomLoading.value) return;
|
||||
if (!canEenter(user.value, device.value, online.value)) return;
|
||||
warnning.value = "";
|
||||
showModal.value = true;
|
||||
createRoomLoading.value = true;
|
||||
try {
|
||||
const countData = await loadDailyCount();
|
||||
if (isLimitReached(countData.challenge)) {
|
||||
showLimitModal.value = true;
|
||||
return;
|
||||
}
|
||||
warnning.value = "";
|
||||
showModal.value = true;
|
||||
} finally {
|
||||
createRoomLoading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const closeLimitModal = () => {
|
||||
showLimitModal.value = false;
|
||||
};
|
||||
|
||||
const goVipPage = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.navigateTo({
|
||||
url: "/pages/member/be-vip",
|
||||
});
|
||||
};
|
||||
|
||||
const loadDailyCount = async () => {
|
||||
if (!user.value.id) return dailyCount.value;
|
||||
try {
|
||||
const result = await getDailyCountAPI();
|
||||
updateDailyCount(result);
|
||||
return result || dailyCount.value;
|
||||
} catch (error) {
|
||||
console.log("load daily count error", error);
|
||||
return dailyCount.value;
|
||||
}
|
||||
};
|
||||
const onSignin = () => {
|
||||
if (roomID.value && user.value.id) enterRoom(roomID.value);
|
||||
@@ -80,8 +128,12 @@ const goMyRecord = () => {
|
||||
});
|
||||
};
|
||||
onShow(async () => {
|
||||
loading.value = false;
|
||||
if (user.value.id) {
|
||||
const result = await getBattleDataAPI();
|
||||
const [result] = await Promise.all([
|
||||
getBattleDataAPI(),
|
||||
loadDailyCount(),
|
||||
]);
|
||||
data.value = result;
|
||||
}
|
||||
});
|
||||
@@ -106,7 +158,18 @@ onLoad(async (options) => {
|
||||
<view class="my-data">
|
||||
<view>
|
||||
<Avatar :rankLvl="user.rankLvl" :src="user.avatar" :size="30" />
|
||||
<text class="truncate">{{ user.nickName }}</text>
|
||||
<view
|
||||
:class="[
|
||||
'member-nickname',
|
||||
isVip ? 'member-nickname--vip' : '',
|
||||
isSVip ? 'member-nickname--svip' : '',
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ user.nickName }}</text>
|
||||
<text v-if="isSVip" class="member-nickname__shine">{{
|
||||
user.nickName
|
||||
}}</text>
|
||||
</view>
|
||||
<text class="my-record-btn" @click="goMyRecord">我的战绩</text>
|
||||
</view>
|
||||
<view>
|
||||
@@ -146,16 +209,24 @@ onLoad(async (options) => {
|
||||
</view>
|
||||
<view class="create-room">
|
||||
<image src="https://static.shelingxingqiu.com/attachment/2025-07-15/dbcejys872iyun92h6.png" mode="widthFix" />
|
||||
<image src="../static/room-notfound-title.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/room-notfound-title.png" mode="widthFix" />
|
||||
<view>
|
||||
<image :src="user.avatar" mode="widthFix" />
|
||||
<image src="../static/versus.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/versus.png" mode="widthFix" />
|
||||
<view>
|
||||
<image src="../static/question-mark.png" mode="widthFix" />
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<SButton width="80%" :rounded="30" :onClick="() => $clickSound(onCreateRoom)">
|
||||
<view v-if="challengeLimitText" class="pp-text">
|
||||
{{ challengeLimitText }}
|
||||
</view>
|
||||
<SButton
|
||||
width="80%"
|
||||
:rounded="30"
|
||||
:disabled="createRoomLoading"
|
||||
:onClick="() => { $clickSound(); return onCreateRoom(); }"
|
||||
>
|
||||
创建约战房
|
||||
</SButton>
|
||||
</view>
|
||||
@@ -170,6 +241,14 @@ onLoad(async (options) => {
|
||||
<Signin :show="showSignin" :onClose="onSignin" />
|
||||
</view>
|
||||
</Container>
|
||||
<ModalDialog
|
||||
:show="showLimitModal"
|
||||
:content="'今日约战次数已经用完\n开通会员可增加次数'"
|
||||
cancelText="知道了"
|
||||
confirmText="去开通"
|
||||
:onCancel="closeLimitModal"
|
||||
:onConfirm="goVipPage"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -255,7 +334,7 @@ onLoad(async (options) => {
|
||||
}
|
||||
|
||||
.create-room>view:nth-child(3) {
|
||||
margin: 12vw auto;
|
||||
margin: 12vw auto 5vw auto;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -291,6 +370,13 @@ onLoad(async (options) => {
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.pp-text{
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-size: 22rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.warnning {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -335,13 +421,17 @@ onLoad(async (options) => {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.my-data>view:first-child>text {
|
||||
.my-data>view:first-child>.member-nickname {
|
||||
color: #fff;
|
||||
font-size: 17px;
|
||||
margin-left: 10px;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.my-data>view:first-child>.member-nickname__text,
|
||||
.my-data>view:first-child>.member-nickname__shine {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.my-data>view:last-child {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
+116
-29
@@ -1,31 +1,66 @@
|
||||
<script setup>
|
||||
import { computed } from "vue";
|
||||
import Container from "@/components/Container.vue";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
|
||||
const MAX_LEVEL = 100;
|
||||
const LEVEL_NODE_WIDTH_RPX = 72;
|
||||
const TRACK_PADDING_RPX = 20;
|
||||
const windowWidth = uni.getSystemInfoSync().windowWidth;
|
||||
const rpxToPx = (value) => (value * windowWidth) / 750;
|
||||
const levels = Array.from({ length: MAX_LEVEL }, (_, index) => index + 1);
|
||||
const currentLevel = computed(() => {
|
||||
const level = Number(user.value?.lvl) || 1;
|
||||
return Math.min(Math.max(level, 1), MAX_LEVEL);
|
||||
});
|
||||
const currentLevelScrollLeft = computed(() => {
|
||||
const nodeWidth = rpxToPx(LEVEL_NODE_WIDTH_RPX);
|
||||
const trackPadding = rpxToPx(TRACK_PADDING_RPX);
|
||||
const contentWidth = rpxToPx(
|
||||
TRACK_PADDING_RPX * 2 + MAX_LEVEL * LEVEL_NODE_WIDTH_RPX
|
||||
);
|
||||
const currentCenter =
|
||||
trackPadding + (currentLevel.value - 1) * nodeWidth + nodeWidth / 2;
|
||||
const targetLeft = currentCenter - windowWidth / 2;
|
||||
const maxScrollLeft = Math.max(contentWidth - windowWidth, 0);
|
||||
|
||||
return Math.min(Math.max(targetLeft, 0), maxScrollLeft);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="等级介绍">
|
||||
<view class="container">
|
||||
<!-- 等级进度条 -->
|
||||
<view class="level-progress">
|
||||
<view v-for="(_, index) in 10" :key="index" class="progress-dot">
|
||||
<scroll-view
|
||||
class="level-progress"
|
||||
scroll-x
|
||||
:show-scrollbar="false"
|
||||
:scroll-left="currentLevelScrollLeft"
|
||||
scroll-with-animation
|
||||
>
|
||||
<view class="level-track">
|
||||
<view
|
||||
:style="{
|
||||
backgroundColor:
|
||||
index + 1 < user.lvl
|
||||
? '#fff9'
|
||||
: index + 1 === user.lvl
|
||||
? '#fed847'
|
||||
: 'transparent',
|
||||
borderColor: index + 1 === user.lvl ? '#fed847' : '#fff9',
|
||||
}"
|
||||
/>
|
||||
<view />
|
||||
v-for="level in levels"
|
||||
:id="`level-${level}`"
|
||||
:key="level"
|
||||
:class="[
|
||||
'level-node',
|
||||
level < currentLevel ? 'level-node--done' : '',
|
||||
level === currentLevel ? 'level-node--current' : '',
|
||||
]"
|
||||
>
|
||||
<view class="level-node__top">
|
||||
<view class="level-node__dot" />
|
||||
<view v-if="level < MAX_LEVEL" class="level-node__line" />
|
||||
</view>
|
||||
<text class="level-node__label">{{ level }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 说明文本 -->
|
||||
<view class="body">
|
||||
@@ -65,28 +100,80 @@ const { user } = storeToRefs(store);
|
||||
|
||||
.level-progress {
|
||||
width: 100%;
|
||||
height: 32rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-top: 20rpx;
|
||||
padding-bottom: 40rpx;
|
||||
white-space: nowrap;
|
||||
padding: 24rpx 0 34rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.progress-dot {
|
||||
.level-track {
|
||||
display: inline-flex;
|
||||
align-items: flex-start;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.level-node {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
width: 72rpx;
|
||||
flex: 0 0 72rpx;
|
||||
}
|
||||
|
||||
.level-node__top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
.progress-dot > view:first-child {
|
||||
width: 3.8vw;
|
||||
height: 3.8vw;
|
||||
|
||||
.level-node__dot {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #fff9;
|
||||
border: 3rpx solid rgba(255, 255, 255, 0.45);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.progress-dot > view:last-child {
|
||||
width: 3.8vw;
|
||||
height: 1px;
|
||||
margin: 0 2px;
|
||||
background-color: #fff9;
|
||||
|
||||
.level-node__line {
|
||||
flex: 1;
|
||||
height: 2rpx;
|
||||
background-color: rgba(255, 255, 255, 0.45);
|
||||
}
|
||||
|
||||
.level-node__label {
|
||||
width: 28rpx;
|
||||
margin-top: 14rpx;
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
font-size: 24rpx;
|
||||
line-height: 28rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.level-node--done .level-node__dot {
|
||||
background-color: #ffffff;
|
||||
border-color: #ffffff;
|
||||
}
|
||||
|
||||
.level-node--done .level-node__line {
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.level-node--done .level-node__label {
|
||||
color: rgba(255, 255, 255, 0.72);
|
||||
}
|
||||
|
||||
.level-node--current .level-node__dot {
|
||||
background-color: #fed847;
|
||||
border-color: #fed847;
|
||||
}
|
||||
|
||||
.level-node--current .level-node__line {
|
||||
background-color: rgba(255, 255, 255, 0.45);
|
||||
}
|
||||
|
||||
.level-node--current .level-node__label {
|
||||
color: #fed847;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.body {
|
||||
|
||||
+241
-13
@@ -1,19 +1,23 @@
|
||||
<script setup>
|
||||
import {onMounted, ref} from "vue";
|
||||
import {onMounted, onUnmounted, ref} from "vue";
|
||||
import {onShareAppMessage, onShareTimeline, onShow} from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import AppFooter from "@/components/AppFooter.vue";
|
||||
import UserHeader from "@/components/UserHeader.vue";
|
||||
import Signin from "@/components/Signin.vue";
|
||||
import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import OtaModal from "@/components/OtaModal.vue";
|
||||
|
||||
import {
|
||||
checkUserBindAPI,
|
||||
getAppConfig,
|
||||
getDeviceBatteryAPI,
|
||||
getHardwareBoxTaskStatusAPI,
|
||||
getHardwareBoxVersionAPI,
|
||||
getHomeData,
|
||||
getMyDevicesAPI,
|
||||
getScoreRankList,
|
||||
sendHardwareBoxUpdateAPI,
|
||||
silentLoginAPI,
|
||||
} from "@/apis";
|
||||
import {topThreeColors} from "@/constants";
|
||||
@@ -37,6 +41,208 @@ const showModal = ref(false);
|
||||
const showGuide = ref(false);
|
||||
const scoreRankList = ref([]);
|
||||
|
||||
// OTA 相关
|
||||
const otaVisible = ref(false);
|
||||
const otaState = ref("new_version");
|
||||
const otaProgress = ref(0);
|
||||
const otaInfo = ref({
|
||||
versionNumber: "",
|
||||
versionInfo: "",
|
||||
resourceUrl: "",
|
||||
forceUpdate: false,
|
||||
});
|
||||
const isStartingOta = ref(false);
|
||||
let otaProgressTimer = null;
|
||||
let otaStatusTimer = null;
|
||||
let otaTimeoutTimer = null;
|
||||
|
||||
// 清理首页 OTA 更新定时器,避免弹窗关闭或页面卸载后继续轮询。
|
||||
const clearOtaUpdateTimers = () => {
|
||||
clearInterval(otaProgressTimer);
|
||||
clearTimeout(otaStatusTimer);
|
||||
clearTimeout(otaTimeoutTimer);
|
||||
otaProgressTimer = null;
|
||||
otaStatusTimer = null;
|
||||
otaTimeoutTimer = null;
|
||||
};
|
||||
|
||||
// 启动首页 OTA 本地进度动画,最终成功失败以后端任务状态为准。
|
||||
const startOtaProgressAnimation = () => {
|
||||
clearInterval(otaProgressTimer);
|
||||
otaProgressTimer = setInterval(() => {
|
||||
if (otaProgress.value >= 90) {
|
||||
clearInterval(otaProgressTimer);
|
||||
return;
|
||||
}
|
||||
const increment = Math.max(0.5, 2 - otaProgress.value / 60);
|
||||
otaProgress.value = Math.min(90, otaProgress.value + increment);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
// 获取并保存后端返回的 OTA 版本信息,供弹窗展示和更新接口使用。
|
||||
const applyOtaVersionInfo = (versionInfo) => {
|
||||
otaInfo.value = {
|
||||
versionNumber: versionInfo?.versionNumber || "",
|
||||
versionInfo: versionInfo?.versionInfo || "",
|
||||
resourceUrl: versionInfo?.resourceUrl || "",
|
||||
forceUpdate: Number(versionInfo?.forceUpdate) === 1,
|
||||
};
|
||||
};
|
||||
|
||||
// 检查当前设备盒子是否存在可升级版本。
|
||||
const checkOtaUpdate = async () => {
|
||||
let versionInfo;
|
||||
try {
|
||||
versionInfo = await getHardwareBoxVersionAPI();
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
if (!versionInfo?.needUpdate) 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;
|
||||
};
|
||||
|
||||
// 拼接 OTA WiFi 页参数,让未连 WiFi 的设备继续使用同一份版本信息。
|
||||
const getOtaWifiUrl = () => {
|
||||
const { versionNumber, resourceUrl } = otaInfo.value;
|
||||
const query = [
|
||||
`versionNumber=${encodeURIComponent(versionNumber)}`,
|
||||
`resourceUrl=${encodeURIComponent(resourceUrl)}`,
|
||||
].join("&");
|
||||
return `/pages/ota-wifi?${query}`;
|
||||
};
|
||||
|
||||
// 处理 OTA 弹窗暂不更新,强制更新时不允许关闭。
|
||||
const handleOtaDismiss = () => {
|
||||
if (otaInfo.value.forceUpdate) return;
|
||||
uni.setStorageSync("ota_dismissed_at", Date.now());
|
||||
otaVisible.value = false;
|
||||
};
|
||||
|
||||
// 将首页 OTA 直连更新流程标记为失败。
|
||||
const failHomeOtaUpdate = () => {
|
||||
clearOtaUpdateTimers();
|
||||
isStartingOta.value = false;
|
||||
otaState.value = "update_failure";
|
||||
otaVisible.value = true;
|
||||
};
|
||||
|
||||
// 将首页 OTA 直连更新流程标记为成功。
|
||||
const completeHomeOtaUpdate = () => {
|
||||
clearOtaUpdateTimers();
|
||||
isStartingOta.value = false;
|
||||
otaProgress.value = 100;
|
||||
setTimeout(() => {
|
||||
otaState.value = "update_success";
|
||||
otaVisible.value = true;
|
||||
}, 300);
|
||||
};
|
||||
|
||||
// 轮询首页直接发起的 OTA 更新任务状态。
|
||||
const pollHomeOtaTaskStatus = (taskId) => {
|
||||
clearTimeout(otaStatusTimer);
|
||||
otaStatusTimer = setTimeout(async () => {
|
||||
try {
|
||||
const taskStatus = await getHardwareBoxTaskStatusAPI(taskId);
|
||||
const status = Number(taskStatus?.status);
|
||||
if (status === 2) {
|
||||
completeHomeOtaUpdate();
|
||||
return;
|
||||
}
|
||||
if (status === 3) {
|
||||
failHomeOtaUpdate();
|
||||
return;
|
||||
}
|
||||
if (status === 0 || status === 1) {
|
||||
pollHomeOtaTaskStatus(taskId);
|
||||
return;
|
||||
}
|
||||
failHomeOtaUpdate();
|
||||
} catch (err) {
|
||||
failHomeOtaUpdate();
|
||||
}
|
||||
}, 3000);
|
||||
};
|
||||
|
||||
// 设备盒子已连 WiFi 时,从首页直接传空 WiFi 信息发起 OTA 更新。
|
||||
const startHomeOtaUpdate = async () => {
|
||||
otaState.value = "update_progress";
|
||||
otaVisible.value = true;
|
||||
otaProgress.value = 0;
|
||||
startOtaProgressAnimation();
|
||||
otaTimeoutTimer = setTimeout(() => {
|
||||
if (otaState.value === "update_progress") {
|
||||
failHomeOtaUpdate();
|
||||
}
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
try {
|
||||
const updateResult = await sendHardwareBoxUpdateAPI({
|
||||
versionNumber: otaInfo.value.versionNumber,
|
||||
wifiSsid: "",
|
||||
wifiPassword: "",
|
||||
resourceUrl: otaInfo.value.resourceUrl,
|
||||
});
|
||||
if (!updateResult?.taskId) {
|
||||
failHomeOtaUpdate();
|
||||
return;
|
||||
}
|
||||
pollHomeOtaTaskStatus(updateResult.taskId);
|
||||
} catch (err) {
|
||||
failHomeOtaUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
// 点击立即更新时先判断设备是否在线并已通过 WiFi 联网,已联网则首页直接更新,否则跳转 WiFi 页面。
|
||||
const handleOtaUpdate = async () => {
|
||||
if (isStartingOta.value) return;
|
||||
isStartingOta.value = true;
|
||||
let deviceStatus;
|
||||
try {
|
||||
deviceStatus = await getDeviceBatteryAPI();
|
||||
} catch (err) {
|
||||
isStartingOta.value = false;
|
||||
uni.showToast({
|
||||
title: "获取设备状态失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (deviceStatus?.online !== true) {
|
||||
isStartingOta.value = false;
|
||||
uni.showToast({
|
||||
title: "请先开启智能弓",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (String(deviceStatus?.netType || "").toLowerCase() === "wifi") {
|
||||
startHomeOtaUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
isStartingOta.value = false;
|
||||
otaVisible.value = false;
|
||||
uni.navigateTo({ url: getOtaWifiUrl() });
|
||||
};
|
||||
|
||||
// 处理 OTA 更新成功后的完成按钮,关闭结果弹窗。
|
||||
const handleOtaDone = () => {
|
||||
otaVisible.value = false;
|
||||
};
|
||||
|
||||
// 处理 OTA 更新失败后的重试按钮,重新走立即更新判断流程。
|
||||
const handleOtaRetry = () => {
|
||||
handleOtaUpdate();
|
||||
};
|
||||
|
||||
// 提取积分榜接口返回的榜单数组,兼容数组和对象两种返回格式。
|
||||
const getScoreRankData = (result) => {
|
||||
if (Array.isArray(result)) return result;
|
||||
@@ -50,11 +256,6 @@ const toPage = async (path) => {
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
// if (path === "/pages/first-try") {
|
||||
// if (canEenter(user.value, device.value, online.value, path)) {
|
||||
// await uni.$checkAudio();
|
||||
// }
|
||||
// }
|
||||
uni.navigateTo({url: path});
|
||||
};
|
||||
|
||||
@@ -64,10 +265,18 @@ const toRankListPage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
onShow(async () => {
|
||||
onShow(async (options) => {
|
||||
const env = uni.getAccountInfoSync().miniProgram.envVersion;
|
||||
const token = uni.getStorageSync(`${env}_token`);
|
||||
|
||||
// 检查是否从 OTA 更新页面返回
|
||||
if (options && options.updateResult) {
|
||||
otaState.value = options.updateResult;
|
||||
otaVisible.value = true;
|
||||
} else if (token || user.value.id) {
|
||||
await checkOtaUpdate();
|
||||
}
|
||||
|
||||
if (!user.value.id && !token) {
|
||||
// showModal.value = true;
|
||||
// try {
|
||||
@@ -141,6 +350,10 @@ onMounted(async () => {
|
||||
console.log("全局配置:", config);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
clearOtaUpdateTimers();
|
||||
});
|
||||
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!", // 分享卡片的标题
|
||||
@@ -161,6 +374,21 @@ onShareTimeline(() => {
|
||||
|
||||
<template>
|
||||
<Container :isHome="true" :showBackToGame="true">
|
||||
<!-- OTA 升级弹窗:使用 visible 控制显隐,description 为副标题,changelog 为详细说明 -->
|
||||
<OtaModal
|
||||
:visible="otaVisible"
|
||||
:state="otaState"
|
||||
:version="otaInfo.versionNumber"
|
||||
:progress="otaProgress"
|
||||
:description="''"
|
||||
:changelog="otaInfo.versionInfo"
|
||||
:forceUpdate="otaInfo.forceUpdate"
|
||||
@update="handleOtaUpdate"
|
||||
@skip="handleOtaDismiss"
|
||||
@close="handleOtaDismiss"
|
||||
@done="handleOtaDone"
|
||||
@retry="handleOtaRetry"
|
||||
/>
|
||||
<view class="container">
|
||||
<view class="top-theme">
|
||||
<!-- <image
|
||||
@@ -190,7 +418,7 @@ onShareTimeline(() => {
|
||||
<text v-else-if="online">设备在线</text>
|
||||
</block>
|
||||
<image
|
||||
src="../static/first-try.png"
|
||||
src="https://static.shelingxingqiu.com/shootmini/static/first-try.png"
|
||||
mode="widthFix"
|
||||
@click="() => toPage('/pages/first-try')"
|
||||
/>
|
||||
@@ -201,11 +429,11 @@ onShareTimeline(() => {
|
||||
</view>
|
||||
<view class="play-card">
|
||||
<!-- toPage('/pages/practise') -->
|
||||
<view @click="() => toPage('/pages/training/index')">
|
||||
<image src="../static/my-practise.png" mode="widthFix"/>
|
||||
<view @click="$clickSound(() => toPage('/pages/training/index'))">
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/my-practise.png" mode="widthFix"/>
|
||||
</view>
|
||||
<view @click="$clickSound(() => toPage('/pages/friend-battle'))">
|
||||
<image src="../static/friend-battle.png" mode="widthFix"/>
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/friend-battle.png" mode="widthFix"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -220,7 +448,7 @@ onShareTimeline(() => {
|
||||
hover-class="none"
|
||||
></button>
|
||||
<view class="ranking-players" @click="toRankListPage">
|
||||
<img src="../static/juezhanbang.png" mode="widthFix"/>
|
||||
<img src="https://static.shelingxingqiu.com/shootmini/static/juezhanbang.png" mode="widthFix"/>
|
||||
<view class="divide-line"></view>
|
||||
<view class="player-avatars">
|
||||
<view
|
||||
@@ -254,7 +482,7 @@ onShareTimeline(() => {
|
||||
</view>
|
||||
<view class="my-data">
|
||||
<view @click="() => toPage('/pages/my-growth')">
|
||||
<image src="../static/my-growth.png" mode="widthFix"/>
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/my-growth.png" mode="widthFix"/>
|
||||
</view>
|
||||
<view @click="() => toPage('/pages/ranking')">
|
||||
<view>
|
||||
|
||||
@@ -67,7 +67,7 @@ onLoad(async (options) => {
|
||||
const checkBowData = (selected) => {
|
||||
if (data.value.mode <= 3) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-bow-data?battleId=${battleId.value}&selected=${selected}`,
|
||||
url: `/pages/team-battle/team-bow-data?battleId=${battleId.value}&selected=${selected}`,
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
|
||||
+157
-26
@@ -3,18 +3,28 @@ import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import Matching from "@/components/Matching.vue";
|
||||
import ModalDialog from "@/components/ModalDialog.vue";
|
||||
import audioManager from "@/audioManager";
|
||||
import { matchGameAPI, getBattleAPI } from "@/apis";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import { isLimitError } from "@/util";
|
||||
import { returnToBattle } from "@/utils/matchReturn";
|
||||
|
||||
const gameType = ref(0);
|
||||
const teamSize = ref(0);
|
||||
const onComplete = ref(null);
|
||||
const showLimitModal = ref(false);
|
||||
const navigationPending = ref(false);
|
||||
let pageMounted = false;
|
||||
let pageVisible = false;
|
||||
let foregroundGeneration = 0;
|
||||
|
||||
/** 匹配超时计时器,用于检测 WS 消息丢失或真正超时 */
|
||||
const matchTimeoutTimer = ref(null);
|
||||
|
||||
/** 匹配超时阈值(ms),后端设置 15s 匹配,前端预留 5s 冗余 */
|
||||
const MATCH_TIMEOUT_MS = 20 * 1000;
|
||||
const MATCH_INFO_RETRY_DELAY_MS = 500;
|
||||
|
||||
/** 清除超时计时器 */
|
||||
const clearMatchTimeout = () => {
|
||||
@@ -24,21 +34,110 @@ const clearMatchTimeout = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const wait = (delay) =>
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve, delay);
|
||||
});
|
||||
|
||||
const isCurrentForeground = (generation) =>
|
||||
pageMounted &&
|
||||
pageVisible &&
|
||||
generation === foregroundGeneration &&
|
||||
!navigationPending.value;
|
||||
|
||||
const redirectOnce = (url) =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (navigationPending.value) {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
navigationPending.value = true;
|
||||
clearMatchTimeout();
|
||||
uni.redirectTo({
|
||||
url,
|
||||
success: resolve,
|
||||
fail: (error) => {
|
||||
navigationPending.value = false;
|
||||
reject(error);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
async function queryCurrentBattle(generation) {
|
||||
try {
|
||||
return await getBattleAPI();
|
||||
} catch (error) {
|
||||
await wait(MATCH_INFO_RETRY_DELAY_MS);
|
||||
if (!isCurrentForeground(generation)) throw error;
|
||||
return getBattleAPI();
|
||||
}
|
||||
}
|
||||
|
||||
async function returnToCurrentBattle(battle) {
|
||||
if (!battle?.matchId || navigationPending.value) return false;
|
||||
return returnToBattle(battle, redirectOnce);
|
||||
}
|
||||
|
||||
async function reconcileMatchingPage(generation) {
|
||||
clearMatchTimeout();
|
||||
|
||||
let battle = null;
|
||||
try {
|
||||
battle = await queryCurrentBattle(generation);
|
||||
} catch (error) {
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
console.log("resume match info error", error);
|
||||
uni.showToast({
|
||||
title: "比赛状态查询失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
if (battle?.matchId) {
|
||||
try {
|
||||
await returnToCurrentBattle(battle);
|
||||
} catch (error) {
|
||||
console.log("return to current match error", error);
|
||||
uni.showToast({
|
||||
title: "进入比赛失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gameType.value || !teamSize.value) return;
|
||||
|
||||
try {
|
||||
await matchGameAPI(true, gameType.value, teamSize.value);
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
matchTimeoutTimer.value = setTimeout(handleMatchTimeout, MATCH_TIMEOUT_MS);
|
||||
} catch (error) {
|
||||
if (!isCurrentForeground(generation)) return;
|
||||
clearMatchTimeout();
|
||||
if (isLimitError(error)) {
|
||||
showLimitModal.value = true;
|
||||
return;
|
||||
}
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 超时处理:查询后端是否已分配对局
|
||||
* - 有对局 → WS 消息丢失场景,自动跳入
|
||||
* - 无对局 → 真正超时,提示用户并返回大厅
|
||||
*/
|
||||
const handleMatchTimeout = async () => {
|
||||
if (!pageVisible || navigationPending.value) return;
|
||||
try {
|
||||
const battle = await getBattleAPI();
|
||||
if (battle && battle.matchId) {
|
||||
uni.showToast({ title: "匹配成功,正在进入...", icon: "none" });
|
||||
if (battle.mode <= 3) {
|
||||
uni.redirectTo({ url: `/pages/team-battle/index?battleId=${battle.matchId}` });
|
||||
} else {
|
||||
uni.redirectTo({ url: `/pages/melee-battle?battleId=${battle.matchId}` });
|
||||
}
|
||||
await returnToCurrentBattle(battle);
|
||||
} else {
|
||||
uni.showToast({ title: "匹配超时,请重试", icon: "none" });
|
||||
try {
|
||||
@@ -58,12 +157,26 @@ async function stopMatch() {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
|
||||
const closeLimitModal = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.navigateBack();
|
||||
};
|
||||
|
||||
const goVipPage = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.redirectTo({
|
||||
url: "/pages/member/be-vip",
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 取消匹配,带容错处理:
|
||||
* - 取消成功 → 返回大厅
|
||||
* - 取消失败(后端已分配对局但 WS 未到达)→ 查询并跳入当前对局
|
||||
*/
|
||||
async function cancelMatch() {
|
||||
if (navigationPending.value) return;
|
||||
foregroundGeneration += 1;
|
||||
clearMatchTimeout();
|
||||
try {
|
||||
if (gameType.value && teamSize.value) {
|
||||
@@ -75,11 +188,7 @@ async function cancelMatch() {
|
||||
try {
|
||||
const battle = await getBattleAPI();
|
||||
if (battle && battle.matchId) {
|
||||
if (battle.mode <= 3) {
|
||||
uni.redirectTo({ url: `/pages/team-battle/index?battleId=${battle.matchId}` });
|
||||
} else {
|
||||
uni.redirectTo({ url: `/pages/melee-battle?battleId=${battle.matchId}` });
|
||||
}
|
||||
await returnToCurrentBattle(battle);
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
@@ -94,18 +203,21 @@ async function onReceiveMessage(msg) {
|
||||
onComplete.value = () => {}
|
||||
}
|
||||
if (msg.type === MESSAGETYPESV2.AboutToStart) {
|
||||
if (navigationPending.value) return;
|
||||
// 收到开始消息,清除超时计时器
|
||||
clearMatchTimeout();
|
||||
// 使用后端下发的 mode 字段判断跳转目标,与好友约战(battle-room.vue)保持一致
|
||||
// mode <= 3 为团队对抗,mode > 3 为大乱斗,覆盖全部 gameType(1~5),不再遗漏
|
||||
if (msg.mode <= 3) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/team-battle/index?battleId=${msg.id}`,
|
||||
});
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: `/pages/melee-battle?battleId=${msg.id}`,
|
||||
});
|
||||
const matchId = msg.matchId || msg.id;
|
||||
if (!matchId) return;
|
||||
const url =
|
||||
msg.mode <= 3
|
||||
? `/pages/team-battle/index?battleId=${matchId}`
|
||||
: `/pages/melee-battle?battleId=${matchId}`;
|
||||
try {
|
||||
await redirectOnce(url);
|
||||
} catch (error) {
|
||||
console.log("redirect to matched battle error", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,17 +227,27 @@ onLoad(async (options) => {
|
||||
gameType.value = options.gameType;
|
||||
teamSize.value = options.teamSize;
|
||||
}
|
||||
if (pageMounted && pageVisible) {
|
||||
const generation = ++foregroundGeneration;
|
||||
void reconcileMatchingPage(generation);
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
void audioManager.warmAll();
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("cancelMatching", cancelMatch);
|
||||
pageMounted = true;
|
||||
if (pageVisible) void reconcileMatchingPage(foregroundGeneration);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
pageMounted = false;
|
||||
pageVisible = false;
|
||||
foregroundGeneration += 1;
|
||||
clearMatchTimeout();
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false,
|
||||
@@ -134,17 +256,18 @@ onBeforeUnmount(() => {
|
||||
uni.$off("cancelMatching", cancelMatch);
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
if (gameType.value && teamSize.value) {
|
||||
matchGameAPI(true, gameType.value, teamSize.value);
|
||||
// 启动超时计时器,防止 WS 消息丢失或长时间无对手导致用户卡死
|
||||
clearMatchTimeout();
|
||||
matchTimeoutTimer.value = setTimeout(handleMatchTimeout, MATCH_TIMEOUT_MS);
|
||||
}
|
||||
onShow(() => {
|
||||
pageVisible = true;
|
||||
navigationPending.value = false;
|
||||
const generation = ++foregroundGeneration;
|
||||
clearMatchTimeout();
|
||||
if (pageMounted) void reconcileMatchingPage(generation);
|
||||
});
|
||||
|
||||
onHide(() => {
|
||||
|
||||
pageVisible = false;
|
||||
foregroundGeneration += 1;
|
||||
clearMatchTimeout();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -154,6 +277,14 @@ onHide(() => {
|
||||
<Matching :stopMatch="stopMatch" :onComplete="onComplete" />
|
||||
</view>
|
||||
</Container>
|
||||
<ModalDialog
|
||||
:show="showLimitModal"
|
||||
:content="'今日排位赛次数已经用完\n开通会员可增加次数'"
|
||||
cancelText="知道了"
|
||||
confirmText="去开通"
|
||||
:onCancel="closeLimitModal"
|
||||
:onConfirm="goVipPage"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+272
-86
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount, watch, nextTick } from "vue";
|
||||
import { ref, onMounted, onBeforeUnmount, watch, nextTick, computed } from "vue";
|
||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
@@ -13,7 +13,14 @@ import TestDistance from "@/components/TestDistance.vue";
|
||||
import SModal from "@/components/SModal.vue";
|
||||
import audioManager from "@/audioManager";
|
||||
import { getBattleAPI, laserCloseAPI } from "@/apis";
|
||||
import {
|
||||
closeMatchWebSocket,
|
||||
connectMatchWebSocket,
|
||||
MATCH_WS_AUDIO_ACK_EVENT,
|
||||
MATCH_WS_STATE_EVENT,
|
||||
} from "@/matchWebsocket";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import { takeMatchReturnSnapshot } from "@/utils/matchReturn";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
@@ -30,13 +37,24 @@ const playersSorted = ref([]);
|
||||
const playersScores = ref([]);
|
||||
const halfTimeTip = ref(false);
|
||||
const halfRest = ref(false);
|
||||
const DEFAULT_READY_TIME = 15;
|
||||
const HALF_REST_SECONDS = 20;
|
||||
const MATCH_READY_SNAPSHOT_PREFIX = "match-ready-snapshot:";
|
||||
const MATCH_STATUS_BY_TEXT = {
|
||||
MATCH_STATUS_READY: 0,
|
||||
MATCH_STATUS_STARTED: 1,
|
||||
MATCH_STATUS_END: 2,
|
||||
MATCH_STATUS_TIMEOUT: 3,
|
||||
MATCH_STATUS_UNEXPECTEDLY: 4,
|
||||
};
|
||||
const halfRestRemain = ref(HALF_REST_SECONDS);
|
||||
const readyTime = ref(DEFAULT_READY_TIME);
|
||||
let halfRestTimer = null;
|
||||
/** 控制设备离线提示弹窗的显示状态 */
|
||||
const showOfflineModal = ref(false);
|
||||
/** 记录每位玩家当前半场连续 10 环及以上次数,key 为 playerId,用于触发 tententen 音效 */
|
||||
const xRingStreaks = ref({});
|
||||
let battleEnded = false;
|
||||
let skipNextRestoreOnShow = false;
|
||||
let restoreGeneration = 0;
|
||||
|
||||
function clearHalfRestCountdown() {
|
||||
if (halfRestTimer) {
|
||||
@@ -45,6 +63,12 @@ function clearHalfRestCountdown() {
|
||||
}
|
||||
}
|
||||
|
||||
function leaveHalfRest() {
|
||||
clearHalfRestCountdown();
|
||||
halfTimeTip.value = false;
|
||||
halfRest.value = false;
|
||||
}
|
||||
|
||||
function getHalfRestSeconds(battleInfo) {
|
||||
const remainCandidates = [
|
||||
battleInfo?.halfRestRemain,
|
||||
@@ -60,13 +84,24 @@ function getHalfRestSeconds(battleInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
const endTime = Number(battleInfo?.halfRestEndTime ?? battleInfo?.restEndTime);
|
||||
if (!Number.isFinite(endTime) || endTime <= 0) return HALF_REST_SECONDS;
|
||||
const timeoutTime = normalizeTimestamp(battleInfo?.timeoutTime);
|
||||
if (timeoutTime) {
|
||||
const elapsedSeconds = Math.max(0, (Date.now() - timeoutTime) / 1000);
|
||||
return Math.max(
|
||||
0,
|
||||
Math.min(HALF_REST_SECONDS, Math.ceil(HALF_REST_SECONDS - elapsedSeconds))
|
||||
);
|
||||
}
|
||||
|
||||
const timestamp = endTime < 1e12 ? endTime * 1000 : endTime;
|
||||
const diffSeconds = (timestamp - Date.now()) / 1000;
|
||||
if (diffSeconds > 0 && diffSeconds <= HALF_REST_SECONDS) {
|
||||
return Math.ceil(diffSeconds);
|
||||
const endTime = normalizeTimestamp(
|
||||
battleInfo?.halfRestEndTime ?? battleInfo?.restEndTime
|
||||
);
|
||||
if (endTime) {
|
||||
const diffSeconds = (endTime - Date.now()) / 1000;
|
||||
return Math.max(
|
||||
0,
|
||||
Math.min(HALF_REST_SECONDS, Math.ceil(diffSeconds))
|
||||
);
|
||||
}
|
||||
|
||||
return HALF_REST_SECONDS;
|
||||
@@ -74,7 +109,14 @@ function getHalfRestSeconds(battleInfo) {
|
||||
|
||||
function startHalfRestCountdown(seconds = HALF_REST_SECONDS) {
|
||||
clearHalfRestCountdown();
|
||||
halfRestRemain.value = Math.max(0, Math.ceil(Number(seconds) || HALF_REST_SECONDS));
|
||||
const secondsValue = Number(seconds);
|
||||
const normalizedSeconds = Number.isFinite(secondsValue)
|
||||
? secondsValue
|
||||
: HALF_REST_SECONDS;
|
||||
halfRestRemain.value = Math.max(
|
||||
0,
|
||||
Math.min(HALF_REST_SECONDS, Math.ceil(normalizedSeconds))
|
||||
);
|
||||
|
||||
if (halfRestRemain.value <= 0) return;
|
||||
|
||||
@@ -88,6 +130,116 @@ function startHalfRestCountdown(seconds = HALF_REST_SECONDS) {
|
||||
halfRestRemain.value -= 1;
|
||||
}, 1000);
|
||||
}
|
||||
const currentPlayer = computed(() =>
|
||||
players.value.find((player) => String(player?.id) === String(user.value.id))
|
||||
);
|
||||
const isCurrentUserSvip = computed(() => currentPlayer.value?.sVip === true);
|
||||
|
||||
function getReadySnapshotKey(matchId) {
|
||||
return `${MATCH_READY_SNAPSHOT_PREFIX}${String(matchId || "")}`;
|
||||
}
|
||||
|
||||
function normalizeBattleInfo(battleInfo) {
|
||||
if (!battleInfo || typeof battleInfo !== "object") return battleInfo;
|
||||
|
||||
const statusText = battleInfo.statusText || battleInfo.status_text;
|
||||
if (
|
||||
(battleInfo.status === undefined ||
|
||||
battleInfo.status === null ||
|
||||
battleInfo.status === "") &&
|
||||
MATCH_STATUS_BY_TEXT[statusText] !== undefined
|
||||
) {
|
||||
return {
|
||||
...battleInfo,
|
||||
status: MATCH_STATUS_BY_TEXT[statusText],
|
||||
};
|
||||
}
|
||||
|
||||
return battleInfo;
|
||||
}
|
||||
|
||||
function normalizeTimestamp(value) {
|
||||
const numberValue = Number(value || 0);
|
||||
if (!numberValue) return 0;
|
||||
return numberValue < 1000000000000 ? numberValue * 1000 : numberValue;
|
||||
}
|
||||
|
||||
function getReadyTime(battleInfo) {
|
||||
const value = Number(battleInfo?.readyTime);
|
||||
return Number.isFinite(value) && value > 0 ? value : DEFAULT_READY_TIME;
|
||||
}
|
||||
|
||||
function getReadyRemainingSeconds(battleInfo) {
|
||||
const total = getReadyTime(battleInfo);
|
||||
const countdownStartTime = normalizeTimestamp(battleInfo?.countdownStartTime);
|
||||
if (!countdownStartTime) return total;
|
||||
|
||||
const elapsed = Math.max(0, (Date.now() - countdownStartTime) / 1000);
|
||||
console.log('11111111111111111111111111111', total, countdownStartTime, Math.max(0, (Date.now() - countdownStartTime) / 1000))
|
||||
return Math.max(0, total - elapsed);
|
||||
}
|
||||
|
||||
function hasKnownStatus(battleInfo) {
|
||||
return !(
|
||||
battleInfo?.status === undefined ||
|
||||
battleInfo?.status === null ||
|
||||
battleInfo?.status === ""
|
||||
);
|
||||
}
|
||||
|
||||
function hasStartedSnapshot(battleInfo) {
|
||||
if (hasKnownStatus(battleInfo)) return Number(battleInfo.status) !== 0;
|
||||
|
||||
const current = battleInfo?.current || {};
|
||||
return !!(
|
||||
current.playerId ||
|
||||
current.startTime ||
|
||||
current.round ||
|
||||
(Array.isArray(battleInfo?.rounds) && battleInfo.rounds.length)
|
||||
);
|
||||
}
|
||||
|
||||
function takeReadySnapshot(matchId) {
|
||||
const key = getReadySnapshotKey(matchId);
|
||||
const snapshot = uni.getStorageSync(key);
|
||||
if (snapshot) uni.removeStorageSync(key);
|
||||
return normalizeBattleInfo(snapshot);
|
||||
}
|
||||
|
||||
function reconnectMatchServer(battleInfo) {
|
||||
const status = Number(battleInfo?.status);
|
||||
if ([2, 4].includes(status)) return;
|
||||
if (!battleInfo?.serverAddr) return;
|
||||
|
||||
connectMatchWebSocket({
|
||||
serverAddr: battleInfo.serverAddr,
|
||||
matchId: battleInfo.matchId || battleId.value,
|
||||
userId: user.value.id,
|
||||
mode: battleInfo.mode,
|
||||
});
|
||||
}
|
||||
|
||||
function closeBattleServer(reason) {
|
||||
if (battleEnded) return;
|
||||
closeMatchWebSocket({ reason });
|
||||
}
|
||||
|
||||
function notifyMatchAudioAck(message) {
|
||||
if (
|
||||
message?.sequence === undefined ||
|
||||
message?.sequence === null ||
|
||||
message?.sequence === ""
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.$emit(MATCH_WS_AUDIO_ACK_EVENT, {
|
||||
matchId: message.matchId || battleId.value,
|
||||
sequence: message.sequence,
|
||||
matchWsType: message.matchWsType,
|
||||
matchWsTypeName: message.matchWsTypeName,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听设备在线状态,大乱斗比赛进行中设备离线时弹窗提示用户
|
||||
@@ -99,7 +251,11 @@ watch(online, (newVal, oldVal) => {
|
||||
});
|
||||
|
||||
function recoverData(battleInfo, { force = false } = {}) {
|
||||
battleInfo = normalizeBattleInfo(battleInfo);
|
||||
if (!battleInfo) return;
|
||||
if (battleInfo.status !== undefined) {
|
||||
battleEnded = [2, 4].includes(Number(battleInfo.status));
|
||||
}
|
||||
try {
|
||||
if (battleInfo.way === 1) title.value = "好友约战 - 大乱斗";
|
||||
if (battleInfo.way === 2) title.value = "排位赛 - 大乱斗";
|
||||
@@ -117,19 +273,27 @@ function recoverData(battleInfo, { force = false } = {}) {
|
||||
players.value = [];
|
||||
}
|
||||
|
||||
start.value = battleInfo.status !== 0;
|
||||
if (hasKnownStatus(battleInfo)) {
|
||||
start.value = battleInfo.status !== 0;
|
||||
} else if (!hasStartedSnapshot(battleInfo)) {
|
||||
if (start.value !== true) start.value = false;
|
||||
return;
|
||||
} else {
|
||||
start.value = true;
|
||||
}
|
||||
|
||||
if (battleInfo.status === 0) {
|
||||
const readyRemain = (Date.now() - (battleInfo.createTime || Date.now())) / 1000;
|
||||
if (readyRemain > 0 && readyRemain < 15) {
|
||||
setTimeout(() => uni.$emit("update-timer", 15 - readyRemain - 0.2), 200);
|
||||
}
|
||||
readyTime.value = getReadyTime(battleInfo);
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-timer", getReadyRemainingSeconds(battleInfo));
|
||||
}, 200);
|
||||
return;
|
||||
}
|
||||
|
||||
const rounds = Array.isArray(battleInfo.rounds) ? battleInfo.rounds : [];
|
||||
tips.value =
|
||||
(battleInfo.rounds.length !== 2 ? "上" : "下") + "半场:请先射6箭";
|
||||
playersScores.value = battleInfo.rounds.map((r) => ({ ...r.shoots }));
|
||||
(rounds.length !== 2 ? "上" : "下") + "半场:请先射6箭";
|
||||
playersScores.value = rounds.map((r) => ({ ...r.shoots }));
|
||||
const totals = {};
|
||||
players.value.forEach((p) => {
|
||||
const total = playersScores.value.reduce((acc, round) => {
|
||||
@@ -151,8 +315,10 @@ function recoverData(battleInfo, { force = false } = {}) {
|
||||
}, 200);
|
||||
return;
|
||||
}
|
||||
leaveHalfRest();
|
||||
if (force) {
|
||||
const remain = (Date.now() - (battleInfo.current?.startTime || Date.now())) / 1000;
|
||||
const ackTime = normalizeTimestamp(battleInfo.current?.ackTime);
|
||||
const remain = ackTime ? Math.max(0, (Date.now() - ackTime) / 1000) : 0;
|
||||
console.log(`当前轮已进行${remain}秒`);
|
||||
if (remain > 0 && remain < 90) {
|
||||
setTimeout(() => {
|
||||
@@ -165,8 +331,64 @@ function recoverData(battleInfo, { force = false } = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreLatestBattle() {
|
||||
if (!battleId.value) return;
|
||||
|
||||
const currentRestoreId = ++restoreGeneration;
|
||||
let result = null;
|
||||
try {
|
||||
result = normalizeBattleInfo(await getBattleAPI(battleId.value));
|
||||
} catch (err) {
|
||||
console.log("restore latest melee battle failed:", err);
|
||||
return;
|
||||
}
|
||||
if (currentRestoreId !== restoreGeneration || !result) return;
|
||||
|
||||
if (result.status === 2) {
|
||||
battleEnded = true;
|
||||
uni.showToast({
|
||||
title: "比赛已结束",
|
||||
icon: "none",
|
||||
});
|
||||
uni.navigateBack({
|
||||
delta: 2,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
reconnectMatchServer(result);
|
||||
recoverData(result, { force: true });
|
||||
}
|
||||
|
||||
function onMatchSocketState(event) {
|
||||
if (event?.state !== "open" || event?.reconnected !== true) return;
|
||||
if (
|
||||
event.matchId &&
|
||||
battleId.value &&
|
||||
String(event.matchId) !== String(battleId.value)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
restoreLatestBattle();
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.battleId) battleId.value = options.battleId;
|
||||
const returnSnapshot = options.fromReturn ? takeMatchReturnSnapshot() : null;
|
||||
skipNextRestoreOnShow = false;
|
||||
if (returnSnapshot?.matchId) battleId.value = returnSnapshot.matchId;
|
||||
else if (options.battleId) battleId.value = options.battleId;
|
||||
if (returnSnapshot) {
|
||||
skipNextRestoreOnShow = true;
|
||||
reconnectMatchServer(returnSnapshot);
|
||||
recoverData(returnSnapshot, { force: true });
|
||||
return;
|
||||
}
|
||||
const readySnapshot = takeReadySnapshot(battleId.value);
|
||||
if (readySnapshot?.status === 0) {
|
||||
skipNextRestoreOnShow = true;
|
||||
reconnectMatchServer(readySnapshot);
|
||||
recoverData(readySnapshot);
|
||||
}
|
||||
// uni.enableAlertBeforeUnload({
|
||||
// message: "离开比赛可能导致比赛失败,是否继续?",
|
||||
// success: (res) => {
|
||||
@@ -175,68 +397,26 @@ onLoad(async (options) => {
|
||||
// });
|
||||
});
|
||||
|
||||
/**
|
||||
* 检测指定玩家连续 10 环及以上是否达到 3 箭,达到则在环数播报入队后追加 tententen 音效
|
||||
* @param {number|string} playerId - 本次射手的 ID(大乱斗中 ShootResult 保留 playerId)
|
||||
* @param {boolean} isTenPlusRingShot - 本次射击是否为 10 环及以上
|
||||
*/
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function checkAndPlayTententen(playerId, isTenPlusRingShot) {
|
||||
if (!playerId) return;
|
||||
const id = parseInt(playerId);
|
||||
if (isTenPlusRingShot) {
|
||||
xRingStreaks.value[id] = (xRingStreaks.value[id] || 0) + 1;
|
||||
// 同一玩家连续 3 箭均为 10 环及以上,追加到环数音效队列尾部播放
|
||||
if (xRingStreaks.value[id] >= 3) {
|
||||
xRingStreaks.value[id] = 0;
|
||||
// nextTick 确保 HeaderProgress 的环数播报已入队后再追加 tententen,避免播放顺序颠倒
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
} else {
|
||||
// 低于 10 环或未上靶则重置该玩家的连续计数
|
||||
xRingStreaks.value[id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function onReceiveMessage(msg) {
|
||||
if (Array.isArray(msg)) return;
|
||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||
clearHalfRestCountdown();
|
||||
halfTimeTip.value = false;
|
||||
halfRest.value = false;
|
||||
if (msg.type === MESSAGETYPESV2.AboutToStart) {
|
||||
recoverData(msg);
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||
leaveHalfRest();
|
||||
recoverData(msg);
|
||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
// 更新前快照各玩家本轮已射箭数,用于事后识别本次射手
|
||||
const curRound = playersScores.value[playersScores.value.length - 1] || {};
|
||||
const prevCounts = {};
|
||||
for (const pid of Object.keys(curRound)) {
|
||||
prevCounts[pid] = (curRound[pid] || []).length;
|
||||
}
|
||||
recoverData(msg);
|
||||
// 对比更新后数据找出箭数增加的玩家(即本次射手),并读取其最新箭的 ring 数据
|
||||
const newRound = playersScores.value[playersScores.value.length - 1] || {};
|
||||
let shooterId = null;
|
||||
let isTenPlusRingShot = false;
|
||||
for (const pid of Object.keys(newRound)) {
|
||||
const newLen = (newRound[pid] || []).length;
|
||||
if (newLen > (prevCounts[pid] || 0)) {
|
||||
shooterId = parseInt(pid);
|
||||
const shot = newRound[pid][newLen - 1];
|
||||
isTenPlusRingShot = isTenPlusRing(shot);
|
||||
break;
|
||||
}
|
||||
if (msg.shootData?.threeConsecutive10Rings === true) {
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
// 检测同一玩家连续三箭 10 环及以上,触发 tententen 音效
|
||||
checkAndPlayTententen(shooterId, isTenPlusRingShot);
|
||||
} else if (msg.type === MESSAGETYPESV2.HalfRest) {
|
||||
halfTimeTip.value = true;
|
||||
halfRest.value = true;
|
||||
tips.value = "准备下半场";
|
||||
startHalfRestCountdown();
|
||||
startHalfRestCountdown(getHalfRestSeconds(msg));
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||
battleEnded = true;
|
||||
notifyMatchAudioAck(msg);
|
||||
setTimeout(() => {
|
||||
// 全部跳转到新结算页
|
||||
uni.redirectTo({
|
||||
@@ -250,33 +430,31 @@ onMounted(async () => {
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on(MATCH_WS_STATE_EVENT, onMatchSocketState);
|
||||
await laserCloseAPI();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false,
|
||||
});
|
||||
restoreGeneration += 1;
|
||||
clearHalfRestCountdown();
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off(MATCH_WS_STATE_EVENT, onMatchSocketState);
|
||||
closeBattleServer("melee-battle-unmount");
|
||||
audioManager.stopAll();
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
if (battleId.value) {
|
||||
const result = await getBattleAPI(battleId.value);
|
||||
if (!result) return;
|
||||
if (result.status === 2) {
|
||||
uni.showToast({
|
||||
title: "比赛已结束",
|
||||
icon: "none",
|
||||
});
|
||||
uni.navigateBack({
|
||||
delta: 2,
|
||||
});
|
||||
} else {
|
||||
recoverData(result, { force: true });
|
||||
}
|
||||
onHide(() => {
|
||||
closeBattleServer("melee-battle-hide");
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
if (skipNextRestoreOnShow) {
|
||||
skipNextRestoreOnShow = false;
|
||||
return;
|
||||
}
|
||||
restoreLatestBattle();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -284,13 +462,19 @@ onShow(async () => {
|
||||
<Container :title="title" :bgType="1">
|
||||
<view class="container">
|
||||
<BattleHeader v-if="!start" :players="players" />
|
||||
<TestDistance v-if="start === false" :guide="false" :isBattle="true" />
|
||||
<TestDistance
|
||||
v-if="start === false"
|
||||
:guide="false"
|
||||
:isBattle="true"
|
||||
:count="readyTime"
|
||||
/>
|
||||
<ShootProgress
|
||||
:show="start"
|
||||
:start="start && !halfRest"
|
||||
:tips="tips"
|
||||
:total="90"
|
||||
:melee="true"
|
||||
:halfRest="halfRest"
|
||||
:battleId="battleId"
|
||||
/>
|
||||
<view v-if="start" class="user-row">
|
||||
@@ -304,6 +488,8 @@ onShow(async () => {
|
||||
"
|
||||
:totalRound="12"
|
||||
:scores="playersScores.map((r) => r[user.id]).flat()"
|
||||
:isSvip="isCurrentUserSvip"
|
||||
:missAsZero="true"
|
||||
:stop="halfRest"
|
||||
/>
|
||||
<view :style="{ paddingBottom: '20px' }">
|
||||
|
||||
@@ -13,13 +13,31 @@ const currentUser = ref({
|
||||
});
|
||||
const players = ref([]);
|
||||
|
||||
function getRingTotal(arrows = []) {
|
||||
return arrows.reduce((last, next) => last + (Number(next?.ring) || 0), 0);
|
||||
}
|
||||
|
||||
function getScoreLabel(score) {
|
||||
if (!score) return "";
|
||||
return score.ringX ? "X" : score.ring || "";
|
||||
}
|
||||
|
||||
const isMember = (player = {}) => player.vip === true || player.sVip === true;
|
||||
|
||||
const getMemberNicknameClass = (player = {}) => [
|
||||
"player-name",
|
||||
"member-nickname",
|
||||
player.vip === true && player.sVip !== true ? "member-nickname--vip" : "",
|
||||
player.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (!options.battleId) return;
|
||||
const result = await getBattleAPI(options.battleId || "59348111700660224");
|
||||
const plist = result.teams?.[0]?.players || [];
|
||||
players.value = result.resultList.map((item, index) => {
|
||||
const plist = result.teams[0] ? result.teams[0].players : [];
|
||||
const p = plist.find((p) => p.id === item.userId);
|
||||
const arrows = new Array(12);
|
||||
const p = plist.find((p) => String(p.id) === String(item.userId));
|
||||
const arrows = Array.from({ length: 12 }, () => ({}));
|
||||
result.rounds.forEach((r, index) => {
|
||||
if (r.shoots[item.userId]) {
|
||||
r.shoots[item.userId].forEach((s, index2) => {
|
||||
@@ -29,9 +47,11 @@ onLoad(async (options) => {
|
||||
});
|
||||
return {
|
||||
...item,
|
||||
...p,
|
||||
userId: item.userId,
|
||||
rank: index + 1,
|
||||
name: p.name,
|
||||
avatar: p.avatar || "",
|
||||
name: p?.name || item.name,
|
||||
avatar: p?.avatar || item.avatar || "",
|
||||
arrows,
|
||||
};
|
||||
});
|
||||
@@ -45,7 +65,7 @@ onLoad(async (options) => {
|
||||
<Container title="靶纸">
|
||||
<view class="container">
|
||||
<image
|
||||
src="../static/battle-header-melee.png"
|
||||
src="https://static.shelingxingqiu.com/shootmini/static/battle-header-melee.png"
|
||||
mode="widthFix"
|
||||
:style="{ top: '-50rpx' }"
|
||||
/>
|
||||
@@ -68,18 +88,27 @@ onLoad(async (options) => {
|
||||
class="player-bg"
|
||||
/>
|
||||
<Avatar :src="player.avatar" :rankLvl="player.rankLvl" :size="40" />
|
||||
<text>{{ player.name }}</text>
|
||||
<view v-if="isMember(player)" :class="getMemberNicknameClass(player)">
|
||||
<text class="member-nickname__text">{{ player.name }}</text>
|
||||
<text v-if="player.sVip === true" class="member-nickname__shine">
|
||||
{{ player.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else>{{ player.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{ marginTop: '10px' }">
|
||||
<BowTarget :scores="currentUser.arrows" />
|
||||
<BowTarget
|
||||
:scores="currentUser.arrows"
|
||||
:isSvip="currentUser.sVip === true"
|
||||
/>
|
||||
</view>
|
||||
<view class="score-text"
|
||||
><text :style="{ color: '#fed847' }">{{
|
||||
currentUser.arrows.length
|
||||
}}</text
|
||||
>支箭,共<text :style="{ color: '#fed847' }">{{
|
||||
currentUser.arrows.reduce((last, next) => last + next.ring, 0)
|
||||
getRingTotal(currentUser.arrows)
|
||||
}}</text
|
||||
>环</view
|
||||
>
|
||||
@@ -90,7 +119,7 @@ onLoad(async (options) => {
|
||||
class="score-item"
|
||||
:style="{ width: '13vw', height: '13vw' }"
|
||||
>
|
||||
{{ score.ringX ? "X" : score.ring }}
|
||||
{{ getScoreLabel(score) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -149,6 +178,16 @@ onLoad(async (options) => {
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
.players > view > .player-name {
|
||||
margin: 5px 0;
|
||||
width: 80%;
|
||||
position: relative;
|
||||
justify-content: center;
|
||||
}
|
||||
.player-name .member-nickname__text,
|
||||
.player-name .member-nickname__shine {
|
||||
font-size: 12px;
|
||||
}
|
||||
.score-text {
|
||||
width: 100%;
|
||||
color: #fff;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import { getMemberAgreement } from "./agreementData";
|
||||
|
||||
const agreementType = ref("renew");
|
||||
|
||||
onLoad((options) => {
|
||||
agreementType.value = options.type || "renew";
|
||||
});
|
||||
|
||||
const agreement = computed(() => getMemberAgreement(agreementType.value));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container :title="agreement.navTitle">
|
||||
<scroll-view scroll-y class="agreement-page" :show-scrollbar="false">
|
||||
<view class="content">
|
||||
<view class="page-title">{{ agreement.title }}</view>
|
||||
<view v-if="agreement.meta" class="meta">{{ agreement.meta }}</view>
|
||||
|
||||
<block v-for="(item, index) in agreement.content" :key="index">
|
||||
<view v-if="item.type === 'heading'" class="section-title">
|
||||
{{ item.text }}
|
||||
</view>
|
||||
<view v-else-if="item.type === 'list'" class="list">
|
||||
<view v-for="(listItem, listIndex) in item.items" :key="listIndex" class="list-item">
|
||||
<text class="list-dot">•</text>
|
||||
<text class="list-text">{{ listItem }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="paragraph">
|
||||
<text>{{ item.text }}</text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view class="company">{{ agreement.company }}</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.agreement-page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.page-title,
|
||||
.section-title {
|
||||
color: #333333;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.meta {
|
||||
margin-bottom: 26rpx;
|
||||
color: #666666;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 42rpx 0 22rpx;
|
||||
}
|
||||
|
||||
.paragraph,
|
||||
.list-item,
|
||||
.company {
|
||||
color: #333333;
|
||||
font-size: 26rpx;
|
||||
line-height: 38rpx;
|
||||
}
|
||||
|
||||
.paragraph {
|
||||
margin-bottom: 22rpx;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-bottom: 22rpx;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
|
||||
.list-dot {
|
||||
width: 28rpx;
|
||||
flex-shrink: 0;
|
||||
color: #333333;
|
||||
line-height: 38rpx;
|
||||
}
|
||||
|
||||
.list-text {
|
||||
flex: 1;
|
||||
color: #333333;
|
||||
line-height: 38rpx;
|
||||
}
|
||||
|
||||
.company {
|
||||
margin-top: 42rpx;
|
||||
padding-bottom: 30rpx;
|
||||
text-align: right;
|
||||
font-weight: 700;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,322 @@
|
||||
export const memberAgreements = {
|
||||
renew: {
|
||||
navTitle: "会员自动续费服务协议",
|
||||
title: "射灵星球小程序会员自动续费服务协议",
|
||||
content: [
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "欢迎您使用射灵星球小程序付费会员服务(以下简称“本服务”)!",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "本服务是由广州光点飞舞网络有限公司(以下简称“公司”或“我们”)为您提供。本服务为付费服务。为了保障您的权益,请在使用本服务前详细阅读并遵守本《射灵星球小程序会员服务协议(含自动续费服务规则)》(以下简称“本协议”)以及公司已发布或将来可能发布的各项服务协议与规则。您在申请开通本服务并进入购买程序前,请务必审慎阅读、充分理解各服务协议及规则,特别是免除或限制责任条款、法律适用和争议解决条款。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "当您依照本服务开通页面提示进行阅读并同意本协议,完成全部服务开通程序后(包括但不限于点击“同意”、“下一步”或“确认支付”等确认按钮,或您开始使用本服务),即表示您已充分阅读、理解并接受本协议的全部内容,您已与本服务提供方达成一致,成为“射灵星球小程序”付费会员。本协议即在您与公司之间产生法律效力,成为对双方均具有约束力的法律文件。",
|
||||
},
|
||||
{ type: "heading", text: "一、定义及适用范围" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1.1 射灵星球小程序付费会员:指已按照服务协议及规则完成射灵星球小程序登录的用户,在签署本协议并根据本服务开通页面所展示的收费标准支付相应费用后获取的特殊资格,在本协议中简称为“会员”或“您”。公司根据业务发展可能会新增、调整会员类型或名称,实际以开通页面展示为准,这不影响您的实际权益。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1.2 付费会员权益:指用户基于其付费会员资格所享有的特殊权益,具体权益内容应以本服务购买页面展示内容及相关权益说明为准。您理解并同意,公司可能会根据设备型号、系统版本、客户端等因素开发不同的版本,不同版本实际可使用的具体权益或服务内容可能有所差别,具体以购买页面展示为准。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1.3 本协议内容同时包括公司已经发布及后续可能不断发布的关于本服务的相关协议、规则等内容。前述内容一经正式发布,并以适当的方式送达您(服务购买页面、网站公布、系统通知等),即为本协议不可分割的组成部分,您应同样遵守。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1.4 为了给会员用户提供更多选择,公司可能会与第三方合作推出联合会员服务,或为购买会员服务的用户赠送第三方会员服务。如果您选择购买或接受以上服务,则表示您理解并认可,我们仅提供射灵星球小程序付费会员服务,不对第三方的会员服务负责。第三方会员服务的权益、使用、收费规则等,将由第三方执行和向您解释。",
|
||||
},
|
||||
{ type: "heading", text: "二、服务开通、权益内容、服务期限及收费标准" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2.1 本服务仅支持射灵星球小程序登录用户开通。您在开通本服务时,应仔细核对已登录的账号名称、会员类型、付费类型、服务期限等具体信息。因您个人原因充错账号、开通错服务类型或服务时长的,公司不予退还已收取的费用。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2.2 您可通过已有和未来新增的支付渠道或公司指定支付方式完成本服务的购买。当您根据本服务页面提示进行确认、并成功支付了会员服务费和/或完成了成为付费会员的所有程序,您将成为射灵星球小程序付费会员。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2.3 本服务的期限(以下简称“服务期限”)以您选择并成功开通的期限为准。会员计费与服务时长采用自然时间(自然月/自然年)方式计算。具体截止时间为相应续费到期自然日的对应时间点。服务期限届满后,公司将停止继续向您提供本服务。如您同时开通了多种会员服务,其消耗及重叠规则以开通页面的官方具体规则为准。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2.4 本服务的收费标准及具体权益内容以本服务开通页面所展示的为准。基于市场与业务的发展及服务权益调整,公司可能会随时调整本服务开通所需费用及/或具体权益内容。费用或权益内容调整自公布之日起生效,您在调整生效前已开通的服务将不受影响,但该服务到期后的续费开通或自动续费扣款,则需按照调整后的标准执行。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2.5 射灵星球小程序付费会员服务为虚拟内容消费,除因本服务存在重大瑕疵导致您完全无法使用等公司的违约情形、法律法规要求必须退款或公司同意退款等情形外,完成支付和购买后,不可进行退款或转让。您在会员到期前主动取消或终止会员资格的,已支付费用不予退还。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2.6 为了保护您的账号安全、防止账号被盗风险,我们会对您开通会员服务的账号登录设备及使用范围作出合理限制。您不得将账号提供给多名第三方同时使用,否则公司有权根据安全风控能力随时调整或限制您的登录及使用权限。",
|
||||
},
|
||||
{ type: "heading", text: "三、连续购买和自动续费服务" },
|
||||
{ type: "paragraph", text: "3.1 自动续费服务类型/计费周期" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "射灵星球小程序付费会员自动续费服务包含「连续包月」、「连续包年」等服务。本服务的自动续费及对应计费周期采用按自然时间(自然月/自然年)对日顺延的方式计算。即:若您在某月18日开通连续包月服务,则下一次自动扣费续费日期为次月18日;若开通当月无对应日期的(例如1月31日开通,2月无31日),则自动调整为该自然月最后一日进行扣费续费。公司可能会根据会员需求增加或调整自动续费服务类型,具体服务类型以服务开通页面展示为准。",
|
||||
},
|
||||
{ type: "paragraph", text: "3.2 自动续费服务说明" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(1)本自动续费服务基于您对于自动续费的需求,在您已开通会员服务的前提下,为避免您因疏忽或其他原因导致未能及时续费而中断服务,您授权公司可在您的会员服务期限到期前,从您开通本自动续费服务时所绑定的Apple ID账户余额、或绑定的第三方支付账户(包括但不限于微信支付、支付宝支付等)余额中自动代扣下一个计费周期的费用,从而延长对应的会员服务期限。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(2)自动续费扣费日期以您开通本自动续费服务的支付渠道实际扣款时间为准:如您是通过苹果公司iOS渠道开通本服务,扣费日期通常为开通服务之日起每个计费周期的对应日期前24小时内;如您是通过安卓Android渠道或直接在小程序内通过微信支付等渠道开通本服务,扣费日期通常为每个计费周期到期前1至2日。如支付渠道根据实际情况或相关平台规则自行调整扣费时间的,以实际扣款时间为准。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(3)请您关注上述账户及可扣款余额情况,保证上述账户扣款成功以确保会员服务顺利续期。如因上述账户中可扣款余额不足导致续费失败,公司有权中断或终止相应的会员权益及服务,由此导致的风险或损失将由您自行承担。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(4)为了方便您知悉自动续费情况,公司将在扣费日期前5日以站内信、小程序系统消息推送或短信等方式提示您即将发生续期扣费的信息,第三方支付渠道也可能向您发送通知提醒即将扣费。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(5)系统会在每个扣费日期自动从您开通服务时所绑定的支付账户扣费。如扣费日期因账户问题或余额不足导致续费失败,若您未主动明确取消本服务,将视为您同意公司在扣费日期后继续发出扣款尝试,一旦您的账户扣款成功,公司将继续为您提供相应会员服务权益。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(6)如您未在每个扣费日期前操作取消自动续费服务,则公司将根据此前与您达成的委托在扣费日期继续发出续费代扣指令,一旦扣款成功,公司将自动为您开通下一个计费周期的连续服务。对于已成功完成会员服务续费的费用,原则上不予退还。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(7)您在自动续费服务期间可以额外购买或通过参与活动等方式获取付费会员服务,会员服务期限将在原服务期限基础上相应延长,但如您未主动取消自动续费服务,系统仍会按照您所开通的自动续费服务进行扣费及续期。",
|
||||
},
|
||||
{ type: "paragraph", text: "3.3 自动续费服务的退订" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(1)您有权决定是否取消自动续费服务,如果您希望取消自动续费服务,需在每个扣费日期前(至少提前24小时)操作取消,否则将视为您同意继续授权自动续费。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "(2)购买自动续费服务后,您可在小程序的会员管理页中关闭自动续费,或通过如下第三方支付渠道方式取消自动续费服务:",
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
items: [
|
||||
"iOS用户(Apple ID订阅):打开苹果手机“设置” -> 点击顶部的“Apple ID/机主姓名” -> 进入“订阅” -> 选择“射灵星球” -> 点击“取消订阅”;或打开“App Store” -> 点击右上角头像进入“账户” -> 点击“订阅”进行管理。",
|
||||
"微信支付自动续费用户:打开微信APP -> 点击“我” -> “服务” -> “钱包” -> “支付设置” -> “自动续费” -> 选择“射灵星球小程序会员” -> 点击“关闭服务”。",
|
||||
"支付宝自动续费用户:打开支付宝APP -> 点击“我的” -> “设置” -> “支付设置” -> “免密支付/自动扣款” -> 选择“射灵星球小程序会员” -> 点击“关闭服务”。",
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "3.4 公司有权根据市场情况、业务规划、运营策略变化等原因单方面决定停止向您提供自动续费服务,并通过公告或站内信等方式通知您,您的付费会员服务期限自当前服务期限届满之日起终止。",
|
||||
},
|
||||
{ type: "heading", text: "四、服务使用规范与限制" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "4.1 本服务及会员权益仅限您本人使用。未经公司书面同意,禁止以任何形式赠与、借用、出租、转让、售卖或以其他方式许可他人使用该账号及账号项下的会员服务与权益。如发生泄漏、遗失、被盗等行为,而该等行为并非公司过错导致,损失将由您自行承担。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "4.2 如您存在如下违法或不当使用本服务的情形,公司有权取消您的会员资格、作废会员权益且不予退还您所支付的会员服务费用,并有权向您追偿给公司造成的损失:",
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
items: [
|
||||
"以盗窃、利用系统漏洞、通过任何非公司官方或授权渠道获得本服务的行为;",
|
||||
"利用本服务进行盈利或非法获利,或以各种形式转让、借用您的会员权益;",
|
||||
"通过非法手段对本服务会员账户的服务期限、交易状态进行修改或篡改;",
|
||||
"主动对公司用于保护本服务会员权益的任何安全措施技术进行破解、更改、反操作或破坏;",
|
||||
"其他违反法律法规、诚实信用原则、服务协议及相关小程序运营规则的行为。",
|
||||
],
|
||||
},
|
||||
{ type: "heading", text: "五、服务中止、终止及变更" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "5.1 因国家或相关政府监管部门要求、发生不可抗力事件、或由于用户违反本协议约定,公司有权中止或终止向用户提供服务。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "5.2 您知悉并确认,您开通本服务后,如您中途主动取消本服务、放弃会员权益或终止资格,您将无法退还部分或全部会员服务费用。本协议终止后,用户无权要求公司继续向其提供任何服务,且不影响终止前基于本协议已产生的权利义务。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "5.3 公司可根据国家法律法规变化、业务实际变更需求、保护用户权益的需要等,不时修改本协议,并按照法律法规规定的程序及方式进行公告。如用户不同意变更后的内容,则用户有权主动停止使用本服务;如用户在变更内容生效后仍继续使用本服务,即视为用户同意该等内容的变更。",
|
||||
},
|
||||
{ type: "heading", text: "六、责任限制与免责条款" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "6.1 您理解并同意,本服务是按照现有技术和条件所能达到的现状提供的。公司将尽最大努力确保服务的连贯性和安全性,但不能随时预见和防范技术以及其他风险,包括但不限于不可抗力、网络原因、第三方服务瑕疵等原因可能导致的服务中断、数据丢失以及其他的损失和风险。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "6.2 基于收益与赔偿相一致及公平合理的原则,如因公司原因造成本服务不正常中断或服务不可用,您所可能获得的最高赔偿额不超过本协议项下公司就该计费周期已实际收取您的相关服务费用总额。",
|
||||
},
|
||||
{ type: "heading", text: "七、法律适用与争议解决" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "7.1 本协议的成立、生效、履行、解释及争议的解决均应适用中华人民共和国法律。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "7.2 本协议的签订地为广东省广州市南沙区。若您因本协议与公司发生任何争议,双方应尽量友好协商解决;如协商不成的,任何一方均同意应将相关争议提交至本协议签订地有管辖权的人民法院诉讼解决。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "7.3 本协议任一条款被视为废止、无效或不可执行,该条应视为可分的且并不影响本协议其余条款的有效性及可执行性。",
|
||||
},
|
||||
],
|
||||
company: "广州光点飞舞网络有限公司",
|
||||
},
|
||||
deduct: {
|
||||
navTitle: "扣款授权服务协议",
|
||||
title: "扣费授权服务协议",
|
||||
meta: "版本号:V1.0 生效日期:2026年6月22日",
|
||||
content: [
|
||||
{ type: "heading", text: "一、授权声明" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "本人(即授权人,以下简称“乙方”)作为射灵星球小程序的注册用户,在自愿、平等、知悉全部授权内容的基础上,同意向广州光点飞舞网络有限公司(以下简称“甲方”)及甲方委托的第三方支付机构(包含微信支付、支付宝、苹果支付等,以下简称“支付机构”)作出本扣费授权,双方就授权扣费相关事宜达成如下协议。",
|
||||
},
|
||||
{ type: "heading", text: "二、授权主体" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "授权人(乙方):射灵星球小程序注册用户,用户ID以平台系统记录为准。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "被授权人(甲方):广州光点飞舞网络有限公司,作为会员服务提供方及扣费指令发起方。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "支付执行方:乙方绑定的第三方支付机构,受甲方委托执行扣费操作。",
|
||||
},
|
||||
{ type: "heading", text: "三、授权内容" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "授权场景:乙方开通射灵星球会员自动续费服务后,授权甲方在每个会员周期届满前,向支付机构发起扣费指令,用于支付下一周期的会员服务费用。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "授权金额:扣费金额以乙方开通时选择的自动续费套餐对应价格为准,具体以会员购买页面公示价格为准;若价格调整,甲方将提前通过公示或通知形式告知乙方,乙方继续使用服务视为认可并接受调整后的金额。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "授权支付账户:乙方开通自动续费时绑定的微信支付、支付宝等第三方支付账户,账户信息以支付机构记录为准。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "授权扣费次数:本授权为周期性授权。在授权有效期内,甲方可按会员周期重复发起扣费指令,直至乙方依法撤销授权为止。",
|
||||
},
|
||||
{ type: "heading", text: "四、授权有效期" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 本授权自乙方点击确认开通自动续费服务之日起生效,至乙方成功取消自动续费服务之日终止。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 若乙方注销射灵星球小程序账号,本授权自账号注销完成之日自动终止。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "3. 若因国家政策调整、支付机构规则变更、乙方支付账户注销/冻结等非甲方主观原因导致授权无法履行的,本授权自动终止。",
|
||||
},
|
||||
{ type: "heading", text: "五、扣费与提醒规则" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 扣费提醒:甲方将在每个自动续费扣费日期前5日,通过微信服务通知、小程序系统消息或短信等显著方式提示乙方即将发生续期扣费的信息,以保障乙方的知情权与选择权。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 扣费时机:甲方将在乙方当前会员有效期届满前24小时内发起下一周期的扣费指令,支付机构根据指令从乙方授权账户中划扣对应费用。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "3. 扣费失败处理:若因账户余额不足等原因导致首次扣费失败的,甲方及支付机构可在合规范围内依法尝试补扣;若补扣仍失败或账户处于异常状态的,本期自动续费暂停,乙方会员到期后自动失效。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "4. 扣费凭证:支付机构的扣费记录作为扣费成功的有效凭证,乙方可在支付账户账单中查询明细;甲方同步为乙方提供电子扣费记录,可在会员中心查看。",
|
||||
},
|
||||
{ type: "heading", text: "六、授权的变更与撤销" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 授权变更:本授权内容如需变更(如更换支付账户、调整续费套餐),乙方需先取消原自动续费服务,再重新开通新套餐。新授权自重新开通成功之日起生效,原授权同步终止。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 授权撤销:乙方可随时退订本自动续费服务,解约后不影响乙方已生效周期的会员服务。根据乙方开通时选择的支付执行方,具体撤销路径如下:",
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
items: [
|
||||
"微信支付用户:可通过微信APP内(路径:我 -> 服务 -> 钱包 -> 支付设置 -> 自动续费)或在小程序会员中心页面撤销本授权。",
|
||||
"支付宝用户:可通过支付宝APP内(路径:我的 -> 设置 -> 支付设置 -> 免密支付/自动扣款)或在小程序会员中心页面撤销本授权。",
|
||||
"苹果支付(iOS/App Store订阅)用户:必须通过苹果系统自带的功能进行取消(路径:iOS设备“设置” -> 点击顶部的Apple ID -> 订阅 -> 选择“射灵星球” -> 取消订阅)。",
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "3. 退订生效时效:",
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
items: [
|
||||
"针对微信支付和支付宝:撤销操作成功后,本授权即时终止,甲方不得再发起新的扣费指令。因第三方支付平台系统结算延迟等客观原因,导致退订生效前系统已自动扣款成功的,该期会员权益将正常发放,已扣费用原则上不予退还。",
|
||||
"针对苹果支付:根据苹果公司政策,乙方需在当前计费周期届满前至少24小时手动取消订阅,否则苹果系统可能会自动续订并扣款。苹果渠道的扣费与退款均由苹果公司独立处理,甲方无权干涉,因乙方未及时取消导致扣费的,由乙方自行承担或向苹果公司申诉。",
|
||||
],
|
||||
},
|
||||
{ type: "heading", text: "七、免责条款" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 因乙方支付账户余额不足、账户冻结、挂失、注销、限额等非甲方原因导致扣费失败的,甲方不承担任何责任,由此造成的会员权益中断等后果由乙方自行承担。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 因支付机构系统故障、网络中断、政策调整等第三方不可抗力或外部原因导致扣费延迟、失败或错误的,甲方将协助乙方协调解决,但不承担相应的赔偿责任。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "3. 因乙方泄露支付账户密码、账号被盗用等自身保管不当原因导致的异常扣费,甲方不承担责任,乙方应自行向支付机构或公安机关主张权利。",
|
||||
},
|
||||
{ type: "heading", text: "八、信息保密" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 甲方及支付机构应对乙方的授权信息、支付信息、个人身份信息严格保密,不得用于本授权以外的任何用途。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 除法律法规规定、司法机关或监管部门依法要求外,甲方不得向任何第三方泄露乙方的授权及支付相关信息。",
|
||||
},
|
||||
{ type: "heading", text: "九、争议解决" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 本授权协议的订立、效力、履行及争议解决均适用中华人民共和国法律。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 因本协议产生的任何争议,双方应尽量友好协商解决;协商不成的,任何一方均可向甲方住所地(广东省广州市天河区)有管辖权的人民法院提起诉讼。",
|
||||
},
|
||||
{ type: "heading", text: "十、其他" },
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "1. 本协议为《射灵星球小程序会员服务协议》的配套协议,与该协议具有同等法律效力;本协议未约定事项,参照主协议执行。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "2. 甲方有权根据业务及监管要求调整本协议内容,调整后的协议将在平台公示,乙方继续使用自动续费服务视为接受调整后的内容。",
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "3. 甲方客服联系方式:请通过射灵星球小程序内【在线客服】或发送邮件至官方客服邮箱进行反馈。",
|
||||
},
|
||||
],
|
||||
company: "广州光点飞舞网络有限公司",
|
||||
},
|
||||
};
|
||||
|
||||
export const getMemberAgreement = (type) => {
|
||||
return memberAgreements[type] || memberAgreements.renew;
|
||||
};
|
||||
@@ -0,0 +1,894 @@
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import Signin from "@/components/Signin.vue";
|
||||
import { virtualPayOrderAPI, getAppConfig, getHomeData, getOrderDetailAPI } from "@/apis";
|
||||
import { capsuleHeight, wxLogin } from "@/util";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const store = useStore();
|
||||
const { user, config } = storeToRefs(store);
|
||||
const { updateConfig, updateUser } = store;
|
||||
|
||||
const currentTypeIndex = ref(1);
|
||||
const selectedPackageIndex = ref(0);
|
||||
const showModal = ref(false);
|
||||
const loadingConfig = ref(false);
|
||||
const paying = ref(false);
|
||||
const refreshing = ref(false);
|
||||
|
||||
// 会员页核心展示数据:视觉、权益按蓝湖当前两张设计稿拆分,套餐完全使用接口数据。
|
||||
const memberTypes = [
|
||||
{
|
||||
key: "normal",
|
||||
tab: "VIP",
|
||||
title: "普通会员",
|
||||
prefix: "成为射灵星球",
|
||||
desc: "特享约战竞技次数包、专属会员标识",
|
||||
benefitTitle: "普通会员专属权益",
|
||||
themeClass: "vip-page--normal",
|
||||
heroCard: "https://static.shelingxingqiu.com/shootmini/static/vip/vip-title.png",
|
||||
activeHeroCard: "https://static.shelingxingqiu.com/shootmini/static/vip/vip-title2.png",
|
||||
orderIcon: "../../static/vip/vip-order.png",
|
||||
heroBadge: "../../static/vip/normal-hero-badge.png",
|
||||
buttonClass: "activate-btn--normal",
|
||||
benefits: [
|
||||
{ label: "专属会员标识", icon: "../../static/vip/vip-badge.png" },
|
||||
{ label: "教练点评", icon: "../../static/vip/vip-comment.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-battle.png" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "super",
|
||||
tab: "SVIP",
|
||||
title: "超级会员",
|
||||
prefix: "成为射灵星球",
|
||||
desc: "尊享专属特效、无限制约战竞技、专属会员标识",
|
||||
benefitTitle: "超级会员专属权益",
|
||||
themeClass: "vip-page--super",
|
||||
heroCard: "https://static.shelingxingqiu.com/shootmini/static/vip/svip-title.png",
|
||||
activeHeroCard: "https://static.shelingxingqiu.com/shootmini/static/vip/svip-title2.png",
|
||||
orderIcon: "../../static/vip/svip-order.png",
|
||||
heroBadge: "../../static/vip/super-hero-badge.png",
|
||||
buttonClass: "activate-btn--super",
|
||||
benefits: [
|
||||
{ label: "专属落点标识", icon: "../../static/vip/svip-point.png" },
|
||||
{ label: "专属命中效果", icon: "../../static/vip/svip-hit.png" },
|
||||
{ label: "专属射箭效果", icon: "../../static/vip/svip-arrow.png" },
|
||||
{ label: "专属会员标识", icon: "../../static/vip/svip-badge.png" },
|
||||
{ label: "教练点评", icon: "../../static/vip/svip-comment.png" },
|
||||
{ label: "约战无限制", icon: "../../static/vip/svip-battle.png" },
|
||||
{ label: "排位赛无限制", icon: "../../static/vip/svip-rank.png" },
|
||||
{ label: "专享SVIP客服", icon: "../../static/vip/svip-service.png" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const currentType = computed(() => memberTypes[currentTypeIndex.value]);
|
||||
|
||||
// 后端到期时间可能是秒级时间戳、毫秒级时间戳或日期字符串,这里统一转成毫秒。
|
||||
const toTimestamp = (value) => {
|
||||
if (!value) return 0;
|
||||
const numberValue = Number(value);
|
||||
if (!Number.isNaN(numberValue)) {
|
||||
return numberValue < 1000000000000 ? numberValue * 1000 : numberValue;
|
||||
}
|
||||
const time = new Date(value).getTime();
|
||||
return Number.isNaN(time) ? 0 : time;
|
||||
};
|
||||
|
||||
// 当前卡片只关心本 tab 对应的会员到期时间,普通会员和超级会员互不兜底。
|
||||
const getVipExpiredValue = (type, source = user.value) => {
|
||||
if (!source) return 0;
|
||||
return type.key === "super" ? source.superVipExpiredAt : source.normalVipExpiredAt;
|
||||
};
|
||||
|
||||
// 未过期才展示“会员生效中”样式,已过期或无值继续展示未开通样式。
|
||||
const isVipActive = (type) => {
|
||||
return toTimestamp(getVipExpiredValue(type)) > Date.now();
|
||||
};
|
||||
|
||||
// 会员卡片展示完整到期时间。
|
||||
const formatVipDate = (value) => {
|
||||
const timestamp = toTimestamp(value);
|
||||
if (!timestamp) return "";
|
||||
const date = new Date(timestamp);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
const hour = String(date.getHours()).padStart(2, "0");
|
||||
const minute = String(date.getMinutes()).padStart(2, "0");
|
||||
const second = String(date.getSeconds()).padStart(2, "0");
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
};
|
||||
|
||||
// 会员生效时使用 title2 切图,未生效时沿用原来的开通引导图。
|
||||
const getHeroCard = (type) => {
|
||||
return isVipActive(type) ? type.activeHeroCard : type.heroCard;
|
||||
};
|
||||
|
||||
const getActiveVipExpiredDate = (type) => {
|
||||
return formatVipDate(getVipExpiredValue(type));
|
||||
};
|
||||
|
||||
// 设计稿里的“下期自动续费”按到期日前一天展示。
|
||||
const getActiveVipRenewDate = (type) => {
|
||||
const timestamp = toTimestamp(getVipExpiredValue(type));
|
||||
if (!timestamp) return "";
|
||||
return formatVipDate(timestamp - 24 * 60 * 60 * 1000);
|
||||
};
|
||||
|
||||
const configMenus = computed(() => {
|
||||
return config.value.vipMenus || [];
|
||||
});
|
||||
|
||||
const getMenuName = (item) => {
|
||||
return item.name || item.vipName || item.title || "";
|
||||
};
|
||||
|
||||
const formatPrice = (value) => {
|
||||
if (value === undefined || value === null || value === "") return "";
|
||||
return String(value).replace("¥", "").replace("¥", "");
|
||||
};
|
||||
|
||||
const getMenuPrice = (item) => {
|
||||
return formatPrice(item && item.price);
|
||||
};
|
||||
|
||||
const getMenuOriginalPrice = (item) => {
|
||||
return formatPrice(item && item.originalPrice);
|
||||
};
|
||||
|
||||
const getMenuSortValue = (item) => {
|
||||
const value = item && item.sort;
|
||||
if (value === undefined || value === null || value === "") return Number.MAX_SAFE_INTEGER;
|
||||
const sort = Number(value);
|
||||
return Number.isFinite(sort) ? sort : Number.MAX_SAFE_INTEGER;
|
||||
};
|
||||
|
||||
const sortMenusBySort = (menus = []) => {
|
||||
return menus
|
||||
.map((item, index) => ({ item, index }))
|
||||
.sort((a, b) => {
|
||||
const sortDiff = getMenuSortValue(a.item) - getMenuSortValue(b.item);
|
||||
return sortDiff || a.index - b.index;
|
||||
})
|
||||
.map(({ item }) => item);
|
||||
};
|
||||
|
||||
const getMenuType = (item) => {
|
||||
const vipType = Number(item.vipType);
|
||||
if (vipType === 1) return "normal";
|
||||
if (vipType === 2) return "super";
|
||||
|
||||
const type = String(item.type || "").toLowerCase();
|
||||
if (["super", "svip"].includes(type)) return "super";
|
||||
if (["normal", "vip"].includes(type)) return "normal";
|
||||
|
||||
const name = getMenuName(item);
|
||||
if (/超级|SVIP/i.test(name)) return "super";
|
||||
if (/普通|VIP|会员/i.test(name)) return "normal";
|
||||
return "";
|
||||
};
|
||||
|
||||
const getPackages = (type) => {
|
||||
return sortMenusBySort(configMenus.value)
|
||||
.filter((item) => getMenuType(item) === type.key)
|
||||
.map((item) => {
|
||||
return {
|
||||
source: item,
|
||||
id: item.id,
|
||||
name: getMenuName(item),
|
||||
price: getMenuPrice(item),
|
||||
originalPrice: getMenuOriginalPrice(item),
|
||||
icon: item.icon,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const currentPackages = computed(() => {
|
||||
return getPackages(currentType.value);
|
||||
});
|
||||
|
||||
const selectedPackage = computed(() => {
|
||||
return currentPackages.value[selectedPackageIndex.value] || currentPackages.value[0];
|
||||
});
|
||||
|
||||
const switchType = (index) => {
|
||||
currentTypeIndex.value = index;
|
||||
selectedPackageIndex.value = 0;
|
||||
};
|
||||
|
||||
const onSwiperChange = (event) => {
|
||||
currentTypeIndex.value = event.detail.current;
|
||||
selectedPackageIndex.value = 0;
|
||||
};
|
||||
|
||||
const selectPackage = (index) => {
|
||||
selectedPackageIndex.value = index;
|
||||
};
|
||||
|
||||
const toPackageDesc = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/member/vip-intro",
|
||||
});
|
||||
};
|
||||
|
||||
const toOrderPage = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/member/orders",
|
||||
});
|
||||
};
|
||||
|
||||
const toAgreement = (type) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/member/agreement?type=${type}`,
|
||||
});
|
||||
};
|
||||
|
||||
const loadVipConfig = async () => {
|
||||
if (loadingConfig.value || configMenus.value.length) return;
|
||||
loadingConfig.value = true;
|
||||
try {
|
||||
const result = await getAppConfig();
|
||||
if (result) updateConfig(result);
|
||||
} catch (error) {
|
||||
console.log("load vip config error", error);
|
||||
} finally {
|
||||
loadingConfig.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const refreshUserAfterPay = async () => {
|
||||
refreshing.value = true;
|
||||
try {
|
||||
const result = await getHomeData();
|
||||
if (result.user) {
|
||||
updateUser(result.user);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("refresh user after pay error", error);
|
||||
} finally {
|
||||
refreshing.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getVirtualPaySignData = (result) => {
|
||||
// 后端可能返回字符串或对象,这里统一转成微信虚拟支付需要的 JSON 字符串。
|
||||
const signDataObj = typeof result?.signData === "string" ? JSON.parse(result.signData) : result?.signData;
|
||||
if (!signDataObj) return "";
|
||||
|
||||
// 微信虚拟支付短剧/虚拟商品模式需要购买数量;后端未返回时使用订单数量兜底。
|
||||
if (!signDataObj.buyQuantity) {
|
||||
signDataObj.buyQuantity = result.quantity || 1;
|
||||
}
|
||||
return JSON.stringify(signDataObj);
|
||||
};
|
||||
|
||||
const isVirtualPayCancel = (res = {}) => {
|
||||
const message = String(res.errMsg || res.message || "").toLowerCase();
|
||||
const errCode = Number(res.errCode);
|
||||
const errno = Number(res.errno);
|
||||
|
||||
return message.includes("cancel") || errCode === -23 || errno === -2;
|
||||
};
|
||||
|
||||
const onPay = async () => {
|
||||
if (paying.value || refreshing.value) return;
|
||||
if (!user.value.id) {
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
if (!configMenus.value.length) {
|
||||
await loadVipConfig();
|
||||
}
|
||||
const vipId = selectedPackage.value && selectedPackage.value.id;
|
||||
if (!vipId) {
|
||||
uni.showToast({
|
||||
title: loadingConfig.value ? "套餐配置加载中" : "套餐暂不可购买",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeof wx === "undefined" || !wx.requestVirtualPayment) {
|
||||
uni.showToast({
|
||||
title: "当前环境不支持微信虚拟支付",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
paying.value = true;
|
||||
let waitingPayment = false;
|
||||
let payToast = null;
|
||||
try {
|
||||
// 微信虚拟支付创建订单前需要登录 code,服务端用它换取本次支付签名参数。
|
||||
const wxResult = await wxLogin();
|
||||
const result = await virtualPayOrderAPI(vipId, wxResult.code);
|
||||
const finalSignData = getVirtualPaySignData(result);
|
||||
if (!finalSignData || !result?.paySig || !result?.signature) {
|
||||
uni.showToast({
|
||||
title: "支付参数生成失败",
|
||||
icon: "none",
|
||||
});
|
||||
refreshing.value = false;
|
||||
return;
|
||||
}
|
||||
wx.requestVirtualPayment({
|
||||
signData: finalSignData,
|
||||
paySig: result.paySig,
|
||||
signature: result.signature,
|
||||
mode: "short_series_goods",
|
||||
async success() {
|
||||
payToast = {
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
};
|
||||
if (result?.outTradeNo) {
|
||||
try {
|
||||
const orderDetail = await getOrderDetailAPI(result.outTradeNo);
|
||||
console.log("virtual pay order detail", orderDetail);
|
||||
} catch (error) {
|
||||
console.log("virtual pay order detail error", error);
|
||||
}
|
||||
}
|
||||
// 客户端支付成功后,会员是否真正生效仍以服务端用户信息刷新结果为准。
|
||||
refreshUserAfterPay();
|
||||
},
|
||||
fail(res) {
|
||||
console.log("virtual pay error", res);
|
||||
if (isVirtualPayCancel(res)) {
|
||||
payToast = {
|
||||
title: "支付已取消",
|
||||
icon: "none",
|
||||
};
|
||||
return;
|
||||
}
|
||||
payToast = {
|
||||
title: res.message || "支付失败,请稍后重试",
|
||||
icon: "none",
|
||||
};
|
||||
},
|
||||
complete() {
|
||||
paying.value = false;
|
||||
if (payToast) {
|
||||
setTimeout(() => {
|
||||
uni.showToast(payToast);
|
||||
}, 200);
|
||||
}
|
||||
},
|
||||
});
|
||||
waitingPayment = true;
|
||||
} catch (error) {
|
||||
console.log("create virtual pay order error", error);
|
||||
uni.showToast({
|
||||
title: error.message || "下单失败",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
if (!waitingPayment) paying.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onShow(loadVipConfig);
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="" :bgType="10" :scroll="false" :showBottom="false">
|
||||
<view class="vip-page" :class="currentType.themeClass">
|
||||
<view class="type-tabs" :style="{ top: capsuleHeight + 'px' }">
|
||||
<view
|
||||
v-for="(item, index) in memberTypes"
|
||||
:key="item.key"
|
||||
class="type-tab"
|
||||
:class="{ 'type-tab--active': currentTypeIndex === index }"
|
||||
@click="switchType(index)"
|
||||
>
|
||||
<text>{{ item.tab }}</text>
|
||||
<view class="type-tab__indicator" />
|
||||
</view>
|
||||
</view>
|
||||
<swiper
|
||||
class="type-swiper"
|
||||
:current="currentTypeIndex"
|
||||
:duration="260"
|
||||
@change="onSwiperChange"
|
||||
>
|
||||
<swiper-item v-for="type in memberTypes" :key="type.key">
|
||||
<scroll-view scroll-y class="type-scroll" :show-scrollbar="false">
|
||||
<view class="vip-content">
|
||||
<view
|
||||
class="hero-card"
|
||||
:class="{ 'hero-card--active': isVipActive(type) }"
|
||||
>
|
||||
<image class="hero-card__bg" :src="getHeroCard(type)" mode="scaleToFill" />
|
||||
<!-- 生效态卡片使用 title2 底图,补充有效期和订单入口叠层。 -->
|
||||
<view v-if="isVipActive(type)" class="hero-card__content">
|
||||
<text class="hero-card__date">
|
||||
有效期至:{{ getActiveVipExpiredDate(type) }}
|
||||
</text>
|
||||
<!-- <text v-if="type.key === 'super'" class="hero-card__renew">
|
||||
下期会员将于:{{ getActiveVipRenewDate(type) }}自动续费
|
||||
</text> -->
|
||||
<view class="hero-card__order" @click.stop="toOrderPage">
|
||||
<image class="hero-card__order-icon" :src="type.orderIcon" mode="aspectFit" />
|
||||
<text>订单管理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="benefit-title">
|
||||
<view class="benefit-title__line" />
|
||||
<text>{{ type.benefitTitle }}</text>
|
||||
<view class="benefit-title__line" />
|
||||
</view>
|
||||
|
||||
<view class="benefit-grid" :class="{ 'benefit-grid--normal': type.key === 'normal' }">
|
||||
<view
|
||||
v-for="benefit in type.benefits"
|
||||
:key="benefit.label"
|
||||
class="benefit-item"
|
||||
>
|
||||
<view class="benefit-icon">
|
||||
<image class="benefit-icon__img" :src="benefit.icon" mode="aspectFit" />
|
||||
</view>
|
||||
<text class="benefit-item__label">{{ benefit.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="package-header">
|
||||
<text class="package-header__title">选择套餐</text>
|
||||
<view class="package-header__link" @click="toPackageDesc">
|
||||
<text>套餐说明</text>
|
||||
<image
|
||||
class="package-header__icon"
|
||||
src="../../static/enter.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-x class="package-scroll" :show-scrollbar="false">
|
||||
<view class="package-list">
|
||||
<view
|
||||
v-for="(pack, index) in getPackages(type)"
|
||||
:key="`${type.key}-${pack.id || pack.name || index}`"
|
||||
class="package-card"
|
||||
:class="{ 'package-card--active': selectedPackageIndex === index }"
|
||||
@click="selectPackage(index)"
|
||||
>
|
||||
<view class="package-card__inner">
|
||||
<text class="package-name">{{ pack.name }}</text>
|
||||
<view class="package-price">
|
||||
<text class="package-price__symbol">¥</text>
|
||||
<text class="package-price__value">{{ pack.price }}</text>
|
||||
</view>
|
||||
<view v-if="pack.originalPrice" class="package-origin">
|
||||
<text>¥{{ pack.originalPrice }}</text>
|
||||
<view class="package-origin__line" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<button
|
||||
hover-class="none"
|
||||
class="activate-btn"
|
||||
:class="type.buttonClass"
|
||||
:disabled="loadingConfig || paying || refreshing || !selectedPackage"
|
||||
@click="onPay"
|
||||
>
|
||||
<text v-if="loadingConfig">加载套餐中</text>
|
||||
<text v-else-if="paying">创建订单中</text>
|
||||
<text v-else-if="refreshing">刷新会员状态中</text>
|
||||
<text v-else-if="selectedPackage">¥ {{ selectedPackage.price }} 一键激活</text>
|
||||
<text v-else>套餐暂不可购买</text>
|
||||
</button>
|
||||
|
||||
<view class="agreement">
|
||||
<text>支付即同意</text>
|
||||
《 <text class="agreement__link" @click.stop="toAgreement('renew')">会员自动续费服务协议</text>》
|
||||
《 <text class="agreement__link" @click.stop="toAgreement('deduct')">扣款授权服务协议</text>》
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<Signin :show="showModal" :onClose="() => (showModal = false)" />
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.vip-page {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.type-tabs {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
z-index: 998;
|
||||
width: 50%;
|
||||
height: 50px;
|
||||
margin-left: 50%;
|
||||
transform:translateX(-60%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.type-tab {
|
||||
width: 132rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.type-tab__indicator {
|
||||
width: 40rpx;
|
||||
height: 4rpx;
|
||||
border-radius: 4rpx;
|
||||
margin-top: 8rpx;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.type-tab--active {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.vip-page--normal .type-tab--active .type-tab__indicator {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.vip-page--super .type-tab--active {
|
||||
color: #fedab5;
|
||||
}
|
||||
|
||||
.vip-page--super .type-tab--active .type-tab__indicator {
|
||||
background-color: #fedab5;
|
||||
}
|
||||
|
||||
.type-swiper {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.type-scroll {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.vip-content {
|
||||
min-height: 100%;
|
||||
padding: 32rpx 24rpx 52rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.hero-card {
|
||||
position: relative;
|
||||
width: 702rpx;
|
||||
height: 260rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hero-card__bg {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 702rpx;
|
||||
height: 260rpx;
|
||||
}
|
||||
|
||||
.hero-card__content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
/* 对齐 title2 切图左侧预留文案区域。 */
|
||||
padding: 132rpx 0 0 44rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.hero-card__date,
|
||||
.hero-card__renew {
|
||||
color: #8d6d55;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.vip-page--normal .hero-card__date,
|
||||
.vip-page--normal .hero-card__renew {
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
.hero-card__order {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 10rpx;
|
||||
color: #6d5644;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.vip-page--normal .hero-card__order {
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
.hero-card__order-icon {
|
||||
width: 28rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.benefit-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 38rpx;
|
||||
color: #ffffff;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.benefit-title__line {
|
||||
width: 14rpx;
|
||||
height: 2rpx;
|
||||
background-color: #ffffff;
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
|
||||
.benefit-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 622rpx;
|
||||
margin: 38rpx auto 0;
|
||||
}
|
||||
|
||||
.benefit-grid--normal {
|
||||
width: 672rpx;
|
||||
}
|
||||
|
||||
.benefit-item {
|
||||
width: 144rpx;
|
||||
height: 122rpx;
|
||||
margin-right: 94rpx;
|
||||
margin-bottom: 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.benefit-item:nth-child(3n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.benefit-grid--normal .benefit-item {
|
||||
margin-right: 120rpx;
|
||||
}
|
||||
|
||||
.benefit-grid--normal .benefit-item:nth-child(3n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.benefit-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.benefit-icon__img {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.benefit-item__label {
|
||||
margin-top: 8rpx;
|
||||
color: #ffffff;
|
||||
opacity: 0.7;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
text-align: center;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.package-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 56rpx;
|
||||
padding-right: 8rpx;
|
||||
}
|
||||
|
||||
.benefit-grid--normal + .package-header {
|
||||
margin-top: 146rpx;
|
||||
}
|
||||
|
||||
.package-header__title {
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.vip-page--super .package-header__title {
|
||||
color: #e7ba80;
|
||||
}
|
||||
|
||||
.package-header__link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #999999;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
|
||||
.package-header__icon {
|
||||
width: 24rpx;
|
||||
height: 28rpx;
|
||||
}
|
||||
|
||||
.package-scroll {
|
||||
width: 100%;
|
||||
margin-top: 40rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.package-list {
|
||||
display: inline-flex;
|
||||
min-width: 100%;
|
||||
padding: 6rpx 84rpx 6rpx 6rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.package-card {
|
||||
position: relative;
|
||||
width: 264rpx;
|
||||
flex: 0 0 264rpx;
|
||||
height: 224rpx;
|
||||
border-radius: 16rpx;
|
||||
border: 2rpx solid #999999;
|
||||
margin-right: 32rpx;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.package-card__inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
.package-card--active {
|
||||
border-width: 6rpx;
|
||||
border-color: #fed847;
|
||||
}
|
||||
|
||||
.vip-page--super .package-card--active {
|
||||
border: none;
|
||||
padding: 6rpx;
|
||||
background: linear-gradient(180deg, #fef3e6 0%, #f0c191 100%);
|
||||
}
|
||||
|
||||
.vip-page--super .package-card--active .package-card__inner {
|
||||
border-radius: 10rpx;
|
||||
background-color: #050b19;
|
||||
}
|
||||
|
||||
.package-name {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.package-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin-top: 12rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.package-card--active .package-price {
|
||||
color: #fed847;
|
||||
}
|
||||
|
||||
.vip-page--super .package-card--active .package-price {
|
||||
color: #ffe8cd;
|
||||
}
|
||||
|
||||
.package-price__symbol {
|
||||
font-size: 30rpx;
|
||||
line-height: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.package-price__value {
|
||||
font-size: 56rpx;
|
||||
line-height: 66rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.package-origin {
|
||||
position: relative;
|
||||
margin-top: 2rpx;
|
||||
color: #999999;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.package-origin__line {
|
||||
position: absolute;
|
||||
left: -4rpx;
|
||||
right: -4rpx;
|
||||
top: 16rpx;
|
||||
height: 2rpx;
|
||||
background-color: #999999;
|
||||
}
|
||||
|
||||
.activate-btn {
|
||||
width: 686rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
margin: 34rpx auto 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #000000;
|
||||
font-size: 30rpx;
|
||||
line-height: 42rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.activate-btn::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.activate-btn--normal {
|
||||
background-color: #fed847;
|
||||
}
|
||||
|
||||
.activate-btn--super {
|
||||
background: linear-gradient( 181deg, #FDFDFC 0%, #FDF8F2 0%, #FFC992 100%, #FFB96C 100%);
|
||||
}
|
||||
|
||||
.agreement {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 24rpx;
|
||||
color: #999999;
|
||||
font-size: 20rpx;
|
||||
line-height: 28rpx;
|
||||
}
|
||||
|
||||
.agreement__link {
|
||||
margin-left: -6rpx;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -61,6 +61,18 @@ const goPay = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const copyOrderId = (orderId) => {
|
||||
uni.setClipboardData({
|
||||
data: String(orderId),
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: "复制成功",
|
||||
icon: "success",
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const cancelOrder = async () => {
|
||||
const result = await cancelOrderListAPI(data.value.orderId);
|
||||
data.value = result;
|
||||
@@ -78,14 +90,17 @@ const cancelOrder = async () => {
|
||||
>
|
||||
<view class="order">
|
||||
<view>
|
||||
<text>商品名:{{ data.vipName }}</text>
|
||||
<text>订单号:{{ data.orderId }}</text>
|
||||
<text>下单时间:{{ data.vipCreateAt }}</text>
|
||||
<text
|
||||
>支付时间:{{
|
||||
<text>{{ data.vipName }}</text>
|
||||
<view class="order-number">
|
||||
<text>订单号:{{ data.orderId }}</text>
|
||||
<text class="copy-action" @click.stop="copyOrderId(data.orderId)"
|
||||
>复制</text
|
||||
>
|
||||
</view>
|
||||
<text>创建时间:{{ data.orderCreateAt }}</text>
|
||||
<text v-if="data.orderStatus === 4">支付时间:{{
|
||||
data.orderStatus === 4 ? data.paymentTime : ""
|
||||
}}</text
|
||||
>
|
||||
}}</text>
|
||||
<text>金额:{{ data.total }} 元</text>
|
||||
<text>支付方式:微信</text>
|
||||
</view>
|
||||
@@ -141,4 +156,25 @@ const cancelOrder = async () => {
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.order-number {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #666666;
|
||||
font-size: 26rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.order-number > text:first-child {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
.copy-action {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
padding: 2rpx 14rpx;
|
||||
color: #1f6ed4;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -3,6 +3,7 @@ import { ref, onMounted } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import ScrollList from "@/components/ScrollList.vue";
|
||||
import ModalDialog from "@/components/ModalDialog.vue";
|
||||
import { getOrderListAPI } from "@/apis";
|
||||
import useStore from "@/store";
|
||||
import { orderStatusNames, getStatusColor } from "@/constants";
|
||||
@@ -10,13 +11,34 @@ import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user, config } = storeToRefs(store);
|
||||
|
||||
const autoRenewDialogVisible = ref(false);
|
||||
const selectedRenewOrder = ref(null);
|
||||
|
||||
const toDetailPage = (detail) => {
|
||||
uni.setStorageSync("order", detail);
|
||||
uni.navigateTo({
|
||||
url: `/pages/order-detail`,
|
||||
url: "/pages/member/order-detail",
|
||||
});
|
||||
};
|
||||
|
||||
const openAutoRenewDialog = (detail) => {
|
||||
selectedRenewOrder.value = detail;
|
||||
autoRenewDialogVisible.value = true;
|
||||
};
|
||||
|
||||
const closeAutoRenewDialog = () => {
|
||||
autoRenewDialogVisible.value = false;
|
||||
selectedRenewOrder.value = null;
|
||||
};
|
||||
|
||||
const confirmAutoRenewDialog = () => {
|
||||
autoRenewDialogVisible.value = false;
|
||||
uni.showToast({
|
||||
title: "功能实现中",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
const list = ref([]);
|
||||
|
||||
const onLoading = async (page) => {
|
||||
@@ -44,7 +66,7 @@ onShow(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="订单">
|
||||
<Container title="订单管理">
|
||||
<view class="container">
|
||||
<ScrollList :onLoading="onLoading">
|
||||
<view
|
||||
@@ -58,18 +80,31 @@ onShow(() => {
|
||||
>{{ orderStatusNames[item.orderStatus] }}</view
|
||||
>
|
||||
<text>{{ item.vipName }}</text>
|
||||
<!-- <text>订单号:{{ item.orderId }}</text> -->
|
||||
<!-- <text>创建时间:{{ item.vipCreateAt }}</text> -->
|
||||
<text
|
||||
<text>订单号:{{ item.orderId }}</text>
|
||||
<text>创建时间:{{ item.orderCreateAt }}</text>
|
||||
<!-- <text
|
||||
>支付时间:{{
|
||||
item.orderStatus === 4 ? item.paymentTime : ""
|
||||
}}</text
|
||||
>
|
||||
> -->
|
||||
<text>金额:{{ item.total }} 元</text>
|
||||
<text>支付方式:微信</text>
|
||||
<!-- <text>支付方式:微信</text> -->
|
||||
<!-- <text class="renew-action" @click.stop="openAutoRenewDialog(item)">
|
||||
自动续费
|
||||
</text> -->
|
||||
</view>
|
||||
</ScrollList>
|
||||
</view>
|
||||
|
||||
<ModalDialog
|
||||
:show="autoRenewDialogVisible"
|
||||
title=""
|
||||
:content="'确定关闭自动续费吗?\n会员到期后你将失去7项特权哦!'"
|
||||
cancel-text="一意孤行"
|
||||
confirm-text="继续享受"
|
||||
:on-cancel="closeAutoRenewDialog"
|
||||
:on-confirm="confirmAutoRenewDialog"
|
||||
/>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
@@ -78,15 +113,15 @@ onShow(() => {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #f5f5f5;
|
||||
padding-top: 10px;
|
||||
padding-top: 16rpx;
|
||||
}
|
||||
.order-item {
|
||||
position: relative;
|
||||
background-color: #fff;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 15px;
|
||||
padding: 28rpx 30rpx 18rpx 30rpx;
|
||||
}
|
||||
.order-item > view:first-child {
|
||||
position: absolute;
|
||||
@@ -98,12 +133,20 @@ onShow(() => {
|
||||
font-size: 11px;
|
||||
}
|
||||
.order-item > text:nth-child(2) {
|
||||
color: #000;
|
||||
font-size: 16px;
|
||||
color: #333333;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.order-item > text {
|
||||
color: #666666;
|
||||
font-size: 13px;
|
||||
margin-top: 5px;
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
.order-item > .renew-action {
|
||||
position: absolute;
|
||||
right: 30rpx;
|
||||
bottom: 18rpx;
|
||||
color: #1f6ed4;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,244 @@
|
||||
<script setup>
|
||||
import Container from "@/components/Container.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="会员权益说明">
|
||||
<scroll-view scroll-y class="vip-intro" :show-scrollbar="false">
|
||||
<view class="content">
|
||||
<view class="page-title">射灵星球会员权益</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text class="strong">核心特权:</text>
|
||||
<text>解锁约战、段位评级、实时排位赛、AI智能教练点评四大核心功能。</text>
|
||||
</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text class="strong">专属服务:</text>
|
||||
<text>享全年不同阶段VIP专属客服,快速解决技术故障、规则疑问等所有问题。</text>
|
||||
</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text class="strong">新用户福利:</text>
|
||||
<text>所有初次绑定设备的用户,免费赠送6个月普通会员。</text>
|
||||
</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text>
|
||||
加入射灵星球,在真实射箭运动中体验在线竞技的乐趣,结识全球志同道合的弓友,持续享受新功能与系统升级,不断挑战自我,创造属于你的辉煌战绩!
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="table-wrap">
|
||||
<view class="intro-toast">
|
||||
<image class="intro-toast__bg" src="../../static/vip/intro-toast.png" mode="scaleToFill" />
|
||||
<text class="intro-toast__text">初次绑定设备赠送6个月</text>
|
||||
</view>
|
||||
<view class="benefit-table">
|
||||
<view class="table-row table-head">
|
||||
<text class="table-cell table-cell--feature">特权</text>
|
||||
<text class="table-cell">基础用户</text>
|
||||
<text class="table-cell">普通会员</text>
|
||||
<text class="table-cell">超级会员</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">专属落点标识</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">螺旋</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">专属命中效果</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">玻璃裂纹</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">箭矢飞行特效</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">光箭</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">每日约战次数</text>
|
||||
<text class="table-cell">2次</text>
|
||||
<text class="table-cell">22次</text>
|
||||
<text class="table-cell">无限</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">每日排位赛次数</text>
|
||||
<text class="table-cell">2次</text>
|
||||
<text class="table-cell">22次</text>
|
||||
<text class="table-cell">无限</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">教练点评</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">专享</text>
|
||||
<text class="table-cell">专享</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">昵称美化</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">专享</text>
|
||||
<text class="table-cell">专享</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text class="table-cell table-cell--feature">专属客服</text>
|
||||
<text class="table-cell">无</text>
|
||||
<text class="table-cell">专享</text>
|
||||
<text class="table-cell">专享</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-title">会员时长叠加与生效规则</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text class="strong">等级优先级:</text>
|
||||
<text>
|
||||
同时拥有 超级会员 和 普通会员 时,优先使用超级会员权益,普通会员时长自动顺延,待 超级会员 到期后自动生效。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text class="strong">连续套餐叠加:</text>
|
||||
<text>
|
||||
已有月 / 半年 / 年卡时再购买连续包月 / 包年,总有效期直接累加;连续套餐从下单日起算,下个周期正常自动扣费。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="paragraph example">
|
||||
<text>
|
||||
示例:1 月 1 日买半年卡(7 月 1 日到期),1 月 10 日买连续包月,总有效期延至 8 月 1 日,8 月 1 日会发起首次自动扣款。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="paragraph">
|
||||
<text class="strong">升级超级会员规则:</text>
|
||||
<text>
|
||||
购买升级 超级会员 后立即生效,可升级时长以购买页面提示为准;未升级的剩余 普通会员 时长,将在 超级会员 到期后继续使用。
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.vip-intro {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.page-title,
|
||||
.section-title {
|
||||
color: #333333;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
margin-bottom: 26rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 42rpx 0 22rpx;
|
||||
}
|
||||
|
||||
.paragraph {
|
||||
margin-bottom: 22rpx;
|
||||
color: #333333;
|
||||
font-size: 26rpx;
|
||||
line-height: 38rpx;
|
||||
}
|
||||
|
||||
.strong {
|
||||
color: #333333;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.example {
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
position: relative;
|
||||
margin-top: 34rpx;
|
||||
}
|
||||
|
||||
.intro-toast {
|
||||
position: absolute;
|
||||
top: -38rpx;
|
||||
right: 118rpx;
|
||||
z-index: 2;
|
||||
width: 222rpx;
|
||||
height: 54rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.intro-toast__bg {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 222rpx;
|
||||
height: 54rpx;
|
||||
}
|
||||
|
||||
.intro-toast__text {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: #333333;
|
||||
font-size: 18rpx;
|
||||
line-height: 30rpx;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
margin-top: -6rpx;
|
||||
}
|
||||
|
||||
.benefit-table {
|
||||
width: 100%;
|
||||
border-top: 1rpx solid #e5e5e5;
|
||||
border-left: 1rpx solid #e5e5e5;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: flex;
|
||||
min-height: 60rpx;
|
||||
}
|
||||
|
||||
.table-cell {
|
||||
width: 22.5%;
|
||||
min-height: 60rpx;
|
||||
padding: 12rpx 4rpx;
|
||||
border-right: 1rpx solid #e5e5e5;
|
||||
border-bottom: 1rpx solid #e5e5e5;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #333333;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.table-cell--feature {
|
||||
width: 32.5%;
|
||||
}
|
||||
|
||||
.table-head .table-cell {
|
||||
color: #666666;
|
||||
font-weight: 700;
|
||||
}
|
||||
</style>
|
||||
@@ -11,12 +11,14 @@ import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const arrows = ref([]);
|
||||
const isSvip = ref(false);
|
||||
const total = ref(0);
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (!options.id) return;
|
||||
const result = await getPractiseAPI(options.id || 176);
|
||||
arrows.value = result.details;
|
||||
isSvip.value = result.sVip === true;
|
||||
total.value = result.details.length;
|
||||
});
|
||||
</script>
|
||||
@@ -34,7 +36,7 @@ onLoad(async (options) => {
|
||||
</view>
|
||||
</view> -->
|
||||
<view :style="{ marginBottom: '20px' }">
|
||||
<BowTarget :scores="arrows" />
|
||||
<BowTarget :scores="arrows" :isSvip="isSvip" />
|
||||
</view>
|
||||
<view class="desc">
|
||||
<text>{{ arrows.length }}</text>
|
||||
|
||||
+50
-7
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
@@ -21,6 +21,8 @@ const { user, device } = storeToRefs(store);
|
||||
const justBind = ref(false);
|
||||
const calibration = ref(false);
|
||||
const token = ref(null);
|
||||
const isSVip = computed(() => user.value.sVip === true);
|
||||
const isVip = computed(() => user.value.vip === true && !isSVip.value);
|
||||
|
||||
// 扫描二维码方法
|
||||
const handleScan = () => {
|
||||
@@ -101,6 +103,11 @@ const unbindDevice = async () => {
|
||||
clearDevice();
|
||||
};
|
||||
|
||||
/** 连接wifi跳转到wifi列表页面 */
|
||||
const joinWifi = () => {
|
||||
uni.navigateTo({ url: "/pages/ota-wifi" });
|
||||
};
|
||||
|
||||
const toDeviceIntroPage = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/device-intro",
|
||||
@@ -154,7 +161,7 @@ onShow(async () => {
|
||||
<Container title="弓箭绑定">
|
||||
<view v-if="!device.deviceId" class="scan-code">
|
||||
<button hover-class="none" @click="$clickSound(handleScan)">
|
||||
<image src="../static/scan.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/scan.png" mode="widthFix" />
|
||||
</button>
|
||||
<button hover-class="none" @click="showTip = true">
|
||||
<text>扫</text>
|
||||
@@ -165,7 +172,7 @@ onShow(async () => {
|
||||
<text>射灵智能弓箭,三模传感系统与独创靶环算法,</text>
|
||||
<text>毫秒级在线实时对战,让你拥有全球约战的乐趣!</text>
|
||||
<button hover-class="none" @click="toDeviceIntroPage">
|
||||
<image src="../static/have-no-device.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/have-no-device.png" mode="widthFix" />
|
||||
</button>
|
||||
<ScreenHint
|
||||
mode="square"
|
||||
@@ -212,7 +219,7 @@ onShow(async () => {
|
||||
:style="{ marginBottom: calibration ? '250rpx' : '100rpx' }"
|
||||
>
|
||||
<view>
|
||||
<image src="../static/device-icon.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/device-icon.png" mode="widthFix" />
|
||||
<text>{{ device.deviceName }}</text>
|
||||
<view class="calibration" v-if="calibration">
|
||||
<button hover-class="none" @click="goCalibration">
|
||||
@@ -232,7 +239,18 @@ onShow(async () => {
|
||||
mode="widthFix"
|
||||
:style="{ borderRadius: '50%' }"
|
||||
/>
|
||||
<text>{{ user.nickName }}</text>
|
||||
<view
|
||||
:class="[
|
||||
'member-nickname',
|
||||
isVip ? 'member-nickname--vip' : '',
|
||||
isSVip ? 'member-nickname--svip' : '',
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ user.nickName }}</text>
|
||||
<text v-if="isSVip" class="member-nickname__shine">{{
|
||||
user.nickName
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <block v-if="calibration"> -->
|
||||
@@ -268,7 +286,7 @@ onShow(async () => {
|
||||
<view v-if="device.deviceId && !justBind" class="has-device">
|
||||
<view class="device-binded">
|
||||
<view>
|
||||
<image src="../static/device-icon.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/device-icon.png" mode="widthFix" />
|
||||
<text>{{ device.deviceName }}</text>
|
||||
<view class="calibration">
|
||||
<button hover-class="none" @click="goCalibration">
|
||||
@@ -290,7 +308,18 @@ onShow(async () => {
|
||||
mode="widthFix"
|
||||
:style="{ borderRadius: '50%' }"
|
||||
/>
|
||||
<text>{{ user.nickName }}</text>
|
||||
<view
|
||||
:class="[
|
||||
'member-nickname',
|
||||
isVip ? 'member-nickname--vip' : '',
|
||||
isSVip ? 'member-nickname--svip' : '',
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ user.nickName }}</text>
|
||||
<text v-if="isSVip" class="member-nickname__shine">{{
|
||||
user.nickName
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{ marginTop: '240rpx' }">
|
||||
@@ -298,6 +327,11 @@ onShow(async () => {
|
||||
>解绑</SButton
|
||||
>
|
||||
</view>
|
||||
<view :style="{ marginTop: '20rpx' }">
|
||||
<SButton :onClick="() => $clickSound(joinWifi)" width="80vw" :rounded="40"
|
||||
>设备连接WIFI</SButton
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
@@ -428,6 +462,15 @@ onShow(async () => {
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
.device-binded .member-nickname {
|
||||
justify-content: center;
|
||||
width: 120px;
|
||||
}
|
||||
.device-binded .member-nickname__text,
|
||||
.device-binded .member-nickname__shine {
|
||||
font-size: 26rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.device-binded > image {
|
||||
width: 100rpx;
|
||||
margin: 0 20px;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -81,9 +81,17 @@ const loading = ref(false);
|
||||
const shareImage = async () => {
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
await generateShareImage("shareImageCanvas", record.value);
|
||||
await wxShare("shareImageCanvas");
|
||||
loading.value = false;
|
||||
try {
|
||||
await generateShareImage("shareImageCanvas", record.value);
|
||||
await wxShare("shareImageCanvas");
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "海报生成失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(async (options) => {
|
||||
|
||||
@@ -15,11 +15,22 @@ const list = ref([]);
|
||||
const mine = ref({
|
||||
averageRing: 0,
|
||||
});
|
||||
const sharing = ref(false);
|
||||
|
||||
const shareImage = async () => {
|
||||
if (!mine.value.id) return;
|
||||
await sharePointData("shareCanvas", mine.value);
|
||||
await wxShare("shareCanvas");
|
||||
if (!mine.value.id || sharing.value) return;
|
||||
sharing.value = true;
|
||||
try {
|
||||
await sharePointData("shareCanvas", mine.value);
|
||||
await wxShare("shareCanvas");
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "海报生成失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
sharing.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -33,7 +44,7 @@ onMounted(async () => {
|
||||
<Container :bgType="5" bgColor="#F5F5F5" :whiteBackArrow="false">
|
||||
<view class="top-part">
|
||||
<view>
|
||||
<image src="../static/point-champion.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/point-champion.png" mode="widthFix" />
|
||||
<image
|
||||
:src="list[0] && list[0].avatar ? list[0].avatar : ''"
|
||||
mode="widthFix"
|
||||
|
||||
@@ -348,7 +348,7 @@ onShareTimeline(() => {
|
||||
/>
|
||||
<view class="heat-map">
|
||||
<image
|
||||
:src="bowTargetSrc || '../static/bow-target.png'"
|
||||
:src="bowTargetSrc || 'https://static.shelingxingqiu.com/shootmini/static/bow-target.png'"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<image
|
||||
@@ -374,7 +374,7 @@ onShareTimeline(() => {
|
||||
</view>
|
||||
<view class="reward" v-if="data.totalArrow">
|
||||
<button hover-class="none" @click="showTip = true">
|
||||
<image src="../static/reward-us.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/reward-us.png" mode="widthFix" />
|
||||
</button>
|
||||
</view>
|
||||
<RingBarChart :data="data.ringRate" v-if="user.id" />
|
||||
|
||||
+97
-62
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount, nextTick } from "vue";
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import ShootProgress from "@/components/ShootProgress.vue";
|
||||
@@ -15,10 +15,11 @@ import audioManager from "@/audioManager";
|
||||
|
||||
import {
|
||||
createPractiseAPI,
|
||||
startPractiseAPI,
|
||||
endPractiseAPI,
|
||||
getPractiseAPI,
|
||||
startPractiseAPI,
|
||||
} from "@/apis";
|
||||
import { connectMatchWebSocket, closeMatchWebSocket } from "@/matchWebsocket";
|
||||
import { sharePractiseData } from "@/canvas";
|
||||
import { wxShare, debounce } from "@/util";
|
||||
import { MESSAGETYPESV2, roundsName } from "@/constants";
|
||||
@@ -26,18 +27,20 @@ import { MESSAGETYPESV2, roundsName } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const { user, device } = storeToRefs(store);
|
||||
|
||||
const start = ref(false);
|
||||
const scores = ref([]);
|
||||
const isSvip = ref(false);
|
||||
const total = 12;
|
||||
/** 当前练习中连续 10 环及以上计数,用于触发 tententen 音效 */
|
||||
const xRingStreak = ref(0);
|
||||
const practiseResult = ref({});
|
||||
const practiseId = ref("");
|
||||
const showGuide = ref(false);
|
||||
const tips = ref("");
|
||||
const targetType = ref(1);
|
||||
const sharing = ref(false);
|
||||
const exiting = ref(false);
|
||||
const RESULT_TIP_CDN = "https://static.shelingxingqiu.com/shootmini/static";
|
||||
|
||||
onLoad((options) => {
|
||||
if (options.target) {
|
||||
@@ -45,52 +48,64 @@ onLoad((options) => {
|
||||
}
|
||||
});
|
||||
|
||||
const createPractise = async () => {
|
||||
closeMatchWebSocket({ reason: "practice-recreate" });
|
||||
const result = await createPractiseAPI(
|
||||
total,
|
||||
120,
|
||||
targetType.value,
|
||||
device.value.deviceId
|
||||
);
|
||||
if (result?.id) practiseId.value = result.id;
|
||||
if (!result?.serverAddr) {
|
||||
uni.showToast({
|
||||
title: "练习连接信息异常,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return null;
|
||||
}
|
||||
connectMatchWebSocket({
|
||||
serverAddr: result.serverAddr,
|
||||
matchId: result.id,
|
||||
userId: user.value.id,
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const beginPractise = async () => {
|
||||
if (!practiseId.value) {
|
||||
uni.showToast({
|
||||
title: "练习未创建,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
await startPractiseAPI(practiseId.value);
|
||||
return true;
|
||||
};
|
||||
|
||||
const onReady = async () => {
|
||||
await startPractiseAPI();
|
||||
const result = await beginPractise();
|
||||
if (!result) return;
|
||||
scores.value = [];
|
||||
xRingStreak.value = 0; // 新一局开始,重置 10 环及以上连续计数
|
||||
isSvip.value = false;
|
||||
start.value = true;
|
||||
audioManager.play("练习开始");
|
||||
};
|
||||
|
||||
const onOver = async () => {
|
||||
practiseResult.value = await getPractiseAPI(practiseId.value);
|
||||
const onOver = async (message) => {
|
||||
practiseResult.value = Array.isArray(message?.details)
|
||||
? message
|
||||
: await getPractiseAPI(practiseId.value);
|
||||
start.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 检测连续 10 环及以上是否达到 3 箭,达到则播放 tententen 音效
|
||||
* @param {boolean} isTenPlusRingShot - 本次射击是否为 10 环及以上
|
||||
*/
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function checkAndPlayTententen(isTenPlusRingShot) {
|
||||
if (isTenPlusRingShot) {
|
||||
xRingStreak.value += 1;
|
||||
// 连续 3 箭均为 10 环及以上,在环数播报入队后追加 tententen,避免播放顺序颠倒
|
||||
if (xRingStreak.value >= 3) {
|
||||
xRingStreak.value = 0;
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
} else {
|
||||
// 低于 10 环或未上靶则重置连续计数
|
||||
xRingStreak.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function onReceiveMessage(msg) {
|
||||
if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
const prevLen = scores.value.length;
|
||||
scores.value = msg.details;
|
||||
// 有新箭时取最后一箭判断是否 10 环及以上并检测连续计数
|
||||
if (scores.value.length > prevLen) {
|
||||
const latestArrow = scores.value[scores.value.length - 1];
|
||||
checkAndPlayTententen(isTenPlusRing(latestArrow));
|
||||
}
|
||||
isSvip.value = msg.sVip === true;
|
||||
scores.value = Array.isArray(msg.details) ? msg.details : scores.value;
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||
// setTimeout(onOver, 1500);
|
||||
setTimeout(() => onOver(msg), 1500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,33 +120,58 @@ async function onComplete() {
|
||||
practiseResult.value = {};
|
||||
start.value = false;
|
||||
scores.value = [];
|
||||
xRingStreak.value = 0; // 重新开始练习,重置 10 环及以上连续计数
|
||||
const result = await createPractiseAPI(total, 120);
|
||||
if (result) practiseId.value = result.id;
|
||||
isSvip.value = false;
|
||||
await createPractise();
|
||||
}
|
||||
}
|
||||
|
||||
async function exitPractise() {
|
||||
if (exiting.value) return;
|
||||
exiting.value = true;
|
||||
|
||||
try {
|
||||
if (practiseId.value && !practiseResult.value?.details) {
|
||||
await endPractiseAPI(practiseId.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to stop practice", error);
|
||||
} finally {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
|
||||
const getResultTipSrc = (result = {}) => {
|
||||
const validCount = (result.details || []).filter(
|
||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||
).length;
|
||||
return `${RESULT_TIP_CDN}/${validCount < total ? "un" : ""}finish-tip.png`;
|
||||
};
|
||||
|
||||
const onClickShare = debounce(async () => {
|
||||
await sharePractiseData("shareCanvas", 2, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
if (sharing.value) return;
|
||||
sharing.value = true;
|
||||
try {
|
||||
await sharePractiseData("shareCanvas", 2, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "海报生成失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
sharing.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
function onAudioEnded(s) {
|
||||
if (s.indexOf("比赛结束") >= 0) {
|
||||
onOver()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
void audioManager.warmAll();
|
||||
// audioManager.play("第一轮");
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("share-image", onClickShare);
|
||||
uni.$on("audioEnded", onAudioEnded);
|
||||
const result = await createPractiseAPI(total, 120, targetType.value);
|
||||
if (result) practiseId.value = result.id;
|
||||
await createPractise();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -140,9 +180,8 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off("share-image", onClickShare);
|
||||
uni.$off("audioEnded", onAudioEnded);
|
||||
audioManager.stopAll();
|
||||
endPractiseAPI();
|
||||
closeMatchWebSocket({ reason: "practice-leave" });
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -151,6 +190,7 @@ onBeforeUnmount(() => {
|
||||
:bgType="1"
|
||||
title="个人单组练习"
|
||||
:showBottom="!start && !scores.length"
|
||||
:onBack="exitPractise"
|
||||
>
|
||||
<view>
|
||||
<TestDistance v-if="!start && !practiseResult.id" />
|
||||
@@ -178,6 +218,7 @@ onBeforeUnmount(() => {
|
||||
:totalRound="start ? total / 4 : 0"
|
||||
:currentRound="scores.length % 3"
|
||||
:scores="scores"
|
||||
:isSvip="isSvip"
|
||||
/>
|
||||
<ScorePanel2 :arrows="scores" />
|
||||
<ScoreResult
|
||||
@@ -186,13 +227,7 @@ onBeforeUnmount(() => {
|
||||
:total="total"
|
||||
:onClose="onComplete"
|
||||
:result="practiseResult"
|
||||
:tipSrc="`../static/${
|
||||
practiseResult.details.filter(
|
||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||
).length < total
|
||||
? 'un'
|
||||
: ''
|
||||
}finish-tip.png`"
|
||||
:tipSrc="getResultTipSrc(practiseResult)"
|
||||
/>
|
||||
<canvas class="share-canvas" id="shareCanvas" type="2d"></canvas>
|
||||
</block>
|
||||
|
||||
+97
-54
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount, nextTick } from "vue";
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import Container from "@/components/Container.vue";
|
||||
import ShootProgress from "@/components/ShootProgress.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
@@ -14,10 +14,11 @@ import audioManager from "@/audioManager";
|
||||
|
||||
import {
|
||||
createPractiseAPI,
|
||||
startPractiseAPI,
|
||||
endPractiseAPI,
|
||||
getPractiseAPI,
|
||||
startPractiseAPI,
|
||||
} from "@/apis";
|
||||
import { connectMatchWebSocket, closeMatchWebSocket } from "@/matchWebsocket";
|
||||
import { sharePractiseData } from "@/canvas";
|
||||
import { wxShare, debounce } from "@/util";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
@@ -26,17 +27,19 @@ import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
import {onLoad} from "@dcloudio/uni-app";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const { user, device } = storeToRefs(store);
|
||||
|
||||
const start = ref(false);
|
||||
const scores = ref([]);
|
||||
const isSvip = ref(false);
|
||||
const total = 36;
|
||||
/** 当前练习中连续 10 环及以上计数,用于触发 tententen 音效 */
|
||||
const xRingStreak = ref(0);
|
||||
const practiseResult = ref({});
|
||||
const practiseId = ref("");
|
||||
const showGuide = ref(false);
|
||||
const targetType = ref(1);
|
||||
const sharing = ref(false);
|
||||
const exiting = ref(false);
|
||||
const RESULT_TIP_CDN = "https://static.shelingxingqiu.com/shootmini/static";
|
||||
|
||||
onLoad((options) => {
|
||||
if (options.target) {
|
||||
@@ -44,52 +47,64 @@ onLoad((options) => {
|
||||
}
|
||||
});
|
||||
|
||||
const createPractise = async () => {
|
||||
closeMatchWebSocket({ reason: "practice-recreate" });
|
||||
const result = await createPractiseAPI(
|
||||
total,
|
||||
3600,
|
||||
targetType.value,
|
||||
device.value.deviceId
|
||||
);
|
||||
if (result?.id) practiseId.value = result.id;
|
||||
if (!result?.serverAddr) {
|
||||
uni.showToast({
|
||||
title: "练习连接信息异常,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return null;
|
||||
}
|
||||
connectMatchWebSocket({
|
||||
serverAddr: result.serverAddr,
|
||||
matchId: result.id,
|
||||
userId: user.value.id,
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const beginPractise = async () => {
|
||||
if (!practiseId.value) {
|
||||
uni.showToast({
|
||||
title: "练习未创建,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
await startPractiseAPI(practiseId.value);
|
||||
return true;
|
||||
};
|
||||
|
||||
const onReady = async () => {
|
||||
await startPractiseAPI();
|
||||
const result = await beginPractise();
|
||||
if (!result) return;
|
||||
scores.value = [];
|
||||
xRingStreak.value = 0; // 新一局开始,重置 10 环及以上连续计数
|
||||
isSvip.value = false;
|
||||
start.value = true;
|
||||
audioManager.play("练习开始");
|
||||
};
|
||||
|
||||
const onOver = async () => {
|
||||
practiseResult.value = await getPractiseAPI(practiseId.value);
|
||||
const onOver = async (message) => {
|
||||
practiseResult.value = Array.isArray(message?.details)
|
||||
? message
|
||||
: await getPractiseAPI(practiseId.value);
|
||||
start.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 检测连续 10 环及以上是否达到 3 箭,达到则播放 tententen 音效
|
||||
* @param {boolean} isTenPlusRingShot - 本次射击是否为 10 环及以上
|
||||
*/
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function checkAndPlayTententen(isTenPlusRingShot) {
|
||||
if (isTenPlusRingShot) {
|
||||
xRingStreak.value += 1;
|
||||
// 连续 3 箭均为 10 环及以上,在环数播报入队后追加 tententen,避免播放顺序颠倒
|
||||
if (xRingStreak.value >= 3) {
|
||||
xRingStreak.value = 0;
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
} else {
|
||||
// 低于 10 环或未上靶则重置连续计数
|
||||
xRingStreak.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function onReceiveMessage(msg) {
|
||||
if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
const prevLen = scores.value.length;
|
||||
scores.value = msg.details;
|
||||
// 有新箭时取最后一箭判断是否 10 环及以上并检测连续计数
|
||||
if (scores.value.length > prevLen) {
|
||||
const latestArrow = scores.value[scores.value.length - 1];
|
||||
checkAndPlayTententen(isTenPlusRing(latestArrow));
|
||||
}
|
||||
isSvip.value = msg.sVip === true;
|
||||
scores.value = Array.isArray(msg.details) ? msg.details : scores.value;
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||
setTimeout(onOver, 1500);
|
||||
setTimeout(() => onOver(msg), 1500);
|
||||
}
|
||||
// messages.forEach((msg) => {
|
||||
// if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||
@@ -120,25 +135,57 @@ async function onComplete() {
|
||||
practiseResult.value = {};
|
||||
start.value = false;
|
||||
scores.value = [];
|
||||
xRingStreak.value = 0; // 重新开始练习,重置 10 环及以上连续计数
|
||||
const result = await createPractiseAPI(total, 3600);
|
||||
if (result) practiseId.value = result.id;
|
||||
isSvip.value = false;
|
||||
await createPractise();
|
||||
}
|
||||
}
|
||||
|
||||
async function exitPractise() {
|
||||
if (exiting.value) return;
|
||||
exiting.value = true;
|
||||
|
||||
try {
|
||||
if (practiseId.value && !practiseResult.value?.details) {
|
||||
await endPractiseAPI(practiseId.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to stop practice", error);
|
||||
} finally {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
|
||||
const getResultTipSrc = (result = {}) => {
|
||||
const validCount = (result.details || []).filter(
|
||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||
).length;
|
||||
return `${RESULT_TIP_CDN}/${validCount < total ? "2un" : ""}finish-tip.png`;
|
||||
};
|
||||
|
||||
const onClickShare = debounce(async () => {
|
||||
await sharePractiseData("shareCanvas", 3, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
if (sharing.value) return;
|
||||
sharing.value = true;
|
||||
try {
|
||||
await sharePractiseData("shareCanvas", 3, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "海报生成失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
sharing.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
void audioManager.warmAll();
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("share-image", onClickShare);
|
||||
const result = await createPractiseAPI(total, 3600, targetType.value);
|
||||
if (result) practiseId.value = result.id;
|
||||
await createPractise();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -148,7 +195,7 @@ onBeforeUnmount(() => {
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off("share-image", onClickShare);
|
||||
audioManager.stopAll();
|
||||
endPractiseAPI();
|
||||
closeMatchWebSocket({ reason: "practice-leave" });
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -157,6 +204,7 @@ onBeforeUnmount(() => {
|
||||
:bgType="1"
|
||||
title="日常耐力挑战"
|
||||
:showBottom="!start && !scores.length"
|
||||
:onBack="exitPractise"
|
||||
>
|
||||
<view>
|
||||
<TestDistance v-if="!start && !practiseResult.id" />
|
||||
@@ -179,6 +227,7 @@ onBeforeUnmount(() => {
|
||||
:currentRound="scores.length"
|
||||
:totalRound="start ? total : 0"
|
||||
:scores="scores"
|
||||
:isSvip="isSvip"
|
||||
/>
|
||||
<ScorePanel
|
||||
v-if="start"
|
||||
@@ -194,13 +243,7 @@ onBeforeUnmount(() => {
|
||||
:rowCount="9"
|
||||
:onClose="onComplete"
|
||||
:result="practiseResult"
|
||||
:tipSrc="`../static/${
|
||||
practiseResult.details.filter(
|
||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||
).length < total
|
||||
? '2un'
|
||||
: ''
|
||||
}finish-tip.png`"
|
||||
:tipSrc="getResultTipSrc(practiseResult)"
|
||||
/>
|
||||
<canvas class="share-canvas" id="shareCanvas" type="2d"></canvas>
|
||||
</block>
|
||||
|
||||
+20
-4
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import Guide from "@/components/Guide.vue";
|
||||
@@ -15,6 +15,8 @@ const { user, device, online } = storeToRefs(store);
|
||||
const data = ref({});
|
||||
const showTargetPicker = ref(false);
|
||||
const pendingPractiseType = ref("");
|
||||
const isSVip = computed(() => user.value.sVip === true);
|
||||
const isVip = computed(() => user.value.vip === true && !isSVip.value);
|
||||
|
||||
const goPractise = async (type) => {
|
||||
if (!canEenter(user.value, device.value, online.value)) return;
|
||||
@@ -49,7 +51,18 @@ onShow(async () => {
|
||||
<view>
|
||||
<view>
|
||||
<Avatar :rankLvl="user.rankLvl" :src="user.avatar" :size="30" />
|
||||
<text class="truncate">{{ user.nickName }}</text>
|
||||
<view
|
||||
:class="[
|
||||
'member-nickname',
|
||||
isVip ? 'member-nickname--vip' : '',
|
||||
isSVip ? 'member-nickname--svip' : '',
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ user.nickName }}</text>
|
||||
<text v-if="isSVip" class="member-nickname__shine">{{
|
||||
user.nickName
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>已练习打卡</text>
|
||||
@@ -132,12 +145,15 @@ onShow(async () => {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
.practise-data > view:first-child > view:first-child > text {
|
||||
.practise-data > view:first-child > view:first-child .member-nickname {
|
||||
color: #fff;
|
||||
margin-left: 10px;
|
||||
font-size: 16px;
|
||||
width: 120px;
|
||||
}
|
||||
.practise-data > view:first-child > view:first-child .member-nickname__text,
|
||||
.practise-data > view:first-child > view:first-child .member-nickname__shine {
|
||||
font-size: 16px;
|
||||
}
|
||||
.practise-data > view:first-child > view:last-child > text:nth-child(2) {
|
||||
color: #f7d247;
|
||||
margin: 0 3px;
|
||||
|
||||
+17
-17
@@ -13,7 +13,7 @@ import Container from "@/components/Container.vue";
|
||||
<view class="section">
|
||||
<view class="title">一、段位体系概述</view>
|
||||
<view class="text">
|
||||
我们的段位体系分为多个等级,从低到高依次为:倔强青铜、秩序白银、黄金王者、永恒钻石、最强王者、非凡王者、无双王者、绝世王者、至圣王者、荣耀王者和传奇王者。每个大段位下又分为若干小段位,玩家需要通过积累积分来提升段位。
|
||||
我们的段位体系分为多个等级,从低到高依次为:倔强青铜、秩序白银、荣耀黄金、永恒钻石、最强王者、非凡王者、无双王者、绝世王者、至圣王者、荣耀王者和传奇王者。每个大段位下又分为若干小段位,玩家需要通过积累积分来提升段位。
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -63,39 +63,39 @@ import Container from "@/components/Container.vue";
|
||||
<view class="table-row">
|
||||
<text>倔强青铜</text>
|
||||
<view>
|
||||
<text>青铜1*</text>
|
||||
<text>青铜2*</text>
|
||||
<text>青铜3*</text>
|
||||
<text>青铜1</text>
|
||||
<text>青铜2</text>
|
||||
<text>青铜3</text>
|
||||
</view>
|
||||
<text>每个小段位需要满 3星才能晋升到下一个段位,共9颗星。</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text>秩序白银</text>
|
||||
<view>
|
||||
<text>白铜1*</text>
|
||||
<text>白铜2*</text>
|
||||
<text>白铜3*</text>
|
||||
<text>白铜1</text>
|
||||
<text>白铜2</text>
|
||||
<text>白铜3</text>
|
||||
</view>
|
||||
<text>每个小段位需要满 3颗星才能晋升到下一个段位,共9颗星。</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text>黄金王者</text>
|
||||
<text>荣耀黄金</text>
|
||||
<view>
|
||||
<text>黄金1*</text>
|
||||
<text>黄金2*</text>
|
||||
<text>黄金3*</text>
|
||||
<text>黄金4*</text>
|
||||
<text>黄金1</text>
|
||||
<text>黄金2</text>
|
||||
<text>黄金3</text>
|
||||
<text>黄金4</text>
|
||||
</view>
|
||||
<text>每个小段位需要满4颗星才能晋升到下一个段位,共16颗星。</text>
|
||||
</view>
|
||||
<view class="table-row">
|
||||
<text>永恒钻石</text>
|
||||
<view>
|
||||
<text>钻石1*</text>
|
||||
<text>钻石2*</text>
|
||||
<text>钻石3*</text>
|
||||
<text>钻石4*</text>
|
||||
<text>钻石5*</text>
|
||||
<text>钻石1</text>
|
||||
<text>钻石2</text>
|
||||
<text>钻石3</text>
|
||||
<text>钻石4</text>
|
||||
<text>钻石5</text>
|
||||
</view>
|
||||
<text>每个小段位需要满5颗星才能晋升到下一个段位,共25颗星。</text>
|
||||
</view>
|
||||
|
||||
+47
-2
@@ -102,6 +102,8 @@ const buildDefaultMyData = () => ({
|
||||
userId: user.value.id,
|
||||
name: user.value.nickName,
|
||||
avatar: user.value.avatar,
|
||||
vip: user.value.vip,
|
||||
sVip: user.value.sVip,
|
||||
totalScore: 0,
|
||||
mvpCount: 0,
|
||||
tenRings: 0,
|
||||
@@ -154,6 +156,15 @@ const getRankUnit = (index = selectedIndex.value) => {
|
||||
return "次";
|
||||
};
|
||||
|
||||
const isMember = (item = {}) => item.vip === true || item.sVip === true;
|
||||
|
||||
const getMemberNicknameClass = (item = {}) => [
|
||||
"rank-list-player-name",
|
||||
"member-nickname",
|
||||
item.vip === true && item.sVip !== true ? "member-nickname--vip" : "",
|
||||
item.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
// 统一设置页面当前的视觉滚动状态,避免吸顶和顶部背景不同步。
|
||||
const syncScrollVisualState = (scrollTop = 0) => {
|
||||
currentScrollTop.value = scrollTop;
|
||||
@@ -441,7 +452,13 @@ const measureTabsMetrics = () => {
|
||||
</view>
|
||||
<Avatar :src="item.avatar" />
|
||||
<view class="rank-item-content">
|
||||
<text class="truncate">{{ item.name }}</text>
|
||||
<view v-if="isMember(item)" :class="getMemberNicknameClass(item)">
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="rank-list-player-name truncate">{{ item.name }}</text>
|
||||
<text>{{ formatLevelText(item) }}</text>
|
||||
</view>
|
||||
<text class="rank-item-integral">
|
||||
@@ -479,7 +496,23 @@ const measureTabsMetrics = () => {
|
||||
<text>{{ getDisplayMyRank(currentMyData) }}</text>
|
||||
<Avatar :src="currentMyData.avatar || user.avatar" />
|
||||
<view class="rank-item-content">
|
||||
<text class="truncate">{{ currentMyData.name || user.nickName }}</text>
|
||||
<view
|
||||
v-if="isMember(currentMyData)"
|
||||
:class="getMemberNicknameClass(currentMyData)"
|
||||
>
|
||||
<text class="member-nickname__text">
|
||||
{{ currentMyData.name || user.nickName }}
|
||||
</text>
|
||||
<text
|
||||
v-if="currentMyData.sVip === true"
|
||||
class="member-nickname__shine"
|
||||
>
|
||||
{{ currentMyData.name || user.nickName }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="rank-list-player-name truncate">
|
||||
{{ currentMyData.name || user.nickName }}
|
||||
</text>
|
||||
<text>{{ formatLevelText(currentMyData) }}</text>
|
||||
</view>
|
||||
<text class="rank-item-integral">
|
||||
@@ -653,6 +686,18 @@ const measureTabsMetrics = () => {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.rank-list-player-name {
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
margin-bottom: 3px;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.rank-list-player-name .member-nickname__text,
|
||||
.rank-list-player-name .member-nickname__shine {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rank-list-item > text:last-child {
|
||||
margin-right: 10px;
|
||||
width: 56px;
|
||||
|
||||
+136
-13
@@ -3,21 +3,23 @@ import { computed, ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import ModalDialog from "@/components/ModalDialog.vue";
|
||||
import { topThreeColors } from "@/constants";
|
||||
import {
|
||||
getDailyCountAPI,
|
||||
getSeasonList,
|
||||
getSeasonStats,
|
||||
getScoreRankList,
|
||||
getTenRingRankList,
|
||||
getMvpRankList,
|
||||
} from "@/apis";
|
||||
import { canEenter } from "@/util";
|
||||
import { canEenter, getLimitCountText, isLimitReached } from "@/util";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const store = useStore();
|
||||
const { user, device, online, game } = storeToRefs(store);
|
||||
const { getLvlName } = store;
|
||||
const { user, device, online, game, dailyCount } = storeToRefs(store);
|
||||
const { getLvlName, updateDailyCount } = store;
|
||||
|
||||
const defaultSeasonStats = {
|
||||
nickName: "",
|
||||
@@ -55,6 +57,21 @@ const rankLoading = ref(false);
|
||||
const scoreRankList = ref([]);
|
||||
const mvpRankList = ref([]);
|
||||
const tenRingRankList = ref([]);
|
||||
const showLimitModal = ref(false);
|
||||
const isSVip = computed(() => user.value.sVip === true);
|
||||
const isVip = computed(() => user.value.vip === true && !isSVip.value);
|
||||
const rankedLimitText = computed(() =>
|
||||
getLimitCountText("排位", dailyCount.value.ranked)
|
||||
);
|
||||
|
||||
const isMember = (item = {}) => item.vip === true || item.sVip === true;
|
||||
|
||||
const getMemberNicknameClass = (item = {}) => [
|
||||
"rank-preview-name",
|
||||
"member-nickname",
|
||||
item.vip === true && item.sVip !== true ? "member-nickname--vip" : "",
|
||||
item.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
// 根据接口返回结构提取榜单数组,兼容数组和对象两种返回形式。
|
||||
const getRankListFromResponse = (result) => {
|
||||
@@ -104,12 +121,39 @@ const toMatchPage = async (gameType, teamSize) => {
|
||||
uni.$showHint(1);
|
||||
return;
|
||||
}
|
||||
await uni.$checkAudio();
|
||||
const countData = await loadDailyCount();
|
||||
if (isLimitReached(countData.ranked)) {
|
||||
showLimitModal.value = true;
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/match-page?gameType=${gameType}&teamSize=${teamSize}`,
|
||||
});
|
||||
};
|
||||
|
||||
const closeLimitModal = () => {
|
||||
showLimitModal.value = false;
|
||||
};
|
||||
|
||||
const goVipPage = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.navigateTo({
|
||||
url: "/pages/member/be-vip",
|
||||
});
|
||||
};
|
||||
|
||||
const loadDailyCount = async () => {
|
||||
if (!user.value.id) return dailyCount.value;
|
||||
try {
|
||||
const result = await getDailyCountAPI();
|
||||
updateDailyCount(result);
|
||||
return result || dailyCount.value;
|
||||
} catch (error) {
|
||||
console.log("load daily count error", error);
|
||||
return dailyCount.value;
|
||||
}
|
||||
};
|
||||
|
||||
const toMyGrowthPage = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/my-growth",
|
||||
@@ -235,7 +279,10 @@ const onChangeSeason = async (seasonId, name) => {
|
||||
// 页面显示时先拿赛季列表,再拉当前赛季统计和默认榜单数据。
|
||||
onShow(async () => {
|
||||
try {
|
||||
const seasonResult = await getSeasonList();
|
||||
const [seasonResult] = await Promise.all([
|
||||
getSeasonList(),
|
||||
loadDailyCount(),
|
||||
]);
|
||||
seasonData.value = seasonResult.list || [];
|
||||
|
||||
if (!seasonData.value.length) {
|
||||
@@ -271,12 +318,17 @@ onShow(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="排位赛" :showBackToGame="true" :bgType="6">
|
||||
<Container
|
||||
:title="rankedLimitText ? rankedLimitText : '排位赛'"
|
||||
:titleStyle="rankedLimitText ? { fontSize: '24rpx', fontWeight: 'normal' } : {}"
|
||||
:showBackToGame="true"
|
||||
:bgType="6"
|
||||
>
|
||||
<view class="battle-types-box">
|
||||
<view class="battle-types">
|
||||
<view class="first">
|
||||
<image src="../static/rank/battle-choose.png" mode="widthFix" />
|
||||
<image class="star" src="../static/rank/star.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/rank/battle-choose.png" mode="widthFix" />
|
||||
<image class="star" src="https://static.shelingxingqiu.com/shootmini/static/rank/star.png" mode="widthFix" />
|
||||
</view>
|
||||
<image
|
||||
src="../static/rank/battle1v1.svg"
|
||||
@@ -314,7 +366,20 @@ onShow(async () => {
|
||||
:rankLvl="seasonStats.rankLvl"
|
||||
:size="30"
|
||||
/>
|
||||
<text>{{ seasonStats.nickName || user.nickName }}</text>
|
||||
<view
|
||||
:class="[
|
||||
'member-nickname',
|
||||
isVip ? 'member-nickname--vip' : '',
|
||||
isSVip ? 'member-nickname--svip' : '',
|
||||
]"
|
||||
>
|
||||
<text class="member-nickname__text">
|
||||
{{ seasonStats.nickName || user.nickName }}
|
||||
</text>
|
||||
<text v-if="isSVip" class="member-nickname__shine">
|
||||
{{ seasonStats.nickName || user.nickName }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="ranking-season"
|
||||
@@ -476,7 +541,13 @@ onShow(async () => {
|
||||
:style="{ borderColor: index < 3 ? topThreeColors[index] : '' }"
|
||||
/>
|
||||
<view>
|
||||
<text class="truncate">{{ item.name }}</text>
|
||||
<view v-if="isMember(item)" :class="getMemberNicknameClass(item)">
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="rank-preview-name truncate">{{ item.name }}</text>
|
||||
<text>{{ formatRankSubTitle(item) }}</text>
|
||||
</view>
|
||||
<text>{{ item.totalScore || 0 }}<text>分</text></text>
|
||||
@@ -499,7 +570,13 @@ onShow(async () => {
|
||||
:style="{ borderColor: index < 3 ? topThreeColors[index] : '' }"
|
||||
/>
|
||||
<view>
|
||||
<text class="truncate">{{ item.name }}</text>
|
||||
<view v-if="isMember(item)" :class="getMemberNicknameClass(item)">
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="rank-preview-name truncate">{{ item.name }}</text>
|
||||
<text>{{ formatRankSubTitle(item) }}</text>
|
||||
</view>
|
||||
<text>{{ item.mvpCount || 0 }}<text>次</text></text>
|
||||
@@ -522,7 +599,13 @@ onShow(async () => {
|
||||
:style="{ borderColor: index < 3 ? topThreeColors[index] : '' }"
|
||||
/>
|
||||
<view>
|
||||
<text class="truncate">{{ item.name }}</text>
|
||||
<view v-if="isMember(item)" :class="getMemberNicknameClass(item)">
|
||||
<text class="member-nickname__text">{{ item.name }}</text>
|
||||
<text v-if="item.sVip === true" class="member-nickname__shine">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="rank-preview-name truncate">{{ item.name }}</text>
|
||||
<text>{{ formatRankSubTitle(item) }}</text>
|
||||
</view>
|
||||
<text>{{ item.tenRings ?? item.TenRings ?? 0 }}<text>次</text></text>
|
||||
@@ -538,6 +621,14 @@ onShow(async () => {
|
||||
</view>
|
||||
</view>
|
||||
</Container>
|
||||
<ModalDialog
|
||||
:show="showLimitModal"
|
||||
:content="'今日排位赛次数已经用完\n开通会员可增加次数'"
|
||||
cancelText="知道了"
|
||||
confirmText="去开通"
|
||||
:onCancel="closeLimitModal"
|
||||
:onConfirm="goVipPage"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -579,8 +670,14 @@ onShow(async () => {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.user-info > text {
|
||||
.user-info > .member-nickname {
|
||||
margin-left: 15px;
|
||||
max-width: 220rpx;
|
||||
}
|
||||
|
||||
.user-info .member-nickname__text,
|
||||
.user-info .member-nickname__shine {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ranking-season {
|
||||
@@ -773,6 +870,17 @@ onShow(async () => {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.rank-preview-name {
|
||||
color: #fff9;
|
||||
font-size: 14px;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.rank-preview-name .member-nickname__text,
|
||||
.rank-preview-name .member-nickname__shine {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rank-item > view:nth-child(3) > text:last-child {
|
||||
color: #fff4;
|
||||
font-size: 13px;
|
||||
@@ -867,4 +975,19 @@ onShow(async () => {
|
||||
font-size: 10px !important;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
.flex-box{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.lf-text{
|
||||
font-size: 22rpx;
|
||||
color: #bf985e;
|
||||
}
|
||||
.rg-text{
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -49,8 +49,6 @@ const battleWay = ref(0);
|
||||
const lastToSomeoneShootKey = ref("");
|
||||
/** 控制设备离线提示弹窗的显示状态 */
|
||||
const showOfflineModal = ref(false);
|
||||
/** 记录每位玩家当前轮连续 10 环及以上次数,key 为 playerId,用于触发 tententen 音效 */
|
||||
const xRingStreaks = ref({});
|
||||
|
||||
/**
|
||||
* 监听设备在线状态,比赛进行中设备离线时弹窗提示用户
|
||||
@@ -86,7 +84,7 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
|
||||
start.value = battleInfo.status !== 0;
|
||||
|
||||
if (battleInfo.status === 0) {
|
||||
const readyRemain = (Date.now() - (battleInfo.createTime || Date.now())) / 1000;
|
||||
const readyRemain = (Date.now() - (battleInfo.serverTime || Date.now())) / 1000;
|
||||
if (readyRemain > 0 && readyRemain < 15) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-timer", 15 - readyRemain - 0.2);
|
||||
@@ -233,31 +231,6 @@ function onNewRound(msg, prevRound) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测指定射手连续 10 环及以上是否达到 3 箭,达到则在环数播报入队后追加 tententen 音效
|
||||
* @param {number} shooterId - 本次射手的 ID(取自 currentShooterId.value)
|
||||
* @param {boolean} isTenPlusRingShot - 本次射击是否为 10 环及以上
|
||||
*/
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function checkAndPlayTententen(shooterId, isTenPlusRingShot) {
|
||||
if (!shooterId) return;
|
||||
if (isTenPlusRingShot) {
|
||||
xRingStreaks.value[shooterId] = (xRingStreaks.value[shooterId] || 0) + 1;
|
||||
// 同一玩家连续 3 箭均为 10 环及以上,追加到环数音效队列尾部播放
|
||||
if (xRingStreaks.value[shooterId] >= 3) {
|
||||
xRingStreaks.value[shooterId] = 0;
|
||||
// nextTick 确保 HeaderProgress 的环数播报已入队后再追加 tententen,避免播放顺序颠倒
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
} else {
|
||||
// 低于 10 环或未上靶则重置该玩家的连续计数
|
||||
xRingStreaks.value[shooterId] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function onReceiveMessage(msg) {
|
||||
if (Array.isArray(msg)) return;
|
||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||
@@ -272,9 +245,9 @@ async function onReceiveMessage(msg) {
|
||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
showRoundTip.value = false;
|
||||
recoverData(msg, {arrowOnly: true});
|
||||
// 检测同一玩家连续三箭 10 环及以上,触发 tententen 音效
|
||||
// currentShooterId 在 ToSomeoneShoot 时写入,ShootResult 不会覆盖,可靠识别本次射手
|
||||
checkAndPlayTententen(currentShooterId.value, isTenPlusRing(msg.shootData));
|
||||
if (msg.shootData?.threeConsecutive10Rings === true) {
|
||||
nextTick(() => audioManager.play("tententen", false));
|
||||
}
|
||||
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
||||
// 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮
|
||||
const prevRound = currentRound.value;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { onShow } from "@dcloudio/uni-app";
|
||||
|
||||
import { getBattleAPI, getUserGameState } from "@/apis";
|
||||
import { debounce } from "@/util";
|
||||
import { returnToBattle } from "@/utils/matchReturn";
|
||||
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -18,12 +19,14 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
const loading = ref(false);
|
||||
const navigating = ref(false);
|
||||
|
||||
/** 统一获取当前环境 token,用于守卫:无有效 token 时不发起接口请求 */
|
||||
const getToken = () =>
|
||||
uni.getStorageSync(`${uni.getAccountInfoSync().miniProgram.envVersion}_token`);
|
||||
|
||||
onShow(async () => {
|
||||
navigating.value = false;
|
||||
if (user.value.id && getToken()) {
|
||||
setTimeout(async () => {
|
||||
const state = await getUserGameState();
|
||||
@@ -45,28 +48,30 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
const navigateOnce = (url) =>
|
||||
new Promise((resolve, reject) => {
|
||||
navigating.value = true;
|
||||
uni.navigateTo({
|
||||
url,
|
||||
success: resolve,
|
||||
fail: (error) => {
|
||||
navigating.value = false;
|
||||
reject(error);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const onClick = debounce(async () => {
|
||||
if (loading.value) return;
|
||||
if (loading.value || navigating.value) return;
|
||||
try {
|
||||
loading.value = true;
|
||||
const result = await getBattleAPI();
|
||||
if (result && result.matchId) {
|
||||
await uni.$checkAudio();
|
||||
if (result.mode <= 3) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-battle/index?battleId=${result.matchId}`,
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-battle?battleId=${result.matchId}`,
|
||||
});
|
||||
}
|
||||
await returnToBattle(result, navigateOnce);
|
||||
return;
|
||||
}
|
||||
if (game.value.roomID) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/battle-room?roomNumber=" + game.value.roomID,
|
||||
});
|
||||
await navigateOnce("/pages/battle-room?roomNumber=" + game.value.roomID);
|
||||
} else {
|
||||
updateGame(false, "");
|
||||
}
|
||||
@@ -91,9 +96,9 @@ onBeforeUnmount(() => {
|
||||
class="back-to-game"
|
||||
@click="onClick"
|
||||
>
|
||||
<image src="../../../static/back-to-game-bg.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/back-to-game-bg.png" mode="widthFix" />
|
||||
<block v-if="game.inBattle">
|
||||
<image src="../../../static/pk-icon.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/pk-icon.png" mode="widthFix" />
|
||||
<text>返回进行中的对局</text>
|
||||
</block>
|
||||
<block v-else-if="game.roomID">
|
||||
|
||||
@@ -31,7 +31,7 @@ const normalRounds = computed(() => {
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="guide-row">
|
||||
<image src="../../../static/shooter.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/shooter.png" mode="widthFix" />
|
||||
<view
|
||||
:style="{
|
||||
marginBottom: '10px',
|
||||
@@ -42,7 +42,7 @@ const normalRounds = computed(() => {
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<image src="../../../static/battle-header-melee.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/battle-header-melee.png" mode="widthFix" />
|
||||
<text>蓝队({{ bluePoints }})</text>
|
||||
<text>红队({{ redPoints }})</text>
|
||||
</view>
|
||||
@@ -51,7 +51,7 @@ const normalRounds = computed(() => {
|
||||
<view v-for="(result, index) in roundResults" :key="index">
|
||||
<block v-if="index + 1 > normalRounds">
|
||||
<image
|
||||
:src="RoundImages[`gold${index + 1 - normalRounds}`]"
|
||||
:src="RoundImages[`gold${result.goldRound || index + 1 - normalRounds}`]"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</block>
|
||||
@@ -86,7 +86,7 @@ const normalRounds = computed(() => {
|
||||
<view v-for="(result, index) in roundResults" :key="index">
|
||||
<block v-if="index + 1 > normalRounds">
|
||||
<image
|
||||
:src="RoundImages[`gold${index + 1 - normalRounds}`]"
|
||||
:src="RoundImages[`gold${result.goldRound || index + 1 - normalRounds}`]"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</block>
|
||||
|
||||
@@ -27,13 +27,21 @@ defineProps({
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const getMemberNicknameClass = (player = {}) => [
|
||||
"member-nickname",
|
||||
player.vip === true && player.sVip !== true ? "member-nickname--vip" : "",
|
||||
player.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
const isMember = (player = {}) => player.vip === true || player.sVip === true;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container" :style="{ paddingTop: showHeader ? '5px' : '0' }">
|
||||
<image
|
||||
v-if="showHeader"
|
||||
:src="`../../../static/battle-header${players.length ? '-melee' : ''}.png`"
|
||||
:src="`https://static.shelingxingqiu.com/shootmini/static/battle-header${players.length ? '-melee' : ''}.png`"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<view
|
||||
@@ -51,7 +59,16 @@ defineProps({
|
||||
}"
|
||||
>
|
||||
<Avatar :src="player.avatar" :rankLvl="player.rankLvl" :size="40" />
|
||||
<text class="player-name">{{ player.name }}</text>
|
||||
<view
|
||||
v-if="isMember(player)"
|
||||
:class="['player-name', ...getMemberNicknameClass(player)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ player.name }}</text>
|
||||
<text v-if="player.sVip === true" class="member-nickname__shine">
|
||||
{{ player.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="player-name">{{ player.name }}</text>
|
||||
</view>
|
||||
<image
|
||||
v-if="winner === 1"
|
||||
@@ -70,7 +87,16 @@ defineProps({
|
||||
}"
|
||||
>
|
||||
<Avatar :src="player.avatar" :rankLvl="player.rankLvl" :size="40" />
|
||||
<text class="player-name">{{ player.name }}</text>
|
||||
<view
|
||||
v-if="isMember(player)"
|
||||
:class="['player-name', ...getMemberNicknameClass(player)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ player.name }}</text>
|
||||
<text v-if="player.sVip === true" class="member-nickname__shine">
|
||||
{{ player.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="player-name">{{ player.name }}</text>
|
||||
</view>
|
||||
<image
|
||||
v-if="winner === 2"
|
||||
@@ -105,7 +131,16 @@ defineProps({
|
||||
:size="40"
|
||||
:rank="showRank ? index + 1 : 0"
|
||||
/>
|
||||
<text class="player-name">{{ player.name }}</text>
|
||||
<view
|
||||
v-if="isMember(player)"
|
||||
:class="['player-name', ...getMemberNicknameClass(player)]"
|
||||
>
|
||||
<text class="member-nickname__text">{{ player.name }}</text>
|
||||
<text v-if="player.sVip === true" class="member-nickname__shine">
|
||||
{{ player.name }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="player-name">{{ player.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -116,6 +151,7 @@ defineProps({
|
||||
.container {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.container > image:first-child {
|
||||
@@ -183,6 +219,13 @@ defineProps({
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
view.player-name {
|
||||
justify-content: center;
|
||||
}
|
||||
.player-name .member-nickname__text,
|
||||
.player-name .member-nickname__shine {
|
||||
font-size: 12px;
|
||||
}
|
||||
.left-winner-badge {
|
||||
position: absolute;
|
||||
width: 50px;
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||
import {
|
||||
ref,
|
||||
watch,
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
computed,
|
||||
nextTick,
|
||||
getCurrentInstance,
|
||||
} from "vue";
|
||||
import PointSwitcher from "./PointSwitcher.vue";
|
||||
import BowShotEffect from "@/components/BowShotEffect.vue";
|
||||
|
||||
import { MESSAGETYPES, MESSAGETYPESV2 } from "@/constants";
|
||||
import { simulShootAPI } from "@/apis";
|
||||
@@ -26,6 +35,14 @@ const props = defineProps({
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
redTeam: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
blueTeam: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
latestShotFlash: {
|
||||
type: Object,
|
||||
default: null,
|
||||
@@ -59,18 +76,56 @@ const timer = ref(null);
|
||||
const dirTimer = ref(null);
|
||||
const angle = ref(null);
|
||||
const circleColor = ref("");
|
||||
const shotEffect = ref(null);
|
||||
const hiddenRedLatestKey = ref("");
|
||||
const hiddenBlueLatestKey = ref("");
|
||||
const targetShaking = ref(false);
|
||||
const targetSize = ref({ width: 0, height: 0 });
|
||||
const shakeTimer = ref(null);
|
||||
const instance = getCurrentInstance();
|
||||
const ROUND_TIP_OFFSET_Y = -32;
|
||||
const EXPERIENCE_TIP_OFFSET_Y = -68;
|
||||
|
||||
function showShotFlash(flash) {
|
||||
const shootData = flash?.shootData;
|
||||
if (!shootData) return;
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
function buildShotEffectKey(team, shot, fallbackKey = "") {
|
||||
return (
|
||||
fallbackKey ||
|
||||
[
|
||||
team,
|
||||
shot?.playerId ?? "",
|
||||
shot?.x ?? "",
|
||||
shot?.y ?? "",
|
||||
shot?.ring ?? "",
|
||||
shot?.ringX ? 1 : 0,
|
||||
].join("-")
|
||||
);
|
||||
}
|
||||
|
||||
if (flash.team === "red") {
|
||||
function findShotPlayer(shot, team) {
|
||||
const players = team === "red" ? props.redTeam : props.blueTeam;
|
||||
return players.find((player) => String(player?.id) === String(shot?.playerId));
|
||||
}
|
||||
|
||||
function isSvipShot(shot, team) {
|
||||
return findShotPlayer(shot, team)?.sVip === true;
|
||||
}
|
||||
|
||||
function shouldPlayShotEffect(shot, team) {
|
||||
return !!shot && Number(shot.ring) > 0 && isSvipShot(shot, team);
|
||||
}
|
||||
|
||||
function clearTipTimer() {
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
timer.value = null;
|
||||
}
|
||||
|
||||
function showShotTip(team, shootData) {
|
||||
clearTipTimer();
|
||||
|
||||
if (team === "red") {
|
||||
latestOne.value = shootData;
|
||||
timer.value = setTimeout(() => {
|
||||
latestOne.value = null;
|
||||
timer.value = null;
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
@@ -78,9 +133,102 @@ function showShotFlash(flash) {
|
||||
bluelatestOne.value = shootData;
|
||||
timer.value = setTimeout(() => {
|
||||
bluelatestOne.value = null;
|
||||
timer.value = null;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function triggerShotEffect(team, shot, fallbackKey = "") {
|
||||
const key = buildShotEffectKey(team, shot, fallbackKey);
|
||||
|
||||
if (shotEffect.value?.team === "red") hiddenRedLatestKey.value = "";
|
||||
if (shotEffect.value?.team === "blue") hiddenBlueLatestKey.value = "";
|
||||
|
||||
if (team === "red") {
|
||||
latestOne.value = null;
|
||||
hiddenRedLatestKey.value = key;
|
||||
} else {
|
||||
bluelatestOne.value = null;
|
||||
hiddenBlueLatestKey.value = key;
|
||||
}
|
||||
|
||||
shotEffect.value = { key, team, shot };
|
||||
}
|
||||
|
||||
function completeShotEffect(key) {
|
||||
if (!shotEffect.value || shotEffect.value.key !== key) return;
|
||||
|
||||
const { team, shot } = shotEffect.value;
|
||||
if (team === "red") hiddenRedLatestKey.value = "";
|
||||
if (team === "blue") hiddenBlueLatestKey.value = "";
|
||||
shotEffect.value = null;
|
||||
showShotTip(team, shot);
|
||||
}
|
||||
|
||||
function shakeTarget() {
|
||||
targetShaking.value = false;
|
||||
if (shakeTimer.value) {
|
||||
clearTimeout(shakeTimer.value);
|
||||
shakeTimer.value = null;
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
targetShaking.value = true;
|
||||
shakeTimer.value = setTimeout(() => {
|
||||
targetShaking.value = false;
|
||||
shakeTimer.value = null;
|
||||
}, 260);
|
||||
});
|
||||
}
|
||||
|
||||
function updateTargetSize() {
|
||||
nextTick(() => {
|
||||
const query = instance?.proxy
|
||||
? uni.createSelectorQuery().in(instance.proxy)
|
||||
: uni.createSelectorQuery();
|
||||
|
||||
query
|
||||
.select(".target")
|
||||
.boundingClientRect((rect) => {
|
||||
const width = Number(rect?.width);
|
||||
const height = Number(rect?.height);
|
||||
if (!Number.isFinite(width) || !Number.isFinite(height)) return;
|
||||
if (width <= 0 || height <= 0) return;
|
||||
targetSize.value = { width, height };
|
||||
})
|
||||
.exec();
|
||||
});
|
||||
}
|
||||
|
||||
function handleWindowResize() {
|
||||
updateTargetSize();
|
||||
}
|
||||
|
||||
function shouldHideRedHit(index) {
|
||||
return !!hiddenRedLatestKey.value && index === props.scores.length - 1;
|
||||
}
|
||||
|
||||
function shouldHideBlueHit(index) {
|
||||
return !!hiddenBlueLatestKey.value && index === props.blueScores.length - 1;
|
||||
}
|
||||
|
||||
function showShotFlash(flash) {
|
||||
const shootData = flash?.shootData;
|
||||
if (!shootData) {
|
||||
hiddenRedLatestKey.value = "";
|
||||
hiddenBlueLatestKey.value = "";
|
||||
shotEffect.value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const team = flash.team === "red" ? "red" : "blue";
|
||||
if (shouldPlayShotEffect(shootData, team)) {
|
||||
triggerShotEffect(team, shootData, flash.key);
|
||||
return;
|
||||
}
|
||||
|
||||
showShotTip(team, shootData);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.latestShotFlash,
|
||||
(newVal) => {
|
||||
@@ -89,6 +237,26 @@ watch(
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.scores.length,
|
||||
(newLen, oldLen) => {
|
||||
if (newLen > oldLen) return;
|
||||
latestOne.value = null;
|
||||
hiddenRedLatestKey.value = "";
|
||||
if (shotEffect.value?.team === "red") shotEffect.value = null;
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.blueScores.length,
|
||||
(newLen, oldLen) => {
|
||||
if (newLen > oldLen) return;
|
||||
bluelatestOne.value = null;
|
||||
hiddenBlueLatestKey.value = "";
|
||||
if (shotEffect.value?.team === "blue") shotEffect.value = null;
|
||||
}
|
||||
);
|
||||
|
||||
const safeTargetRadius = computed(() => {
|
||||
const radius = Number(props.targetRadius);
|
||||
return Number.isFinite(radius) && radius > 0 ? radius : 20;
|
||||
@@ -159,6 +327,15 @@ function getHitStyle(shot) {
|
||||
};
|
||||
}
|
||||
|
||||
function getSvipHitBgStyle(shot) {
|
||||
const radius = currentHitRadiusPx.value;
|
||||
const point = getShotPoint(shot);
|
||||
|
||||
return {
|
||||
...getTargetPositionStyle(point, radius),
|
||||
};
|
||||
}
|
||||
|
||||
function getRoundTipStyle(shot) {
|
||||
const point = getShotPoint(shot, true);
|
||||
return getTargetPositionStyle(
|
||||
@@ -223,6 +400,8 @@ async function onReceiveMessage(message) {
|
||||
|
||||
onMounted(() => {
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
updateTargetSize();
|
||||
if (uni.onWindowResize) uni.onWindowResize(handleWindowResize);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -234,12 +413,17 @@ onBeforeUnmount(() => {
|
||||
clearTimeout(dirTimer.value);
|
||||
dirTimer.value = null;
|
||||
}
|
||||
if (shakeTimer.value) {
|
||||
clearTimeout(shakeTimer.value);
|
||||
shakeTimer.value = null;
|
||||
}
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
if (uni.offWindowResize) uni.offWindowResize(handleWindowResize);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container">
|
||||
<view :class="['container', { 'container--effecting': shotEffect }]">
|
||||
<view class="header" v-if="totalRound > 0">
|
||||
<text v-if="totalRound > 0" class="round-count">{{
|
||||
(currentRound > totalRound ? totalRound : currentRound) +
|
||||
@@ -247,7 +431,7 @@ onBeforeUnmount(() => {
|
||||
totalRound
|
||||
}}</text>
|
||||
</view>
|
||||
<view class="target">
|
||||
<view :class="['target', { 'target--shake': targetShaking }]">
|
||||
<view v-if="angle !== null" class="arrow-dir" :style="arrowStyle">
|
||||
<view :style="{ background: circleColor }">
|
||||
<image src="../../../static/dot-circle.png" mode="widthFix" />
|
||||
@@ -287,8 +471,20 @@ onBeforeUnmount(() => {
|
||||
}}<text v-if="bluelatestOne.ring">环</text></view
|
||||
>
|
||||
<block v-for="(bow, index) in scores" :key="index">
|
||||
<image
|
||||
v-if="
|
||||
pMode &&
|
||||
bow.ring > 0 &&
|
||||
isSvipShot(bow, 'red') &&
|
||||
!shouldHideRedHit(index)
|
||||
"
|
||||
class="svip-hit-bg"
|
||||
src="../../../static/vip/svip-xuan.png"
|
||||
:style="getSvipHitBgStyle(bow)"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<view
|
||||
v-if="bow.ring > 0"
|
||||
v-if="bow.ring > 0 && !shouldHideRedHit(index)"
|
||||
:class="`hit ${pMode ? 'b' : 's'}-point ${
|
||||
index === scores.length - 1 && latestOne ? 'pump-in' : ''
|
||||
}`"
|
||||
@@ -300,8 +496,20 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
</block>
|
||||
<block v-for="(bow, index) in blueScores" :key="index">
|
||||
<image
|
||||
v-if="
|
||||
pMode &&
|
||||
bow.ring > 0 &&
|
||||
isSvipShot(bow, 'blue') &&
|
||||
!shouldHideBlueHit(index)
|
||||
"
|
||||
class="svip-hit-bg"
|
||||
src="../../../static/vip/svip-xuan.png"
|
||||
:style="getSvipHitBgStyle(bow)"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<view
|
||||
v-if="bow.ring > 0"
|
||||
v-if="bow.ring > 0 && !shouldHideBlueHit(index)"
|
||||
:class="`hit ${pMode ? 'b' : 's'}-point ${
|
||||
index === blueScores.length - 1 && bluelatestOne ? 'pump-in' : ''
|
||||
}`"
|
||||
@@ -313,7 +521,17 @@ onBeforeUnmount(() => {
|
||||
<text v-if="pMode">{{ index + 1 }}</text>
|
||||
</view>
|
||||
</block>
|
||||
<image src="../../../static/bow-target.png" mode="widthFix" />
|
||||
<BowShotEffect
|
||||
:shot="shotEffect && shotEffect.shot"
|
||||
:playKey="shotEffect ? shotEffect.key : ''"
|
||||
:targetRadius="safeTargetRadius"
|
||||
:targetWidth="targetSize.width"
|
||||
:targetHeight="targetSize.height"
|
||||
:hitOffsetPx="currentHitRadiusPx"
|
||||
@impact="shakeTarget"
|
||||
@complete="completeShotEffect"
|
||||
/>
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/bow-target.png" mode="widthFix" />
|
||||
</view>
|
||||
<view class="footer">
|
||||
<PointSwitcher
|
||||
@@ -334,13 +552,22 @@ onBeforeUnmount(() => {
|
||||
height: calc(100vw - 30px);
|
||||
padding: 0px 15px;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.container--effecting {
|
||||
z-index: 10000;
|
||||
}
|
||||
.target {
|
||||
position: relative;
|
||||
margin: 10px;
|
||||
width: calc(100% - 20px);
|
||||
height: calc(100% - 20px);
|
||||
z-index: -1;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
transform-origin: center center;
|
||||
}
|
||||
.target--shake {
|
||||
animation: target-shake 0.26s ease-out;
|
||||
}
|
||||
.e-value {
|
||||
position: absolute;
|
||||
@@ -395,17 +622,26 @@ onBeforeUnmount(() => {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.svip-hit-bg {
|
||||
position: absolute;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
transform-origin: center center;
|
||||
animation: svip-hit-xuan 1.2s linear infinite;
|
||||
}
|
||||
.hit {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
z-index: 1;
|
||||
z-index: 2;
|
||||
color: #fff;
|
||||
transition: all 0.3s ease;
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.b-point {
|
||||
border: 1px solid #fff;
|
||||
z-index: 1;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
@@ -421,6 +657,20 @@ onBeforeUnmount(() => {
|
||||
transform: translate(-50%, -50%);*/
|
||||
margin-top: 2rpx;
|
||||
}
|
||||
@keyframes svip-hit-xuan {
|
||||
0% {
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%) rotate(0deg) scale(0.92);
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%) rotate(180deg) scale(1.08);
|
||||
}
|
||||
100% {
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%) rotate(360deg) scale(0.92);
|
||||
}
|
||||
}
|
||||
@keyframes target-pump-in {
|
||||
from {
|
||||
transform: translate(-50%, -50%) scale(2);
|
||||
@@ -430,6 +680,29 @@ onBeforeUnmount(() => {
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes target-shake {
|
||||
0% {
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
14% {
|
||||
transform: translate(-20rpx, 8rpx);
|
||||
}
|
||||
28% {
|
||||
transform: translate(16rpx, -8rpx);
|
||||
}
|
||||
44% {
|
||||
transform: translate(-12rpx, 6rpx);
|
||||
}
|
||||
64% {
|
||||
transform: translate(8rpx, -4rpx);
|
||||
}
|
||||
82% {
|
||||
transform: translate(-4rpx, 2rpx);
|
||||
}
|
||||
100% {
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
}
|
||||
.hit.pump-in {
|
||||
animation: target-pump-in 0.3s ease-out forwards;
|
||||
transform-origin: center center;
|
||||
@@ -457,6 +730,8 @@ onBeforeUnmount(() => {
|
||||
display: flex;
|
||||
margin-top: -40px;
|
||||
justify-content: flex-end;
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
}
|
||||
.footer > image {
|
||||
width: 40px;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import AppBackground from "./AppBackground.vue";
|
||||
import Header from "./Header.vue";
|
||||
@@ -7,7 +7,7 @@ import ScreenHint from "./ScreenHint.vue";
|
||||
import BackToGame from "./BackToGame.vue";
|
||||
import {laserAimAPI, getBattleAPI, matchGameAPI} from "@/apis";
|
||||
import { capsuleHeight, debounce } from "@/util";
|
||||
import AudioManager from "@/audioManager";
|
||||
import { returnToBattle } from "@/utils/matchReturn";
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
@@ -58,9 +58,6 @@ const isIOS = uni.getDeviceInfo().osName === "ios";
|
||||
const showHint = ref(false);
|
||||
const hintType = ref(0);
|
||||
const isLoading = ref(false);
|
||||
const audioInitProgress = ref(1);
|
||||
const audioProgress = ref(0);
|
||||
const audioTimer = ref(null);
|
||||
|
||||
const showGlobalHint = (type) => {
|
||||
hintType.value = type;
|
||||
@@ -71,55 +68,21 @@ const hideGlobalHint = () => {
|
||||
showHint.value = false;
|
||||
};
|
||||
|
||||
const restart = () => {
|
||||
uni.restartMiniProgram({
|
||||
path: "/pages/index",
|
||||
});
|
||||
};
|
||||
|
||||
const checkAudioProgress = async () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
audioInitProgress.value = AudioManager.getLoadProgress();
|
||||
if (audioInitProgress.value === 1) return resolve();
|
||||
audioTimer.value = setInterval(() => {
|
||||
audioProgress.value = AudioManager.getLoadProgress();
|
||||
if (audioProgress.value === 1) {
|
||||
setTimeout(() => {
|
||||
audioInitProgress.value = 1;
|
||||
}, 200);
|
||||
clearInterval(audioTimer.value);
|
||||
resolve();
|
||||
}
|
||||
}, 200);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const audioFinalProgress = computed(() => {
|
||||
const left = 1 - audioInitProgress.value;
|
||||
if (left <= 0) return 0;
|
||||
return Math.max(0, (audioProgress.value - audioInitProgress.value) / left);
|
||||
});
|
||||
|
||||
const loadingProgress = computed(() => {
|
||||
if (props.loading && audioInitProgress.value >= 1) return 1;
|
||||
return audioFinalProgress.value;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (audioTimer.value) clearInterval(audioTimer.value);
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
uni.$showHint = showGlobalHint;
|
||||
uni.$hideHint = hideGlobalHint;
|
||||
uni.$checkAudio = checkAudioProgress;
|
||||
showHint.value = false;
|
||||
});
|
||||
|
||||
const navigateTo = (url) =>
|
||||
new Promise((resolve, reject) => {
|
||||
uni.navigateTo({
|
||||
url,
|
||||
success: resolve,
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
|
||||
const backToGame = debounce(async () => {
|
||||
if (isLoading.value) return; // 防止重复点击
|
||||
|
||||
@@ -127,16 +90,7 @@ const backToGame = debounce(async () => {
|
||||
isLoading.value = true;
|
||||
const result = await getBattleAPI();
|
||||
if (result && result.matchId) {
|
||||
await checkAudioProgress();
|
||||
if (result.mode <= 3) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-battle/index?battleId=${result.matchId}`,
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-battle?battleId=${result.matchId}`,
|
||||
});
|
||||
}
|
||||
await returnToBattle(result, navigateTo);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取当前游戏失败:", error);
|
||||
@@ -233,13 +187,13 @@ const goCalibration = async () => {
|
||||
</view>
|
||||
</view>
|
||||
</ScreenHint>
|
||||
<view v-if="loading || audioInitProgress < 1" class="audio-progress">
|
||||
<view v-if="loading" class="audio-progress">
|
||||
<image
|
||||
src="https://static.shelingxingqiu.com/attachment/2025-11-26/deihtj15xjwcz3c1tx.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<view>
|
||||
<view :style="{ width: `${loadingProgress * 100}%` }">
|
||||
<view :style="{ width: '100%' }">
|
||||
<!-- <image
|
||||
src="https://static.shelingxingqiu.com/attachment/2025-11-24/degu91a7si77sg9jqv.png"
|
||||
mode="widthFix"
|
||||
@@ -247,8 +201,7 @@ const goCalibration = async () => {
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>{{ loading ? loadingText || "加载中..." : "若加载时间过长,请" }}</text>
|
||||
<button v-if="!loading" hover-class="none" @click="restart">点击这里重启</button>
|
||||
<text>{{ loadingText || "加载中..." }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -12,13 +12,13 @@ defineProps({
|
||||
const bubbleTypes = [
|
||||
"../../../static/long-bubble.png",
|
||||
"../../../static/long-bubble-middle.png",
|
||||
"../../../static/long-bubble-tall.png",
|
||||
"https://static.shelingxingqiu.com/shootmini/static/long-bubble-tall.png",
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container">
|
||||
<image src="../../../static/shooter.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/shooter.png" mode="widthFix" />
|
||||
<view>
|
||||
<image
|
||||
v-if="!noBg"
|
||||
|
||||
@@ -316,7 +316,7 @@ onBeforeUnmount(() => {
|
||||
width: 156rpx;
|
||||
height: 28rpx;
|
||||
font-weight: 400;
|
||||
font-size: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
line-height: 28rpx;
|
||||
|
||||
@@ -27,22 +27,22 @@ const getContentHeight = () => {
|
||||
<view class="scale-in" :style="{ height: getContentHeight() }">
|
||||
<image
|
||||
v-if="mode === 'normal'"
|
||||
src="../../../static/screen-hint-bg.png"
|
||||
src="https://static.shelingxingqiu.com/shootmini/static/screen-hint-bg.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<image
|
||||
v-if="mode === 'tall'"
|
||||
src="../../../static/coach-comment.png"
|
||||
src="https://static.shelingxingqiu.com/shootmini/static/coach-comment.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<image
|
||||
v-if="mode === 'square'"
|
||||
src="../../../static/prompt-bg-square.png"
|
||||
src="https://static.shelingxingqiu.com/shootmini/static/prompt-bg-square.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<image
|
||||
v-if="mode === 'small'"
|
||||
src="../../../static/finish-frame.png"
|
||||
src="https://static.shelingxingqiu.com/shootmini/static/finish-frame.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<slot />
|
||||
|
||||
@@ -17,6 +17,7 @@ const props = defineProps({
|
||||
const players = ref({});
|
||||
const currentTeam = ref(false);
|
||||
const firstName = ref("");
|
||||
const currentPlayer = ref(null);
|
||||
|
||||
// 抽出判断:当前队伍且该玩家排序为 0(队伍首位)
|
||||
const isFirst = (id) =>
|
||||
@@ -30,6 +31,18 @@ const getPos = (id) => {
|
||||
return sort * 40;
|
||||
};
|
||||
|
||||
const getMemberNicknameClass = () => [
|
||||
"current-shooter-name",
|
||||
"member-nickname",
|
||||
currentPlayer.value?.vip === true && currentPlayer.value?.sVip !== true
|
||||
? "member-nickname--vip"
|
||||
: "",
|
||||
currentPlayer.value?.sVip === true ? "member-nickname--svip" : "",
|
||||
];
|
||||
|
||||
const isCurrentPlayerMember = () =>
|
||||
currentPlayer.value?.vip === true || currentPlayer.value?.sVip === true;
|
||||
|
||||
const syncPlayers = () => {
|
||||
const nextPlayers = {};
|
||||
const shooterId = props.currentShooterId;
|
||||
@@ -40,12 +53,14 @@ const syncPlayers = () => {
|
||||
|
||||
currentTeam.value = !!shooterId && shooterIndex >= 0;
|
||||
firstName.value = "";
|
||||
currentPlayer.value = null;
|
||||
|
||||
if (currentTeam.value) {
|
||||
const target = nextTeam.splice(shooterIndex, 1)[0];
|
||||
if (target) {
|
||||
nextTeam.unshift(target);
|
||||
firstName.value = target.name || "";
|
||||
currentPlayer.value = target;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +108,20 @@ watch(
|
||||
>{{ isRed ? "红队" : "蓝队" }}</text
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentTeam && isCurrentPlayerMember()"
|
||||
:class="getMemberNicknameClass()"
|
||||
:style="{
|
||||
[isRed ? 'left' : 'right']: '-4rpx',
|
||||
}"
|
||||
>
|
||||
<text class="member-nickname__text">{{ firstName }}</text>
|
||||
<text v-if="currentPlayer?.sVip === true" class="member-nickname__shine">
|
||||
{{ firstName }}
|
||||
</text>
|
||||
</view>
|
||||
<text
|
||||
v-if="currentTeam"
|
||||
v-else-if="currentTeam"
|
||||
class="truncate"
|
||||
:style="{
|
||||
color: isRed ? '#ff6060' : '#5fadff',
|
||||
@@ -114,6 +141,17 @@ watch(
|
||||
height: 10rpx;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
.current-shooter-name {
|
||||
position: absolute;
|
||||
width: 80rpx;
|
||||
bottom: -100rpx;
|
||||
justify-content: center;
|
||||
}
|
||||
.current-shooter-name .member-nickname__text,
|
||||
.current-shooter-name .member-nickname__shine {
|
||||
font-size: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.container > text {
|
||||
position: absolute;
|
||||
font-size: 20rpx;
|
||||
|
||||
@@ -111,7 +111,7 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="isBattle" class="ready-timer">
|
||||
<image src="../../../static/test-tip.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/test-tip.png" mode="widthFix" />
|
||||
<view v-if="count >= 0">
|
||||
<text>具体正式比赛还有</text>
|
||||
<text>{{ count }}</text>
|
||||
|
||||
+295
-97
@@ -13,8 +13,15 @@ import TeamAvatars from "./components/TeamAvatars.vue";
|
||||
import ShootProgress2 from "./components/ShootProgress2.vue";
|
||||
import SModal from "./components/SModal.vue";
|
||||
import { laserCloseAPI, getBattleAPI } from "@/apis";
|
||||
import {
|
||||
closeMatchWebSocket,
|
||||
connectMatchWebSocket,
|
||||
MATCH_WS_AUDIO_ACK_EVENT,
|
||||
MATCH_WS_STATE_EVENT,
|
||||
} from "@/matchWebsocket";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import { getDirectionText } from "@/util";
|
||||
import { takeMatchReturnSnapshot } from "@/utils/matchReturn";
|
||||
import audioManager, {
|
||||
AUDIO_INTERRUPTION_BEGIN_EVENT,
|
||||
AUDIO_INTERRUPTION_END_EVENT,
|
||||
@@ -26,7 +33,7 @@ const store = useStore();
|
||||
const { user, online } = storeToRefs(store);
|
||||
|
||||
const DEFAULT_SHOOT_TIME = 15;
|
||||
const READY_SECONDS = 15;
|
||||
const DEFAULT_READY_TIME = 15;
|
||||
const READY_TIMER_EMIT_DELAY = 200;
|
||||
const RESTORE_DELAY = 300;
|
||||
const RESTORE_EMPTY_ID_RETRY_DELAY = 50;
|
||||
@@ -41,7 +48,14 @@ const AUDIO_TIMEOUT_PER_KEY = 2600;
|
||||
const AUDIO_TIMEOUT_MAX = 12000;
|
||||
const BATTLE_CANCEL_RETURN_DELAY = 2000;
|
||||
const ROUND_AUDIO_NAMES = ["一", "二", "三", "四", "五"];
|
||||
const X_RING_STREAKS_KEY = "team-battle-x-ring-streaks";
|
||||
const MATCH_READY_SNAPSHOT_PREFIX = "match-ready-snapshot:";
|
||||
const MATCH_STATUS_BY_TEXT = {
|
||||
MATCH_STATUS_READY: 0,
|
||||
MATCH_STATUS_STARTED: 1,
|
||||
MATCH_STATUS_END: 2,
|
||||
MATCH_STATUS_TIMEOUT: 3,
|
||||
MATCH_STATUS_UNEXPECTEDLY: 4,
|
||||
};
|
||||
const PROGRESS_ZERO_EVENT = "team-battle-progress-zero";
|
||||
const COUNTDOWN_READY_EVENT = "team-battle-countdown-ready";
|
||||
|
||||
@@ -67,9 +81,9 @@ const showRoundTip = ref(false);
|
||||
const isFinalShoot = ref(false);
|
||||
const matchStatus = ref(undefined);
|
||||
const shootTimeTotal = ref(DEFAULT_SHOOT_TIME);
|
||||
const readyTime = ref(DEFAULT_READY_TIME);
|
||||
const showOfflineModal = ref(false);
|
||||
const restoreLoading = ref(false);
|
||||
const xRingStreaks = ref({});
|
||||
|
||||
// 消息队列:只保存“待执行”的战况消息,页面展示统一由队列串行驱动。
|
||||
const battleQueue = ref([]);
|
||||
@@ -89,6 +103,10 @@ let restoreLoadingTimer = null;
|
||||
let pendingRoundAudio = false;
|
||||
// 一旦收到 BattleEnd,后续普通消息就不再进入队列。
|
||||
let battleEnded = false;
|
||||
let battleEndTaskRunning = false;
|
||||
let resultNavigationPending = false;
|
||||
let skipNextRestoreOnShow = false;
|
||||
let pendingReturnSnapshot = null;
|
||||
const handledMessageKeys = new Set();
|
||||
const handledMessageKeyOrder = [];
|
||||
const queuedMessageKeys = new Set();
|
||||
@@ -108,27 +126,88 @@ watch(online, (newVal, oldVal) => {
|
||||
});
|
||||
|
||||
// 统一把秒级或毫秒级时间戳转成毫秒,方便和本机时间比较。
|
||||
function loadXRingStreaks() {
|
||||
const cached = uni.getStorageSync(X_RING_STREAKS_KEY);
|
||||
xRingStreaks.value =
|
||||
cached && typeof cached === "object" && !Array.isArray(cached) ? cached : {};
|
||||
}
|
||||
|
||||
function saveXRingStreaks() {
|
||||
uni.setStorageSync(X_RING_STREAKS_KEY, xRingStreaks.value);
|
||||
}
|
||||
|
||||
function clearXRingStreaks() {
|
||||
xRingStreaks.value = {};
|
||||
uni.removeStorageSync(X_RING_STREAKS_KEY);
|
||||
}
|
||||
|
||||
function normalizeTimestamp(value) {
|
||||
const numberValue = Number(value || 0);
|
||||
if (!numberValue) return 0;
|
||||
return numberValue < 1000000000000 ? numberValue * 1000 : numberValue;
|
||||
}
|
||||
|
||||
function getReadyTime(battleInfo) {
|
||||
const value = Number(battleInfo?.readyTime);
|
||||
return Number.isFinite(value) && value > 0 ? value : DEFAULT_READY_TIME;
|
||||
}
|
||||
|
||||
function getReadyRemainingSeconds(battleInfo) {
|
||||
const total = getReadyTime(battleInfo);
|
||||
const countdownStartTime = normalizeTimestamp(battleInfo?.countdownStartTime);
|
||||
if (!countdownStartTime) return total;
|
||||
|
||||
const elapsed = Math.max(0, (Date.now() - countdownStartTime) / 1000);
|
||||
return Math.max(0, total - elapsed);
|
||||
}
|
||||
|
||||
function getReadySnapshotKey(matchId) {
|
||||
return `${MATCH_READY_SNAPSHOT_PREFIX}${String(matchId || "")}`;
|
||||
}
|
||||
|
||||
function normalizeBattleInfo(battleInfo) {
|
||||
if (!battleInfo || typeof battleInfo !== "object") return battleInfo;
|
||||
|
||||
const statusText = battleInfo.statusText || battleInfo.status_text;
|
||||
if (
|
||||
(battleInfo.status === undefined ||
|
||||
battleInfo.status === null ||
|
||||
battleInfo.status === "") &&
|
||||
MATCH_STATUS_BY_TEXT[statusText] !== undefined
|
||||
) {
|
||||
return {
|
||||
...battleInfo,
|
||||
status: MATCH_STATUS_BY_TEXT[statusText],
|
||||
};
|
||||
}
|
||||
|
||||
return battleInfo;
|
||||
}
|
||||
|
||||
function hasKnownStatus(battleInfo) {
|
||||
return !(
|
||||
battleInfo?.status === undefined ||
|
||||
battleInfo?.status === null ||
|
||||
battleInfo?.status === ""
|
||||
);
|
||||
}
|
||||
|
||||
function hasStartedSnapshot(battleInfo) {
|
||||
if (hasKnownStatus(battleInfo)) return Number(battleInfo.status) !== 0;
|
||||
|
||||
const current = battleInfo?.current || {};
|
||||
return !!(
|
||||
current.playerId ||
|
||||
current.startTime ||
|
||||
current.round ||
|
||||
(Array.isArray(battleInfo?.rounds) && battleInfo.rounds.length)
|
||||
);
|
||||
}
|
||||
|
||||
function takeReadySnapshot(matchId) {
|
||||
const key = getReadySnapshotKey(matchId);
|
||||
const snapshot = uni.getStorageSync(key);
|
||||
if (snapshot) uni.removeStorageSync(key);
|
||||
return normalizeBattleInfo(snapshot);
|
||||
}
|
||||
|
||||
function reconnectMatchServer(battleInfo) {
|
||||
const status = Number(battleInfo?.status);
|
||||
if ([2, 3, 4].includes(status)) return;
|
||||
if (!battleInfo?.serverAddr) return;
|
||||
|
||||
connectMatchWebSocket({
|
||||
serverAddr: battleInfo.serverAddr,
|
||||
matchId: battleInfo.matchId || battleId.value,
|
||||
userId: user.value.id,
|
||||
});
|
||||
}
|
||||
|
||||
// 从不同消息结构中提取服务端时间,作为恢复和去重的时间基准。
|
||||
function getServerTime(message) {
|
||||
return normalizeTimestamp(
|
||||
@@ -289,6 +368,10 @@ function hideRestoreLoading() {
|
||||
}
|
||||
|
||||
function showRestoreLoading() {
|
||||
if (start.value === false) {
|
||||
hideRestoreLoading();
|
||||
return;
|
||||
}
|
||||
clearRestoreLoadingTimer();
|
||||
restoreLoading.value = true;
|
||||
restoreLoadingTimer = setTimeout(() => {
|
||||
@@ -297,6 +380,16 @@ function showRestoreLoading() {
|
||||
}, RESTORE_LOADING_TIMEOUT);
|
||||
}
|
||||
|
||||
// 终局开始后作废恢复请求,避免恢复遮罩与结算跳转抢占画面。
|
||||
function cancelPendingBattleRestore() {
|
||||
restoreGeneration += 1;
|
||||
if (pendingRestoreTimer) {
|
||||
clearTimeout(pendingRestoreTimer);
|
||||
pendingRestoreTimer = null;
|
||||
}
|
||||
hideRestoreLoading();
|
||||
}
|
||||
|
||||
// 页面重置、离开或恢复快照时调用,统一清理队列、等待器、音频和进度条。
|
||||
function invalidateBattleQueue({ stopAudio = false, stopProgress = false } = {}) {
|
||||
// 提升队列代际并清空待执行消息,确保恢复快照时不会继续跑旧战况。
|
||||
@@ -316,7 +409,10 @@ function invalidateBattleQueue({ stopAudio = false, stopProgress = false } = {})
|
||||
function enqueueBattleMessage(message) {
|
||||
if (Array.isArray(message) || !message?.type) return;
|
||||
if (battleEnded && message.type !== MESSAGETYPESV2.BattleEnd) return;
|
||||
if (message.type === MESSAGETYPESV2.BattleEnd) battleEnded = true;
|
||||
if (message.type === MESSAGETYPESV2.BattleEnd) {
|
||||
battleEnded = true;
|
||||
cancelPendingBattleRestore();
|
||||
}
|
||||
|
||||
if (message.type === MESSAGETYPESV2.InvalidShot) {
|
||||
const receivedAt = Date.now();
|
||||
@@ -391,7 +487,9 @@ async function executeBattleTask(task, runId) {
|
||||
if (!task || !isQueueAlive(runId)) return;
|
||||
const type = task.type;
|
||||
|
||||
if (type === MESSAGETYPESV2.BattleStart) {
|
||||
if (type === MESSAGETYPESV2.AboutToStart) {
|
||||
applyBattleSnapshot(task.message, { restore: true });
|
||||
} else if (type === MESSAGETYPESV2.BattleStart) {
|
||||
await runBattleStartTask(task, runId);
|
||||
} else if (type === MESSAGETYPESV2.ToSomeoneShoot) {
|
||||
await runToSomeoneShootTask(task, runId);
|
||||
@@ -402,7 +500,7 @@ async function executeBattleTask(task, runId) {
|
||||
} else if (type === MESSAGETYPESV2.BattleEnd) {
|
||||
await runBattleEndTask(task, runId);
|
||||
} else if (type === MESSAGETYPESV2.InvalidShot) {
|
||||
await runInvalidShotTask(runId);
|
||||
await runInvalidShotTask(task, runId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +530,10 @@ function playAudioKeys(keys, { interrupt = false, timeout } = {}) {
|
||||
resolve();
|
||||
},
|
||||
};
|
||||
const timer = setTimeout(waiter.done, waitTime);
|
||||
const timer = setTimeout(() => {
|
||||
audioManager.recoverIfStale(expectedKey);
|
||||
waiter.done();
|
||||
}, waitTime);
|
||||
audioWaiters.add(waiter);
|
||||
audioManager.play(audioKeys, interrupt);
|
||||
});
|
||||
@@ -445,6 +546,24 @@ function onAudioEnded(key) {
|
||||
});
|
||||
}
|
||||
|
||||
function notifyMatchAudioAck(task) {
|
||||
const message = task?.message;
|
||||
if (
|
||||
message?.sequence === undefined ||
|
||||
message?.sequence === null ||
|
||||
message?.sequence === ""
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.$emit(MATCH_WS_AUDIO_ACK_EVENT, {
|
||||
matchId: message.matchId || battleId.value,
|
||||
sequence: message.sequence,
|
||||
matchWsType: message.matchWsType,
|
||||
matchWsTypeName: message.matchWsTypeName,
|
||||
});
|
||||
}
|
||||
|
||||
function handleBattleCovered() {
|
||||
if (pendingRestoreTimer) {
|
||||
clearTimeout(pendingRestoreTimer);
|
||||
@@ -459,6 +578,11 @@ function handleBattleRecovered() {
|
||||
scheduleRestoreLatestBattle();
|
||||
}
|
||||
|
||||
function closeBattleServer(reason) {
|
||||
if (battleEnded) return;
|
||||
closeMatchWebSocket({ reason });
|
||||
}
|
||||
|
||||
// 队伍信息优先用接口返回值;接口缺失时使用本地缓存,避免重进页面时头像为空。
|
||||
function loadTeamPlayers(teamInfo, storageKey) {
|
||||
if (Array.isArray(teamInfo?.players)) return [...teamInfo.players];
|
||||
@@ -523,6 +647,7 @@ function applyRestoreNewRoundSnapshot(battleInfo) {
|
||||
|
||||
// 回填比赛基础信息:队伍、比分、轮次、金箭状态等公共字段都在这里统一处理。
|
||||
function applyBattleBase(battleInfo) {
|
||||
battleInfo = normalizeBattleInfo(battleInfo);
|
||||
if (!battleInfo) return;
|
||||
if (battleInfo.matchId) battleId.value = battleInfo.matchId;
|
||||
if (battleInfo.status !== undefined) {
|
||||
@@ -653,7 +778,7 @@ function getBackendRemainingSeconds(battleInfo, total) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 计算当前倒计时剩余秒数:后端字段优先,其次按开始时间和当前时间补算。
|
||||
// 计算当前倒计时剩余秒数:后端字段优先,其次按 ACK 时间和当前时间补算。
|
||||
function getRemainingSeconds(battleInfo, task, options = {}) {
|
||||
const total = getShootTimeSeconds(battleInfo);
|
||||
const backendRemain = getBackendRemainingSeconds(battleInfo, total);
|
||||
@@ -661,8 +786,9 @@ function getRemainingSeconds(battleInfo, task, options = {}) {
|
||||
// 新轮首箭由后端 shootTime 定完整时长;没有明确剩余时间时,不扣前端轮次弹窗/语音耗时。
|
||||
if (options.fullDurationIfNoBackendRemain) return total;
|
||||
|
||||
const startTime = normalizeTimestamp(battleInfo?.current?.startTime);
|
||||
if (!startTime) return total;
|
||||
const ackTime = normalizeTimestamp(battleInfo?.current?.ackTime);
|
||||
console.log(11111111111111111111111111,ackTime)
|
||||
if (!ackTime) return total;
|
||||
|
||||
// 后端时间是准的,前端只根据语音耗时和接收延迟做近似补偿。
|
||||
// 但回前台的 API 快照不一定带“当前后端时间”,恢复场景优先用本机当前时间计算最新剩余秒数。
|
||||
@@ -671,7 +797,8 @@ function getRemainingSeconds(battleInfo, task, options = {}) {
|
||||
: task?.serverTime || getServerTime(battleInfo) || Date.now();
|
||||
const waitAfterReceive = task?.serverTime ? Date.now() - task.receivedAt : 0;
|
||||
const effectiveNow = anchorTime + waitAfterReceive;
|
||||
const elapsed = Math.max(0, (effectiveNow - startTime) / 1000);
|
||||
const elapsed = Math.max(0, (effectiveNow - ackTime) / 1000);
|
||||
console.log('剩余:', elapsed, waitAfterReceive, Math.max(0, Math.min(total, total - elapsed)))
|
||||
return Math.max(0, Math.min(total, total - elapsed));
|
||||
}
|
||||
|
||||
@@ -720,6 +847,7 @@ function stopProgressAfterMount() {
|
||||
// 待开局状态:清理比赛态展示,并恢复准备倒计时。
|
||||
function applyReadyState(battleInfo) {
|
||||
hideRestoreLoading();
|
||||
readyTime.value = getReadyTime(battleInfo);
|
||||
start.value = false;
|
||||
showRoundTip.value = false;
|
||||
currentShooterId.value = 0;
|
||||
@@ -731,17 +859,15 @@ function applyReadyState(battleInfo) {
|
||||
clearProgressZeroWaiters();
|
||||
cancelRoundTipDisplay();
|
||||
|
||||
const createTime = normalizeTimestamp(battleInfo?.createTime || Date.now());
|
||||
const readyElapsed = (Date.now() - createTime) / 1000;
|
||||
if (readyElapsed > 0 && readyElapsed < READY_SECONDS) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-timer", READY_SECONDS - readyElapsed - 0.2);
|
||||
}, READY_TIMER_EMIT_DELAY);
|
||||
}
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-timer", getReadyRemainingSeconds(battleInfo));
|
||||
}, READY_TIMER_EMIT_DELAY);
|
||||
}
|
||||
|
||||
// 快照恢复入口:只把页面拉到服务端最新状态,不重放已经发生过的语音。
|
||||
function applyBattleSnapshot(battleInfo, { restore = false, restoreEventType = 0 } = {}) {
|
||||
battleInfo = normalizeBattleInfo(battleInfo);
|
||||
if (!battleInfo) return;
|
||||
// 快照恢复只负责“把页面拉回最新状态”,不重放历史语音。
|
||||
applyBattleBase(battleInfo);
|
||||
if (battleInfo.status === 0) {
|
||||
@@ -749,6 +875,12 @@ function applyBattleSnapshot(battleInfo, { restore = false, restoreEventType = 0
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasStartedSnapshot(battleInfo)) {
|
||||
hideRestoreLoading();
|
||||
if (start.value === false) applyReadyState(battleInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
start.value = true;
|
||||
showRoundTip.value = false;
|
||||
|
||||
@@ -784,12 +916,12 @@ function applyBattleSnapshot(battleInfo, { restore = false, restoreEventType = 0
|
||||
// 开局任务:切换到正式比赛态,并播报“比赛开始”。
|
||||
async function runBattleStartTask(task, runId) {
|
||||
// 开赛任务只负责切换正式态并播“比赛开始”,后续进入队列顺序。
|
||||
clearXRingStreaks();
|
||||
applyBattleBase(task.message);
|
||||
start.value = true;
|
||||
pendingRoundAudio = true;
|
||||
updateShotInfo(task.message);
|
||||
await playAudioKeys("比赛开始", { interrupt: false });
|
||||
notifyMatchAudioAck(task);
|
||||
if (!isQueueAlive(runId)) return;
|
||||
}
|
||||
|
||||
@@ -843,11 +975,12 @@ async function runToSomeoneShootTask(task, runId) {
|
||||
});
|
||||
|
||||
await audioPromise;
|
||||
notifyMatchAudioAck(task);
|
||||
if (!isQueueAlive(runId)) return;
|
||||
|
||||
const remainingSeconds = getRemainingSeconds(battleInfo, task, {
|
||||
fullDurationIfNoBackendRemain: isRoundFirstShoot,
|
||||
});
|
||||
// 实时换人消息的倒计时由本条语音 ACK 驱动:后端收到 ACK 后才开始计时,
|
||||
// 因此前端也应从完整 shootTime 启动,不能扣除消息排队及 tententen/提示语音耗时。
|
||||
const remainingSeconds = getShootTimeSeconds(battleInfo);
|
||||
const countdown = getCountdownPayload(remainingSeconds, shootTimeTotal.value);
|
||||
markProgressDeadline(countdown);
|
||||
uni.$emit("update-remain", {
|
||||
@@ -858,29 +991,6 @@ async function runToSomeoneShootTask(task, runId) {
|
||||
});
|
||||
}
|
||||
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function updateXRingStreak(shooterId, isTenPlusRingShot) {
|
||||
if (!shooterId) return false;
|
||||
const id = String(shooterId);
|
||||
if (!isTenPlusRingShot) {
|
||||
xRingStreaks.value[id] = 0;
|
||||
saveXRingStreaks();
|
||||
return false;
|
||||
}
|
||||
|
||||
xRingStreaks.value[id] = (xRingStreaks.value[id] || 0) + 1;
|
||||
if (xRingStreaks.value[id] < 3) {
|
||||
saveXRingStreaks();
|
||||
return false;
|
||||
}
|
||||
xRingStreaks.value[id] = 0;
|
||||
saveXRingStreaks();
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildShootResultAudioKeys(shootData) {
|
||||
if (!shootData) return [];
|
||||
const audioKeys = [
|
||||
@@ -889,6 +999,9 @@ function buildShootResultAudioKeys(shootData) {
|
||||
if (shootData.angle !== null && shootData.angle !== undefined) {
|
||||
audioKeys.push(`向${getDirectionText(shootData.angle)}调整`);
|
||||
}
|
||||
if (shootData.threeConsecutive10Rings === true) {
|
||||
audioKeys.push("tententen");
|
||||
}
|
||||
return audioKeys;
|
||||
}
|
||||
|
||||
@@ -908,13 +1021,9 @@ async function runShootResultTask(task) {
|
||||
};
|
||||
}
|
||||
|
||||
const isTententen = updateXRingStreak(
|
||||
currentShooterId.value,
|
||||
isTenPlusRing(battleInfo.shootData)
|
||||
);
|
||||
const audioKeys = buildShootResultAudioKeys(battleInfo.shootData);
|
||||
if (isTententen) audioKeys.push("tententen");
|
||||
await playAudioKeys(audioKeys, { interrupt: false });
|
||||
notifyMatchAudioAck(task);
|
||||
}
|
||||
|
||||
// 新回合任务:展示上一回合结算弹窗,弹窗关闭后再允许下一轮继续。
|
||||
@@ -959,47 +1068,88 @@ async function runNewRoundTask(task, runId) {
|
||||
pendingRoundAudio = true;
|
||||
}
|
||||
|
||||
function navigateToBattleResultOnce(matchId) {
|
||||
const targetMatchId = matchId || battleId.value;
|
||||
if (!targetMatchId || resultNavigationPending) return false;
|
||||
|
||||
resultNavigationPending = true;
|
||||
battleEnded = true;
|
||||
cancelPendingBattleRestore();
|
||||
|
||||
uni.redirectTo({
|
||||
url: `/pages/friend-battle-result?battleId=${targetMatchId}`,
|
||||
fail: (err) => {
|
||||
resultNavigationPending = false;
|
||||
console.log("navigate to battle result failed:", err);
|
||||
},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// 终局任务:播放结束语音后,根据状态跳结果页或返回上一页。
|
||||
async function runBattleEndTask(task, runId) {
|
||||
const battleInfo = task.message;
|
||||
applyBattleBase(battleInfo);
|
||||
battleEnded = true;
|
||||
clearXRingStreaks();
|
||||
matchStatus.value = battleInfo.status;
|
||||
if (battleInfo.status === 4) {
|
||||
showRoundTip.value = true;
|
||||
currentBluePoint.value = 0;
|
||||
currentRedPoint.value = 0;
|
||||
if (resultNavigationPending) {
|
||||
notifyMatchAudioAck(task);
|
||||
return;
|
||||
}
|
||||
|
||||
// 终局语音必须完整播完,再决定跳转或返回。
|
||||
await playAudioKeys("比赛结束", { interrupt: false, timeout: AUDIO_TIMEOUT_MAX });
|
||||
if (!isQueueAlive(runId)) return;
|
||||
battleEndTaskRunning = true;
|
||||
try {
|
||||
const battleInfo = task.message;
|
||||
applyBattleBase(battleInfo);
|
||||
battleEnded = true;
|
||||
matchStatus.value = battleInfo.status;
|
||||
if (battleInfo.status === 4) {
|
||||
showRoundTip.value = true;
|
||||
currentBluePoint.value = 0;
|
||||
currentRedPoint.value = 0;
|
||||
}
|
||||
|
||||
if (matchStatus.value === 2) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/friend-battle-result?battleId=${battleId.value}`,
|
||||
});
|
||||
} else if (matchStatus.value === 4) {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, BATTLE_CANCEL_RETURN_DELAY);
|
||||
// 终局语音必须完整播完,再决定跳转或返回。
|
||||
await playAudioKeys("比赛结束", { interrupt: false, timeout: AUDIO_TIMEOUT_MAX });
|
||||
notifyMatchAudioAck(task);
|
||||
if (!isQueueAlive(runId)) return;
|
||||
|
||||
if (matchStatus.value === 2) {
|
||||
navigateToBattleResultOnce(battleId.value);
|
||||
} else if (matchStatus.value === 4) {
|
||||
const roomNumber = battleInfo.roomId || store.game.roomNumber || store.game.roomID;
|
||||
setTimeout(() => {
|
||||
if (roomNumber) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/battle-room?roomNumber=${encodeURIComponent(roomNumber)}&fromResult=1`,
|
||||
});
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}, BATTLE_CANCEL_RETURN_DELAY);
|
||||
}
|
||||
} finally {
|
||||
battleEndTaskRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 无效射击任务:弹 toast 并播报无效射击,不修改比赛主状态。
|
||||
async function runInvalidShotTask(runId) {
|
||||
async function runInvalidShotTask(task, runId) {
|
||||
if (!isQueueAlive(runId)) return;
|
||||
uni.showToast({
|
||||
title: "距离不足,无效",
|
||||
icon: "none",
|
||||
});
|
||||
await playAudioKeys("射击无效", { interrupt: false });
|
||||
notifyMatchAudioAck(task);
|
||||
}
|
||||
|
||||
// 回前台恢复入口:拉取服务端快照,处理结束态,然后继续消费增量队列。
|
||||
async function restoreLatestBattle() {
|
||||
if (!battleId.value) return;
|
||||
if (
|
||||
!battleId.value ||
|
||||
battleEnded ||
|
||||
battleEndTaskRunning ||
|
||||
resultNavigationPending
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const currentRestoreId = ++restoreGeneration;
|
||||
showRestoreLoading();
|
||||
|
||||
@@ -1013,6 +1163,7 @@ async function restoreLatestBattle() {
|
||||
console.log("restore latest battle failed:", err);
|
||||
}
|
||||
if (currentRestoreId !== restoreGeneration) return;
|
||||
result = normalizeBattleInfo(result);
|
||||
if (!result) {
|
||||
hideRestoreLoading();
|
||||
runBattleQueue();
|
||||
@@ -1028,16 +1179,12 @@ async function restoreLatestBattle() {
|
||||
const restoreEventType = Number(result?.eventType || 0);
|
||||
|
||||
if (result.status === 2) {
|
||||
clearXRingStreaks();
|
||||
hideRestoreLoading();
|
||||
uni.redirectTo({
|
||||
url: `/pages/friend-battle-result?battleId=${result.matchId}`,
|
||||
});
|
||||
battleEnded = true;
|
||||
if (!battleEndTaskRunning) navigateToBattleResultOnce(result.matchId);
|
||||
return;
|
||||
}
|
||||
if (result.status === 4) {
|
||||
clearXRingStreaks();
|
||||
}
|
||||
reconnectMatchServer(result);
|
||||
|
||||
if (restoreEventType === MESSAGETYPESV2.NewRound) {
|
||||
const prevRound = getRestorePrevRound(result);
|
||||
@@ -1067,6 +1214,8 @@ async function restoreLatestBattle() {
|
||||
}
|
||||
|
||||
function scheduleRestoreLatestBattle() {
|
||||
if (battleEnded || battleEndTaskRunning || resultNavigationPending) return;
|
||||
|
||||
if (pendingRestoreTimer) {
|
||||
clearTimeout(pendingRestoreTimer);
|
||||
pendingRestoreTimer = null;
|
||||
@@ -1083,6 +1232,18 @@ function scheduleRestoreLatestBattle() {
|
||||
}, RESTORE_EMPTY_ID_RETRY_DELAY);
|
||||
}
|
||||
|
||||
function onMatchSocketState(event) {
|
||||
if (event?.state !== "open" || event?.reconnected !== true) return;
|
||||
if (
|
||||
event.matchId &&
|
||||
battleId.value &&
|
||||
String(event.matchId) !== String(battleId.value)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
scheduleRestoreLatestBattle();
|
||||
}
|
||||
|
||||
// 页面统一的 socket 回调,只负责把消息送进战况队列。
|
||||
function onReceiveMessage(message) {
|
||||
enqueueBattleMessage(message);
|
||||
@@ -1091,10 +1252,13 @@ function onReceiveMessage(message) {
|
||||
// 新对局入口:彻底清空上一局残留的状态、队列和缓存。
|
||||
onLoad((options) => {
|
||||
console.log('重新进入了')
|
||||
const returnSnapshot = options.fromReturn ? takeMatchReturnSnapshot() : null;
|
||||
pendingReturnSnapshot = returnSnapshot;
|
||||
skipNextRestoreOnShow = false;
|
||||
// 新对局入口:把所有会串场的状态、队列、时间戳和缓存一次性清空。
|
||||
start.value = null;
|
||||
tips.value = "";
|
||||
battleId.value = options.battleId || "";
|
||||
battleId.value = returnSnapshot?.matchId || options.battleId || "";
|
||||
currentRound.value = 0;
|
||||
roundTipRound.value = 0;
|
||||
goldenRound.value = 0;
|
||||
@@ -1114,7 +1278,6 @@ onLoad((options) => {
|
||||
shootTimeTotal.value = DEFAULT_SHOOT_TIME;
|
||||
showOfflineModal.value = false;
|
||||
hideRestoreLoading();
|
||||
loadXRingStreaks();
|
||||
queueGeneration += 1;
|
||||
battleQueue.value = [];
|
||||
queueRunning.value = false;
|
||||
@@ -1123,6 +1286,8 @@ onLoad((options) => {
|
||||
restoreGeneration += 1;
|
||||
pendingRoundAudio = false;
|
||||
battleEnded = false;
|
||||
battleEndTaskRunning = false;
|
||||
resultNavigationPending = false;
|
||||
handledMessageKeys.clear();
|
||||
handledMessageKeyOrder.length = 0;
|
||||
queuedMessageKeys.clear();
|
||||
@@ -1132,6 +1297,15 @@ onLoad((options) => {
|
||||
store.updateShotInfo(0, 0);
|
||||
store.updateTips("");
|
||||
latestShotFlash.value = null;
|
||||
if (returnSnapshot) {
|
||||
skipNextRestoreOnShow = true;
|
||||
showRestoreLoading();
|
||||
return;
|
||||
}
|
||||
const readySnapshot = takeReadySnapshot(battleId.value);
|
||||
if (readySnapshot?.status === 0) {
|
||||
applyBattleSnapshot(readySnapshot, { restore: true });
|
||||
}
|
||||
scheduleRestoreLatestBattle();
|
||||
});
|
||||
|
||||
@@ -1146,11 +1320,20 @@ onMounted(async () => {
|
||||
uni.$on(AUDIO_INTERRUPTION_END_EVENT, handleBattleRecovered);
|
||||
uni.$on(PROGRESS_ZERO_EVENT, onProgressZero);
|
||||
uni.$on(COUNTDOWN_READY_EVENT, hideRestoreLoading);
|
||||
uni.$on(MATCH_WS_STATE_EVENT, onMatchSocketState);
|
||||
if (pendingReturnSnapshot) {
|
||||
const returnSnapshot = pendingReturnSnapshot;
|
||||
pendingReturnSnapshot = null;
|
||||
reconnectMatchServer(returnSnapshot);
|
||||
scheduleRestoreLatestBattle();
|
||||
}
|
||||
await laserCloseAPI();
|
||||
});
|
||||
|
||||
// 离开页面时清理监听、停止音频,并让当前队列整体失效。
|
||||
onBeforeUnmount(() => {
|
||||
restoreGeneration += 1;
|
||||
battleEndTaskRunning = false;
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: false,
|
||||
});
|
||||
@@ -1158,12 +1341,15 @@ onBeforeUnmount(() => {
|
||||
uni.$off("audioEnded", onAudioEnded);
|
||||
uni.$off(PROGRESS_ZERO_EVENT, onProgressZero);
|
||||
uni.$off(COUNTDOWN_READY_EVENT, hideRestoreLoading);
|
||||
uni.$off(MATCH_WS_STATE_EVENT, onMatchSocketState);
|
||||
if (pendingRestoreTimer) {
|
||||
clearTimeout(pendingRestoreTimer);
|
||||
pendingRestoreTimer = null;
|
||||
}
|
||||
pendingReturnSnapshot = null;
|
||||
hideRestoreLoading();
|
||||
invalidateBattleQueue({ stopAudio: true, stopProgress: true });
|
||||
closeBattleServer("team-battle-unmount");
|
||||
console.log('onBeforeUnmount', '页面卸载前')
|
||||
audioManager.stopAll();
|
||||
uni.$off(AUDIO_INTERRUPTION_BEGIN_EVENT, handleBattleCovered);
|
||||
@@ -1173,11 +1359,16 @@ onBeforeUnmount(() => {
|
||||
onHide(()=>{
|
||||
console.log('onHide', '页面大退')
|
||||
handleBattleCovered();
|
||||
closeBattleServer("team-battle-hide");
|
||||
})
|
||||
|
||||
// 每次回到前台都重新拉最新比赛快照,确保画面与后端一致。
|
||||
onShow(() => {
|
||||
console.log('onshow')
|
||||
if (skipNextRestoreOnShow) {
|
||||
skipNextRestoreOnShow = false;
|
||||
return;
|
||||
}
|
||||
scheduleRestoreLatestBattle();
|
||||
});
|
||||
</script>
|
||||
@@ -1196,7 +1387,12 @@ onShow(() => {
|
||||
:blueTeam="blueTeam"
|
||||
:winner="0"
|
||||
/>
|
||||
<TestDistance v-if="start === false" :guide="false" :isBattle="true"/>
|
||||
<TestDistance
|
||||
v-if="start === false"
|
||||
:guide="false"
|
||||
:isBattle="true"
|
||||
:count="readyTime"
|
||||
/>
|
||||
<!-- 比赛进行中显示:左右队伍、进度条、靶面和底部比分。 -->
|
||||
<view v-if="start" class="players-row">
|
||||
<TeamAvatars
|
||||
@@ -1219,6 +1415,8 @@ onShow(() => {
|
||||
:scores="scores"
|
||||
:blueScores="blueScores"
|
||||
:latestShotFlash="latestShotFlash"
|
||||
:redTeam="redTeam"
|
||||
:blueTeam="blueTeam"
|
||||
/>
|
||||
<BattleFooter
|
||||
v-if="start"
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Container from "./components/Container.vue";
|
||||
import BowTarget from "./components/BowTarget.vue";
|
||||
import Avatar from "./components/Avatar.vue";
|
||||
import { roundsName } from "@/constants";
|
||||
import { getBattleAPI } from "@/apis";
|
||||
const selected = ref(0);
|
||||
const redScores = ref([]);
|
||||
const blueScores = ref([]);
|
||||
const redTeam = ref([]);
|
||||
const blueTeam = ref([]);
|
||||
const tabs = ref([]);
|
||||
const players = ref([]);
|
||||
const data = ref({});
|
||||
|
||||
const loadArrows = (round) => {
|
||||
round.shoots[1].forEach((arrow) => {
|
||||
blueScores.value.push(arrow);
|
||||
});
|
||||
round.shoots[2].forEach((arrow) => {
|
||||
redScores.value.push(arrow);
|
||||
});
|
||||
};
|
||||
onLoad(async (options) => {
|
||||
if (!options.battleId) return;
|
||||
const result = await getBattleAPI(options.battleId || "57943107462893568");
|
||||
data.value = result;
|
||||
blueTeam.value = data.value.teams?.[1]?.players || [];
|
||||
redTeam.value = data.value.teams?.[2]?.players || [];
|
||||
blueTeam.value.forEach((p, index) => {
|
||||
players.value.push(p);
|
||||
players.value.push(redTeam.value[index]);
|
||||
});
|
||||
Object.values(data.value.rounds).forEach((round, index) => {
|
||||
if (round.ifGold) tabs.value.push(`决金箭`);
|
||||
else tabs.value.push(`第${roundsName[index + 1]}轮`);
|
||||
});
|
||||
selected.value = Number(options.selected || 0);
|
||||
onClickTab(selected.value);
|
||||
});
|
||||
const onClickTab = (index) => {
|
||||
selected.value = index;
|
||||
redScores.value = [];
|
||||
blueScores.value = [];
|
||||
loadArrows(data.value.rounds[index]);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container title="靶纸">
|
||||
<view class="container">
|
||||
<view>
|
||||
<view
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="index"
|
||||
@click="() => onClickTab(index)"
|
||||
:class="selected === index ? 'selected-tab' : ''"
|
||||
>
|
||||
{{ tab }}
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{ margin: '20px 0' }">
|
||||
<BowTarget
|
||||
:scores="redScores"
|
||||
:blueScores="blueScores"
|
||||
:redTeam="redTeam"
|
||||
:blueTeam="blueTeam"
|
||||
mode="team"
|
||||
/>
|
||||
</view>
|
||||
<view class="score-container">
|
||||
<view
|
||||
class="score-row"
|
||||
v-for="(player, index) in players"
|
||||
:key="index"
|
||||
:style="{
|
||||
justifyContent: index % 2 === 0 ? 'flex-end' : 'flex-start',
|
||||
}"
|
||||
>
|
||||
<Avatar
|
||||
:src="player.avatar"
|
||||
:borderColor="index % 2 === 0 ? '#64BAFF' : '#FF6767'"
|
||||
:size="36"
|
||||
/>
|
||||
<view>
|
||||
<view
|
||||
v-for="(score, index) in data.rounds[selected].shoots[
|
||||
index % 2 === 0 ? 1 : 2
|
||||
]"
|
||||
:key="index"
|
||||
class="score-item"
|
||||
>
|
||||
{{ score.ringX ? "X" : score.ring }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.container > view:nth-child(1) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
width: calc(100% - 20px);
|
||||
color: #fff9;
|
||||
padding: 10px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.container > view:nth-child(1)::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
color: transparent;
|
||||
}
|
||||
.container > view:nth-child(1) > view {
|
||||
border: 1px solid #fff9;
|
||||
border-radius: 20px;
|
||||
padding: 7px 10px;
|
||||
margin: 0 5px;
|
||||
font-size: 14px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.selected-tab {
|
||||
background-color: #fed847;
|
||||
border-color: #fed847 !important;
|
||||
color: #000;
|
||||
}
|
||||
.score-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 5px;
|
||||
width: calc(50% - 5px);
|
||||
padding-left: 5px;
|
||||
}
|
||||
.score-row > view:last-child {
|
||||
margin-left: 10px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, auto);
|
||||
gap: 5px;
|
||||
margin-right: 5px;
|
||||
min-width: 26%;
|
||||
}
|
||||
.score-item {
|
||||
background-image: url("../../static/score-bg.png");
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
color: #fed847;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 20px;
|
||||
width: 10vw;
|
||||
height: 10vw;
|
||||
}
|
||||
.score-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -286,7 +286,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<Container
|
||||
:bgType="isDistanceStage ? 9 : 10"
|
||||
:bgType="isDistanceStage ? 9 : 11"
|
||||
:showBottom="isDistanceStage"
|
||||
:scroll="!isShootingStage"
|
||||
>
|
||||
|
||||
+3
-4
@@ -13,13 +13,12 @@ const { updateUser } = store;
|
||||
|
||||
const toOrderPage = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/orders",
|
||||
url: "/pages/member/orders",
|
||||
});
|
||||
};
|
||||
|
||||
const toFristTryPage = async () => {
|
||||
if (canEenter(user.value, device.value, online.value, "/pages/first-try")) {
|
||||
await uni.$checkAudio();
|
||||
uni.navigateTo({
|
||||
url: "/pages/first-try",
|
||||
});
|
||||
@@ -27,7 +26,7 @@ const toFristTryPage = async () => {
|
||||
};
|
||||
const toBeVipPage = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/be-vip",
|
||||
url: "/pages/member/be-vip",
|
||||
});
|
||||
};
|
||||
const toMyGrowthPage = () => {
|
||||
@@ -136,7 +135,7 @@ const buildVersion = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : ''
|
||||
<text>点</text>
|
||||
</UserItem>
|
||||
<view class="my-grow" @click="toMyGrowthPage">
|
||||
<image src="../static/my-grow.png" mode="widthFix" />
|
||||
<image src="https://static.shelingxingqiu.com/shootmini/static/my-grow.png" mode="widthFix" />
|
||||
</view>
|
||||
<UserItem title="关于我们" :onClick="toAboutUsPage" />
|
||||
<UserItem
|
||||
|
||||
Reference in New Issue
Block a user