添加全局返回游戏
This commit is contained in:
60
src/components/BackToGame.vue
Normal file
60
src/components/BackToGame.vue
Normal file
@@ -0,0 +1,60 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
|
||||
const props = defineProps({
|
||||
signin: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
const show = ref(false);
|
||||
onShow(async () => {
|
||||
const isGaming = await isGamingAPI();
|
||||
show.value = isGaming;
|
||||
});
|
||||
const onClick = async () => {
|
||||
const result = await getCurrentGameAPI();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-if="show" class="back-to-game" @click="onClick">
|
||||
<image src="../static/back-to-game-bg.png" mode="widthFix" />
|
||||
<image src="../static/pk-icon.png" mode="widthFix" />
|
||||
<text>返回进行中的对局</text>
|
||||
<image src="../static/back.png" mode="widthFix" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.back-to-game {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
width: 56vw;
|
||||
left: calc(50% - 28vw);
|
||||
top: 12%;
|
||||
z-index: 999;
|
||||
}
|
||||
.back-to-game > image:first-child {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
.back-to-game > image:nth-child(2) {
|
||||
position: relative;
|
||||
width: 50px;
|
||||
}
|
||||
.back-to-game > text:nth-child(3) {
|
||||
position: relative;
|
||||
font-size: 14px;
|
||||
}
|
||||
.back-to-game > image:nth-child(4) {
|
||||
position: relative;
|
||||
width: 15px;
|
||||
margin-left: 5px;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
</style>
|
||||
@@ -214,7 +214,7 @@ const simulShoot2 = async () => {
|
||||
top: calcRealY(bow.y),
|
||||
backgroundColor: 'blue',
|
||||
}"
|
||||
>{{ bow.ring }}</view
|
||||
>{{ index + 1 }}</view
|
||||
>
|
||||
</block>
|
||||
<image src="../static/bow-target.png" mode="widthFix" />
|
||||
|
||||
@@ -4,6 +4,7 @@ import { onShow } from "@dcloudio/uni-app";
|
||||
import AppBackground from "@/components/AppBackground.vue";
|
||||
import Header from "@/components/Header.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import BackToGame from "@/components/BackToGame.vue";
|
||||
import { getCurrentGameAPI } from "@/apis";
|
||||
import { debounce } from "@/util";
|
||||
defineProps({
|
||||
@@ -27,6 +28,10 @@ defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
showBackToGame: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
const isIos = ref(true);
|
||||
const showHint = ref(false);
|
||||
@@ -55,6 +60,7 @@ const goBack = () => {
|
||||
<view>
|
||||
<AppBackground :type="bgType" />
|
||||
<Header v-if="!isHome" :title="title" :onBack="onBack" />
|
||||
<BackToGame v-if="showBackToGame" />
|
||||
<view
|
||||
class="content"
|
||||
:style="{
|
||||
@@ -66,7 +72,9 @@ const goBack = () => {
|
||||
</view>
|
||||
<ScreenHint :show="showHint">
|
||||
<view v-if="hintType === 1" class="tip-content">
|
||||
<text>完成进行中的对局才能开启新的。您有正在进行中的对局,是否进入?</text>
|
||||
<text
|
||||
>完成进行中的对局才能开启新的。您有正在进行中的对局,是否进入?</text
|
||||
>
|
||||
<view>
|
||||
<button hover-class="none" @click="backToGame">进入</button>
|
||||
<button hover-class="none" @click="() => (showHint = false)">
|
||||
|
||||
@@ -56,11 +56,11 @@ watch(
|
||||
|
||||
watch(
|
||||
() => props.start,
|
||||
(newVal, oldVal) => {
|
||||
if (newVal === false) {
|
||||
(newVal) => {
|
||||
if (!newVal && timer.value) {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
}
|
||||
if (!oldVal && newVal === true) {
|
||||
if (newVal) {
|
||||
remain.value = props.total;
|
||||
// setTimeout(() => {
|
||||
timer.value = setInterval(() => {
|
||||
@@ -81,7 +81,15 @@ watch(
|
||||
);
|
||||
|
||||
const updateRemain = (value) => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
remain.value = Math.floor(value);
|
||||
timer.value = setInterval(() => {
|
||||
if (remain.value > 0) {
|
||||
remain.value--;
|
||||
} else {
|
||||
props.onTimeIsUp();
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user