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

173 lines
3.8 KiB
Vue
Raw Normal View History

2025-07-02 15:57:58 +08:00
<script setup>
2025-08-25 13:47:32 +08:00
import { ref, onMounted, onBeforeUnmount } from "vue";
2025-07-02 15:57:58 +08:00
const props = defineProps({
2025-07-06 00:42:10 +08:00
isFinal: {
type: Boolean,
default: false,
2025-07-02 15:57:58 +08:00
},
round: {
type: Number,
default: 0,
},
bluePoint: {
type: Number,
default: 0,
},
redPoint: {
type: Number,
default: 0,
},
roundData: {
type: Object,
default: () => ({}),
},
2025-07-06 00:42:10 +08:00
onAutoClose: {
type: Function,
default: () => {},
},
2025-07-02 15:57:58 +08:00
});
2025-08-20 18:30:02 +08:00
const count = ref(props.isFinal ? 10 : 3);
2025-07-02 15:57:58 +08:00
const tiemr = ref(null);
2025-07-06 00:42:10 +08:00
function startCount() {
2025-07-02 15:57:58 +08:00
if (tiemr.value) clearInterval(tiemr.value);
tiemr.value = setInterval(() => {
2025-07-06 00:42:10 +08:00
if (count.value === 0) {
clearInterval(tiemr.value);
props.onAutoClose();
} else count.value -= 1;
2025-07-02 15:57:58 +08:00
}, 1000);
2025-07-06 00:42:10 +08:00
}
onMounted(() => {
startCount();
2025-07-02 15:57:58 +08:00
});
2025-08-25 13:47:32 +08:00
onBeforeUnmount(() => {
2025-07-02 15:57:58 +08:00
if (tiemr.value) clearInterval(tiemr.value);
});
</script>
<template>
<view class="round-end-tip">
2025-08-20 18:30:02 +08:00
<text>{{ round }}轮射箭结束</text>
2025-07-06 00:42:10 +08:00
<block v-if="!isFinal">
2025-07-25 15:18:46 +08:00
<view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0">
2025-07-11 12:03:55 +08:00
<text>本轮蓝队</text>
2025-07-02 15:57:58 +08:00
<text>{{
(roundData.shoots[1] || []).reduce(
2025-07-02 15:57:58 +08:00
(last, next) => last + next.ring,
0
)
}}</text>
2025-07-11 12:03:55 +08:00
<text>红队</text>
2025-07-02 15:57:58 +08:00
<text>{{
(roundData.shoots[2] || []).reduce(
2025-07-02 15:57:58 +08:00
(last, next) => last + next.ring,
0
)
}}</text>
<text></text>
</view>
2025-07-25 15:18:46 +08:00
<text
v-if="bluePoint === 0 && redPoint === 0"
:style="{ marginTop: '20px' }"
>
2025-07-25 16:47:07 +08:00
连续3个来回双方均无人射箭比赛取消
2025-07-25 09:59:54 +08:00
</text>
2025-07-25 15:18:46 +08:00
<text v-if="bluePoint !== 0 && bluePoint === redPoint">
2025-07-02 15:57:58 +08:00
红队蓝队各得<text :style="{ color: '#fed847', margin: '0 5px' }">{{
redPoint
}}</text
>
</text>
<text v-if="bluePoint > redPoint">
蓝队获胜<text :style="{ color: '#fed847', margin: '0 5px' }">{{
bluePoint
}}</text
>
</text>
<text v-if="bluePoint < redPoint">
红队获胜<text :style="{ color: '#fed847', margin: '0 5px' }">{{
redPoint
}}</text
>
</text>
</block>
2025-07-06 00:42:10 +08:00
<block v-if="isFinal">
2025-07-02 15:57:58 +08:00
<view class="point-view2">
<text>蓝队</text>
2025-08-18 16:09:11 +08:00
<text>{{ bluePoint }}</text>
2025-07-02 15:57:58 +08:00
<text>红队</text>
2025-08-18 16:09:11 +08:00
<text>{{ redPoint }}</text>
2025-07-02 15:57:58 +08:00
<text></text>
</view>
<text>同分僵局最后一箭定江山</text>
<view class="final-shoot">
<text>{{ count }}</text>
<text>秒后蓝红双方</text>
<text>决金箭</text>
<text>一箭决胜负</text>
</view>
</block>
</view>
</template>
<style scoped>
.round-end-tip {
width: 100%;
color: #fff9;
display: flex;
flex-direction: column;
align-items: center;
2025-11-07 16:28:52 +08:00
font-size: 32rpx;
2025-07-02 15:57:58 +08:00
}
.round-end-tip > text:first-child {
2025-11-07 16:28:52 +08:00
font-size: 36rpx;
2025-07-02 15:57:58 +08:00
color: #fff;
}
.point-view1 {
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
margin-bottom: 3px;
}
.point-view1 > text:nth-child(2),
.point-view1 > text:nth-child(4) {
color: #fed847;
margin: 0 5px;
}
.point-view2 {
margin: 12px 0;
2025-11-07 16:28:52 +08:00
font-size: 48rpx;
2025-07-02 15:57:58 +08:00
display: flex;
align-items: center;
justify-content: center;
color: #fff;
}
.point-view2 > text:nth-child(2),
.point-view2 > text:nth-child(4) {
color: #fed847;
width: 30px;
text-align: center;
font-size: 30px;
}
.final-shoot {
display: flex;
align-items: center;
justify-content: center;
margin-top: 10px;
2025-11-07 16:28:52 +08:00
font-size: 28rpx;
2025-11-07 16:42:07 +08:00
word-break: keep-all;
2025-07-02 15:57:58 +08:00
}
.final-shoot > text:nth-child(1) {
width: 20px;
text-align: right;
}
.final-shoot > text:nth-child(1),
.final-shoot > text:nth-child(3) {
2025-11-07 16:28:52 +08:00
font-size: 32rpx;
2025-07-02 15:57:58 +08:00
color: #fed847;
margin-left: 10px;
margin-right: 5px;
}
</style>