fix:更新约战头部tip模块样式
This commit is contained in:
@@ -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 参数 target(1→20cm,2→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>
|
||||
|
||||
Reference in New Issue
Block a user