fix:更新约战头部tip模块样式

This commit is contained in:
2026-05-07 18:26:52 +08:00
parent 8c66ef78c6
commit d2dc6c51cf
3 changed files with 56 additions and 10 deletions

View File

@@ -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

@@ -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 || [];
@@ -269,6 +289,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 +328,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 +844,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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 25 KiB