Files
shoot-miniprograms/src/components/Container.vue

118 lines
2.5 KiB
Vue
Raw Normal View History

2025-05-23 21:20:38 +08:00
<script setup>
2025-06-15 22:01:06 +08:00
import { ref, onMounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
2025-05-23 21:20:38 +08:00
import AppBackground from "@/components/AppBackground.vue";
import Header from "@/components/Header.vue";
2025-07-02 17:21:44 +08:00
import ScreenHint from "@/components/ScreenHint.vue";
2025-07-03 21:12:59 +08:00
import { getCurrentGameAPI } from "@/apis";
import { debounce } from "@/util";
2025-05-23 21:20:38 +08:00
defineProps({
title: {
type: String,
default: "",
},
bgType: {
2025-05-27 12:38:39 +08:00
type: Number,
2025-05-23 21:20:38 +08:00
default: 0,
},
2025-06-17 16:42:53 +08:00
onBack: {
type: Function,
default: null,
},
2025-06-18 12:32:08 +08:00
overflow: {
type: String,
default: "auto",
},
2025-07-02 17:21:44 +08:00
isHome: {
type: Boolean,
default: false,
},
2025-05-23 21:20:38 +08:00
});
2025-06-15 22:01:06 +08:00
const isIos = ref(true);
2025-07-02 17:21:44 +08:00
const showHint = ref(false);
2025-07-03 21:12:59 +08:00
const hintType = ref(0);
const showGlobalHint = (type) => {
hintType.value = type;
2025-07-02 17:21:44 +08:00
showHint.value = true;
};
onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
});
onShow(() => {
uni.$showHint = showGlobalHint;
showHint.value = false;
});
const backToGame = debounce(async () => {
2025-07-03 21:12:59 +08:00
const result = await getCurrentGameAPI();
});
2025-05-23 21:20:38 +08:00
</script>
<template>
<view>
2025-06-05 17:43:22 +08:00
<AppBackground :type="bgType" />
2025-07-02 17:21:44 +08:00
<Header v-if="!isHome" :title="title" :onBack="onBack" />
2025-06-15 22:01:06 +08:00
<view
class="content"
2025-07-03 21:12:59 +08:00
:style="{
height: isHome ? '100vh' : `calc(100vh - ${isIos ? 98 : 95}px)`,
overflow,
}"
2025-06-15 22:01:06 +08:00
>
2025-05-23 21:20:38 +08:00
<slot></slot>
</view>
2025-07-03 21:12:59 +08:00
<ScreenHint :show="showHint">
<view v-if="hintType === 1" class="back-to-game">
<text>您还有正在进行中的对局是否进入</text>
<view>
<button hover-class="none" @click="backToGame">进入</button>
<button hover-class="none" @click="() => (showHint = false)">
不进入
</button>
</view>
</view>
2025-07-02 17:21:44 +08:00
</ScreenHint>
2025-05-23 21:20:38 +08:00
</view>
</template>
<style scoped>
.content {
2025-06-06 00:34:54 +08:00
width: 100vw;
2025-07-02 17:21:44 +08:00
height: 100vh;
2025-06-06 00:34:54 +08:00
overflow-x: hidden;
2025-06-02 14:42:07 +08:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
2025-06-21 12:59:59 +08:00
overflow-x: hidden;
2025-05-23 21:20:38 +08:00
}
2025-07-03 21:12:59 +08:00
.back-to-game {
flex-direction: column;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
width: 100%;
font-size: 14px;
}
.back-to-game > view {
display: flex;
align-items: center;
justify-content: space-around;
margin-top: 50rpx;
width: 100%;
}
.back-to-game > view > button {
padding: 12px;
border-radius: 20px;
background-color: #fff6;
color: #fff;
width: 45%;
font-size: 16px;
}
.back-to-game > view > button:first-child {
background-color: #fed847;
color: #000;
}
2025-05-23 21:20:38 +08:00
</style>