fix:好友约战首页调整完成

This commit is contained in:
2026-05-07 11:13:18 +08:00
parent e28424456f
commit 542ee5f031
3 changed files with 74 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ defineProps({
display: flex;
align-items: center;
padding: 0 15px;
margin-bottom: 14px;
margin-bottom: 14rpx;
width: clac(100% - 30px);
}
.container .shooter2 {

View File

@@ -59,6 +59,9 @@ const loading = ref(false);
const pointBook = ref(null);
const showProgress = ref(false);
const heat = ref(0);
/** 当前对战房间的房号,由 battle-room 页面通过 uni.$emit 传入 */
const battleRoomNumber = ref("");
const updateLoading = (value) => {
loading.value = value;
};
@@ -67,6 +70,14 @@ const updateHot = (value) => {
heat.value = value;
};
/**
* 接收 battle-room 页面发出的房间信息,更新房号展示
* @param {{ roomNumber: string }} info
*/
const updateBattleRoomInfo = (info) => {
battleRoomNumber.value = info.roomNumber || "";
};
onMounted(() => {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
@@ -83,9 +94,11 @@ onMounted(() => {
showProgress.value = true;
}
uni.$on("update-hot", updateHot);
uni.$on("battle-room-info", updateBattleRoomInfo);
});
onBeforeUnmount(() => {
uni.$off("update-hot", updateHot);
uni.$off("battle-room-info", updateBattleRoomInfo);
});
</script>
@@ -172,6 +185,16 @@ onBeforeUnmount(() => {
<view v-if="showProgress" class="battle-progress">
<HeaderProgress />
</view>
<!-- 对战房间:整个胶囊为分享按钮,点击任意区域均可触发分享 -->
<button
v-if="currentPage === 'pages/battle-room' && battleRoomNumber"
open-type="share"
hover-class="none"
class="battle-room-number"
>
<text class="battle-room-number__text">房号: {{ battleRoomNumber }}</text>
<image src="../static/share2.png" mode="widthFix" class="battle-room-number__icon" />
</button>
</view>
</template>
@@ -259,4 +282,37 @@ onBeforeUnmount(() => {
margin: 0 20rpx;
max-width: 300rpx;
}
/* 对战房间:整个胶囊作为分享按钮,靠右对齐 */
.battle-room-number {
margin-left: auto;
margin-right: 10rpx;
display: flex;
align-items: center;
justify-content: center;
width: 240rpx;
height: 64rpx;
background: rgba(0, 0, 0, 0.15);
border-radius: 96rpx;
border: 1rpx solid #5b5758;
flex-shrink: 0;
padding: 0;
line-height: normal;
}
/* 重置 button 默认边框 */
.battle-room-number::after {
border: none;
}
.battle-room-number__text {
width: 156rpx;
height: 28rpx;
font-weight: 400;
font-size: 20rpx;
color: #ffffff;
text-align: center;
line-height: 28rpx;
}
.battle-room-number__icon {
width: 25rpx;
height: 26rpx;
}
</style>