胶囊高度适配

This commit is contained in:
kron
2025-08-07 10:48:05 +08:00
parent 91ab946699
commit aa815849b1
5 changed files with 28 additions and 26 deletions

View File

@@ -7,7 +7,7 @@ import ScreenHint from "@/components/ScreenHint.vue";
import BackToGame from "@/components/BackToGame.vue"; import BackToGame from "@/components/BackToGame.vue";
import { getCurrentGameAPI } from "@/apis"; import { getCurrentGameAPI } from "@/apis";
import { debounce } from "@/util"; import { debounce } from "@/util";
defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
default: "", default: "",
@@ -41,9 +41,9 @@ defineProps({
default: true, default: true,
}, },
}); });
const isIos = ref(true);
const showHint = ref(false); const showHint = ref(false);
const hintType = ref(0); const hintType = ref(0);
const capsuleHeight = ref(0);
const showGlobalHint = (type) => { const showGlobalHint = (type) => {
hintType.value = type; hintType.value = type;
showHint.value = true; showHint.value = true;
@@ -52,8 +52,8 @@ const hideGlobalHint = () => {
showHint.value = false; showHint.value = false;
}; };
onMounted(() => { onMounted(() => {
const deviceInfo = uni.getDeviceInfo(); const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
isIos.value = deviceInfo.osName === "ios"; capsuleHeight.value = menuBtnInfo.top - 9;
}); });
onUnmounted(() => { onUnmounted(() => {
// const pages = getCurrentPages(); // const pages = getCurrentPages();
@@ -74,7 +74,7 @@ const goBack = () => {
</script> </script>
<template> <template>
<view> <view :style="{ paddingTop: capsuleHeight + 'px' }">
<AppBackground :type="bgType" :bgColor="bgColor" /> <AppBackground :type="bgType" :bgColor="bgColor" />
<Header <Header
v-if="!isHome" v-if="!isHome"
@@ -86,7 +86,7 @@ const goBack = () => {
<view <view
class="content" class="content"
:style="{ :style="{
height: isHome ? '100vh' : `calc(100vh - ${isIos ? 190 : 160}rpx)`, height: `calc(100vh - ${capsuleHeight + (isHome ? 0 : 50)}px)`,
overflow, overflow,
}" }"
> >

View File

@@ -1,6 +1,5 @@
<script setup> <script setup>
import { ref, onMounted, onUnmounted } from "vue"; import { ref, onMounted, onUnmounted } from "vue";
const isIos = ref(true);
const props = defineProps({ const props = defineProps({
title: { title: {
@@ -30,8 +29,6 @@ const updateLoading = (value) => {
}; };
onMounted(() => { onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
const pages = getCurrentPages(); const pages = getCurrentPages();
const currentPage = pages[pages.length - 1]; const currentPage = pages[pages.length - 1];
if (currentPage.route === "pages/point-book-edit") { if (currentPage.route === "pages/point-book-edit") {
@@ -52,7 +49,7 @@ onUnmounted(() => {
</script> </script>
<template> <template>
<view class="container" :style="{ paddingTop: isIos ? '90rpx' : '60rpx' }"> <view class="container">
<view class="back-btn" @click="onClick"> <view class="back-btn" @click="onClick">
<image v-if="whiteBackArrow" src="../static/back.png" mode="widthFix" /> <image v-if="whiteBackArrow" src="../static/back.png" mode="widthFix" />
<image <image
@@ -107,7 +104,9 @@ onUnmounted(() => {
) )
}} }}
{{ {{
pointBook.bowtargetType.name.substring(pointBook.bowtargetType.name.length - 3) pointBook.bowtargetType.name.substring(
pointBook.bowtargetType.name.length - 3
)
}}</text }}</text
> >
</view> </view>
@@ -120,7 +119,7 @@ onUnmounted(() => {
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
width: 72vw; width: 72vw;
height: 100rpx; height: 50px;
/* margin-top: var(--status-bar-height); */ /* margin-top: var(--status-bar-height); */
padding-left: 15px; padding-left: 15px;
} }

View File

@@ -130,6 +130,7 @@ watch(
display: flex; display: flex;
align-items: center; align-items: center;
width: 72vw; width: 72vw;
height: 50px;
padding-left: 15px; padding-left: 15px;
color: #fff; color: #fff;
} }

View File

@@ -23,7 +23,6 @@ const { updateConfig, updateUser, updateDevice, updateRank, getLvlName } =
// 使用storeToRefs用于UI里显示保持响应性 // 使用storeToRefs用于UI里显示保持响应性
const { user, device, rankData } = storeToRefs(store); const { user, device, rankData } = storeToRefs(store);
const showModal = ref(false); const showModal = ref(false);
const isIos = ref(true);
const showGuide = ref(false); const showGuide = ref(false);
const toPage = (path) => { const toPage = (path) => {
@@ -88,8 +87,6 @@ onShow(async () => {
onMounted(async () => { onMounted(async () => {
uni.removeStorageSync("point-book-config"); uni.removeStorageSync("point-book-config");
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
const config = await getAppConfig(); const config = await getAppConfig();
updateConfig(config); updateConfig(config);
console.log("全局配置:", config); console.log("全局配置:", config);
@@ -105,7 +102,7 @@ const comingSoon = () => {
<template> <template>
<Container :isHome="true" :showBackToGame="true"> <Container :isHome="true" :showBackToGame="true">
<view class="container" :style="{ paddingTop: isIos ? '100rpx' : '70rpx' }"> <view class="container">
<UserHeader showRank :onSignin="() => (showModal = true)" /> <UserHeader showRank :onSignin="() => (showModal = true)" />
<view :style="{ padding: '12px 10px' }"> <view :style="{ padding: '12px 10px' }">
<view class="feature-grid"> <view class="feature-grid">

View File

@@ -7,15 +7,15 @@ const store = useStore();
const { user, rankData } = storeToRefs(store); const { user, rankData } = storeToRefs(store);
const { getLvlName } = store; const { getLvlName } = store;
const isIos = ref(true); const capsuleHeight = ref(0);
const selectedIndex = ref(0); const selectedIndex = ref(0);
const currentList = ref([]); const currentList = ref([]);
const myData = ref({}); const myData = ref({});
const addBg = ref(""); const addBg = ref("");
onMounted(async () => { onMounted(async () => {
const deviceInfo = uni.getDeviceInfo(); const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
isIos.value = deviceInfo.osName === "ios"; capsuleHeight.value = menuBtnInfo.top - 9;
currentList.value = rankData.value.rank; currentList.value = rankData.value.rank;
if (rankData.value.myRankPos) myData.value = rankData.value.myRankPos; if (rankData.value.myRankPos) myData.value = rankData.value.myRankPos;
}); });
@@ -47,7 +47,7 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
<view <view
class="header" class="header"
:style="{ :style="{
paddingTop: isIos ? '38px' : '25px', paddingTop: capsuleHeight + 'px',
}" }"
> >
<image <image
@@ -59,7 +59,9 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
<navigator open-type="navigateBack"> <navigator open-type="navigateBack">
<image class="header-back" src="../static/back.png" mode="widthFix" /> <image class="header-back" src="../static/back.png" mode="widthFix" />
</navigator> </navigator>
<text :style="{ opacity: addBg ? 1 : 0, color: '#fff' }"> <text
:style="{ opacity: addBg ? 1 : 0, color: '#fff', fontWeight: 'bold' }"
>
本赛季排行榜 本赛季排行榜
</text> </text>
</view> </view>
@@ -152,7 +154,10 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
</view> </view>
</view> </view>
<view class="my-rank-data" v-if="myData.userId"> <view class="my-rank-data" v-if="myData.userId">
<image src="https://static.shelingxingqiu.com/attachment/2025-08-05/dbuaf19pf7qd8ps0uh.png" mode="widthFix" /> <image
src="https://static.shelingxingqiu.com/attachment/2025-08-05/dbuaf19pf7qd8ps0uh.png"
mode="widthFix"
/>
<text>{{ myData.rank }}</text> <text>{{ myData.rank }}</text>
<Avatar :src="user.avatar" /> <Avatar :src="user.avatar" />
<view class="rank-item-content"> <view class="rank-item-content">
@@ -186,9 +191,9 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
} }
.header { .header {
width: 100%; width: 100%;
height: 60px; height: 50px;
display: flex; display: flex;
align-items: flex-center; align-items: center;
position: fixed; position: fixed;
top: 0; top: 0;
transition: all 0.3s ease; transition: all 0.3s ease;
@@ -197,7 +202,7 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
} }
.header text { .header text {
transition: all 0.3s ease; transition: all 0.3s ease;
line-height: 60px; line-height: 50px;
position: relative; position: relative;
} }
.rank-tabs { .rank-tabs {
@@ -346,7 +351,7 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
.header-back { .header-back {
width: 22px; width: 22px;
height: 22px; height: 22px;
margin: 20px 15px; margin: 0px 15px;
position: relative; position: relative;
} }
.bg-image { .bg-image {