Merge branch 'new-race-mode' into test

This commit is contained in:
2026-05-09 16:01:21 +08:00
18 changed files with 1192 additions and 28 deletions

View File

@@ -9,12 +9,12 @@ defineProps({
<template>
<view class="container">
<image class="shooter2" src="../static/shooter2.png" mode="widthFix" />
<image class="shooter2" src="https://static.shelingxingqiu.com/shootmini/static/shooter2.png" mode="widthFix" />
<view class="bg-box">
<image
class="bg"
v-if="!noBg"
src="../static/long-bubble-border.png"
src="https://static.shelingxingqiu.com/shootmini/static/long-bubble-border.png"
mode="widthFix"
/>
<slot />
@@ -26,20 +26,21 @@ defineProps({
.container {
display: flex;
align-items: center;
padding: 0 15px;
padding: 0 26rpx 0 28rpx;
margin-bottom: 14rpx;
width: clac(100% - 30px);
width: clac(100% - 54rpx);
}
.container .shooter2 {
width: 150rpx;
height: 162rpx;
display: block;
width: 133rpx;
height: 144rpx;
}
.container .bg-box {
color: #fff;
font-size: 28rpx;
position: relative;
flex: 1;
min-height: 55px;
height: 128rpx;
display: flex;
align-items: center;
justify-content: center;

View File

@@ -273,7 +273,7 @@ onBeforeUnmount(() => {
/* 对战房间:整个胶囊作为分享按钮,靠右对齐 */
.battle-room-number {
margin-left: auto;
margin-right: 10rpx;
margin-right: 20rpx;
display: flex;
align-items: center;
justify-content: center;

View File

@@ -39,6 +39,9 @@
{
"path": "pages/battle-result"
},
{
"path": "pages/friend-battle-result"
},
{
"path": "pages/point-book-edit"
},

View File

@@ -117,7 +117,7 @@ const checkBowData = () => {
}deg)`,
}"
>
<view v-if="data.mvp && data.mvp[0].totalRings">
<view v-if="data.mvp && data.mvp.totalRings">
<image src="../static/title-mvp.png" mode="widthFix" />
<text
>斩获<text
@@ -127,7 +127,7 @@ const checkBowData = () => {
margin: '0 3px',
fontWeight: '600',
}"
>{{ data.mvp[0].totalRings }}</text
>{{ data.mvp.totalRings }}</text
></text
>
</view>

View File

@@ -42,6 +42,17 @@ const battleTitle = computed(() => {
return `${half}v${half}对抗赛`;
});
/** 靶纸尺寸cm由 URL 参数或 API 返回的 targetType 字段填充 */
const targetSize = ref(0);
/**
* 根据 targetSize 动态生成靶纸尺寸文本,如"40cm"
* 数据未就绪时显示 "--";数据来源:创建者取 URL 参数 target加入者取 API 返回的 targetType
*/
const targetSizeLabel = computed(() =>
targetSize.value ? `${targetSize.value}cm` : '--'
);
const ready = ref(false);
const allReady = ref(false);
const timer = ref(null);
@@ -56,6 +67,15 @@ async function refreshRoomData() {
const result = await getRoomAPI(roomNumber.value);
if (result.started) return;
room.value = result;
// 加入者通过 API 返回的 targetType 字段同步靶纸尺寸,并持久化到本地缓存
if (result.targetType) {
targetSize.value = result.targetType;
uni.setStorageSync(`targetSize_${roomNumber.value}`, result.targetType);
} else if (targetSize.value === 0) {
// API 无该字段时,从本地缓存兜底(如"返回房间"场景)
const stored = uni.getStorageSync(`targetSize_${roomNumber.value}`);
if (stored) targetSize.value = stored;
}
owner.value = {};
opponent.value = {};
const members = result.members || [];
@@ -241,9 +261,24 @@ const canClick = computed(() => {
return true;
});
/**
* 根据对战类型和人数动态生成分享文案
* 1v1 / 默认 → "星球论箭,来一决高下敢否?"
* 2v2 → "2v2对抗赛是兄弟来助我一把!"
* 3v3 → "3v3对抗赛来了马上发车!"
* 乱斗 → "热血乱斗赛,敢来争锋?"
*/
const shareTitle = computed(() => {
const { battleType, count } = room.value;
if (battleType === 2) return '热血乱斗赛,敢来争锋?';
if (battleType === 1 && count === 4) return '2v2对抗赛是兄弟来助我一把!';
if (battleType === 1 && count === 6) return '3v3对抗赛来了马上发车!';
return '星球论箭,来一决高下敢否?';
});
onShareAppMessage(() => {
return {
title: "邀请您进入房间对战",
title: shareTitle.value,
path: "/pages/friend-battle?roomID=" + roomNumber.value,
imageUrl: "",
};
@@ -269,6 +304,15 @@ onLoad(async (options) => {
roomNumber.value = options.roomNumber;
store.updateRoomNumber(options.roomNumber);
}
// 创建者通过 URL 参数 target1→20cm2→40cm初始化靶纸尺寸并持久化到本地缓存
if (options.target) {
targetSize.value = parseInt(options.target) * 20;
uni.setStorageSync(`targetSize_${roomNumber.value}`, targetSize.value);
} else if (roomNumber.value) {
// "返回房间"等无 target 参数的场景:从本地缓存恢复(待 refreshRoomData 进一步覆盖)
const stored = uni.getStorageSync(`targetSize_${roomNumber.value}`);
if (stored) targetSize.value = stored;
}
});
/**
@@ -299,11 +343,8 @@ onBeforeUnmount(() => {
<GuideTwo>
<view class="battle-guide">
<view class="guide-tips">
<text>弓箭手们人都到齐了吗?</text>
<text v-if="room.battleType === 1">{{
`${room.count / 2}v${room.count / 2}比赛即将开始!`
}}</text>
<text v-if="room.battleType === 2">大乱斗即将开始! </text>
<text class="guide-tips__target">请使用{{ targetSizeLabel }}全环靶</text>
<text class="guide-tips__warn">如果实际靶纸与选择靶纸不同将导致射箭无效</text>
</view>
</view>
</GuideTwo>
@@ -818,4 +859,23 @@ onBeforeUnmount(() => {
border: 1rpx solid #a3793f66;
color: #fed847;
}
.guide-tips__target {
font-weight: 400;
font-size: 26rpx;
color: rgba(255, 217, 71, 0.8);
}
.guide-tips__warn {
font-weight: 400;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.8);
margin-top: 6rpx;
}
.guide-tips {
display: flex;
flex-direction: column;
padding-left: 20rpx;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,8 @@ const { user } = storeToRefs(store);
const title = ref("");
const start = ref(null);
const battleId = ref("");
/** 对战模式1=好友约战 2=排位赛,用于结算页跳转判断 */
const way = ref(0);
const currentRound = ref(1);
const tips = ref("即将开始...");
const players = ref([]);
@@ -28,15 +30,13 @@ const playersScores = ref([]);
const halfTimeTip = ref(false);
const halfRest = ref(false);
const navigateToResult = () => {
uni.redirectTo({ url: `/pages/battle-result?battleId=${battleId.value}` });
};
function recoverData(battleInfo, { force = false } = {}) {
if (!battleInfo) return;
try {
if (battleInfo.way === 1) title.value = "好友约战 - 大乱斗";
if (battleInfo.way === 2) title.value = "排位赛 - 大乱斗";
// 保存 way 供结算跳转时使用
way.value = battleInfo.way ?? 0;
// 优先使用接口数据,否则使用缓存
if (battleInfo.teams?.[0]?.players) {
@@ -122,8 +122,9 @@ async function onReceiveMessage(msg) {
tips.value = "准备下半场";
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
setTimeout(() => {
// 全部跳转到新结算页
uni.redirectTo({
url: "/pages/battle-result?battleId=" + msg.matchId,
url: "/pages/friend-battle-result?battleId=" + msg.matchId,
});
}, 1000);
}

View File

@@ -38,10 +38,14 @@ const showRoundTip = ref(false);
const isFinalShoot = ref(false);
const matchStatus = ref(undefined);
const updateRemainSecond = ref(0);
/** 对战来源类型1=好友约战2=匹配对战),用于结算页分流 */
const battleWay = ref(0);
const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
try {
battleId.value = battleInfo.matchId;
// 存储对战来源,供结算跳转分流使用
if (battleInfo.way !== undefined) battleWay.value = battleInfo.way;
// 优先使用接口返回的队伍数据,如果没有则尝试从缓存读取(应对匹配刚完成接口未就绪的情况)
const t1 = battleInfo.teams?.[1] || {};
@@ -118,14 +122,16 @@ function onAudioEnded(s) {
uni.$emit("update-remain", {stop: false, value: updateRemainSecond.value, team: team});
}
if (s.indexOf("比赛结束") >= 0) {
console.log("比赛结束");
onBattleEnd()
}
}
function onBattleEnd() {
if (matchStatus.value === 2) {
// 全部跳转到新结算页
uni.redirectTo({
url: `/pages/battle-result?battleId=${battleId.value}`,
url: `/pages/friend-battle-result?battleId=${battleId.value}`,
});
}
}
@@ -202,12 +208,9 @@ onShow(async () => {
const result = await getBattleAPI(battleId.value);
if (!result) return;
if (result.status === 2) {
uni.showToast({
title: "比赛已结束",
icon: "none",
});
uni.navigateBack({
delta: 2,
// 比赛已结束(如切后台再回来):跳新结算页
uni.redirectTo({
url: `/pages/friend-battle-result?battleId=${result.matchId}`,
});
} else {
recoverData(result, {force: true});

View File

@@ -0,0 +1,11 @@
<svg width="156" height="58" viewBox="0 0 156 58" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="&#231;&#188;&#150;&#231;&#187;&#132; 5">
<rect id="&#231;&#159;&#169;&#229;&#189;&#162;&#229;&#164;&#135;&#228;&#187;&#189;" width="156" height="58" fill="url(#paint0_linear_1394_738459)"/>
</g>
<defs>
<linearGradient id="paint0_linear_1394_738459" x1="0" y1="87" x2="156" y2="87" gradientUnits="userSpaceOnUse">
<stop stop-color="#7E3627"/>
<stop offset="1" stop-color="#292826" stop-opacity="0.01"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 540 B

View File

@@ -0,0 +1,11 @@
<svg width="156" height="58" viewBox="0 0 156 58" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="&#231;&#188;&#150;&#231;&#187;&#132; 12">
<rect id="&#231;&#159;&#169;&#229;&#189;&#162;&#229;&#164;&#135;&#228;&#187;&#189;" width="156" height="58" fill="url(#paint0_linear_1394_738487)"/>
</g>
<defs>
<linearGradient id="paint0_linear_1394_738487" x1="0" y1="87" x2="156" y2="87" gradientUnits="userSpaceOnUse">
<stop stop-color="#573E25"/>
<stop offset="1" stop-color="#292826" stop-opacity="0.01"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 541 B

View File

@@ -0,0 +1,11 @@
<svg width="156" height="58" viewBox="0 0 156 58" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="&#231;&#188;&#150;&#231;&#187;&#132; 9">
<rect id="&#231;&#159;&#169;&#229;&#189;&#162;&#229;&#164;&#135;&#228;&#187;&#189;" width="156" height="58" fill="url(#paint0_linear_1394_738473)"/>
</g>
<defs>
<linearGradient id="paint0_linear_1394_738473" x1="0.251953" y1="86.9532" x2="156" y2="86.9532" gradientUnits="userSpaceOnUse">
<stop stop-color="#25476F"/>
<stop offset="1" stop-color="#292826" stop-opacity="0.01"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

BIN
src/static/mvp-blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
src/static/mvp-red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
src/static/mvp-tip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB