2025-05-23 21:20:38 +08:00
|
|
|
|
<script setup>
|
2025-06-15 22:01:06 +08:00
|
|
|
|
import { ref, onMounted } from "vue";
|
2025-07-05 17:24:52 +08:00
|
|
|
|
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-13 14:57:16 +08:00
|
|
|
|
import BackToGame from "@/components/BackToGame.vue";
|
2025-07-03 21:12:59 +08:00
|
|
|
|
import { getCurrentGameAPI } from "@/apis";
|
2025-07-05 17:24:52 +08:00
|
|
|
|
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-07-13 14:57:16 +08:00
|
|
|
|
showBackToGame: {
|
|
|
|
|
|
type: Boolean,
|
2025-07-16 15:55:45 +08:00
|
|
|
|
default: false,
|
2025-07-13 14:57:16 +08:00
|
|
|
|
},
|
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;
|
|
|
|
|
|
};
|
2025-07-14 13:39:10 +08:00
|
|
|
|
const hideGlobalHint = () => {
|
|
|
|
|
|
showHint.value = false;
|
|
|
|
|
|
};
|
2025-07-05 17:24:52 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
const deviceInfo = uni.getDeviceInfo();
|
|
|
|
|
|
isIos.value = deviceInfo.osName === "ios";
|
|
|
|
|
|
});
|
|
|
|
|
|
onShow(() => {
|
|
|
|
|
|
uni.$showHint = showGlobalHint;
|
2025-07-14 13:39:10 +08:00
|
|
|
|
uni.$hideHint = hideGlobalHint;
|
2025-07-05 17:24:52 +08:00
|
|
|
|
showHint.value = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
const backToGame = debounce(async () => {
|
2025-07-03 21:12:59 +08:00
|
|
|
|
const result = await getCurrentGameAPI();
|
2025-07-05 17:24:52 +08:00
|
|
|
|
});
|
2025-07-11 00:47:34 +08:00
|
|
|
|
const goBack = () => {
|
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
|
};
|
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-07-13 14:57:16 +08:00
|
|
|
|
<BackToGame v-if="showBackToGame" />
|
2025-06-15 22:01:06 +08:00
|
|
|
|
<view
|
|
|
|
|
|
class="content"
|
2025-07-03 21:12:59 +08:00
|
|
|
|
:style="{
|
2025-07-23 18:24:26 +08:00
|
|
|
|
height: isHome ? '100vh' : `calc(100vh - ${isIos ? 180 : 150}rpx)`,
|
2025-07-03 21:12:59 +08:00
|
|
|
|
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">
|
2025-07-11 00:47:34 +08:00
|
|
|
|
<view v-if="hintType === 1" class="tip-content">
|
2025-07-24 11:54:38 +08:00
|
|
|
|
<text>完成进行中的对局才能开启新的。</text>
|
|
|
|
|
|
<text>您有正在进行中的对局,是否进入?</text>
|
2025-07-03 21:12:59 +08:00
|
|
|
|
<view>
|
|
|
|
|
|
<button hover-class="none" @click="() => (showHint = false)">
|
|
|
|
|
|
不进入
|
|
|
|
|
|
</button>
|
2025-07-21 16:15:14 +08:00
|
|
|
|
<button hover-class="none" @click="backToGame">进入</button>
|
2025-07-03 21:12:59 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2025-07-11 00:47:34 +08:00
|
|
|
|
<view v-if="hintType === 2" class="tip-content">
|
|
|
|
|
|
<text>离开比赛可能会导致比赛失败,</text>
|
|
|
|
|
|
<text>确认离开吗?</text>
|
|
|
|
|
|
<view>
|
2025-07-21 16:15:14 +08:00
|
|
|
|
<button hover-class="none" @click="goBack">离开比赛</button>
|
2025-07-11 00:47:34 +08:00
|
|
|
|
<button hover-class="none" @click="() => (showHint = false)">
|
|
|
|
|
|
继续比赛
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2025-07-11 01:00:54 +08:00
|
|
|
|
<view v-if="hintType === 3" class="tip-content">
|
|
|
|
|
|
<text>今天不玩了吗?</text>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<button hover-class="none" @click="() => (showHint = false)">
|
|
|
|
|
|
取消
|
|
|
|
|
|
</button>
|
2025-07-21 16:15:14 +08:00
|
|
|
|
<button hover-class="none" @click="goBack">确认</button>
|
2025-07-11 01:00:54 +08:00
|
|
|
|
</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-11 00:47:34 +08:00
|
|
|
|
.tip-content {
|
2025-07-03 21:12:59 +08:00
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
2025-07-11 00:47:34 +08:00
|
|
|
|
.tip-content > text {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
.tip-content > view {
|
2025-07-03 21:12:59 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
|
margin-top: 50rpx;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
2025-07-11 00:47:34 +08:00
|
|
|
|
.tip-content > view > button {
|
2025-07-03 21:12:59 +08:00
|
|
|
|
padding: 12px;
|
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
|
background-color: #fff6;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
width: 45%;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
2025-07-21 16:15:14 +08:00
|
|
|
|
.tip-content > view > button:last-child {
|
2025-07-03 21:12:59 +08:00
|
|
|
|
background-color: #fed847;
|
|
|
|
|
|
color: #000;
|
|
|
|
|
|
}
|
2025-05-23 21:20:38 +08:00
|
|
|
|
</style>
|