Files
shoot-miniprograms/src/pages/point-book-edit.vue

254 lines
6.1 KiB
Vue
Raw Normal View History

2025-07-30 09:55:15 +08:00
<script setup>
2025-07-30 14:20:38 +08:00
import { ref, onMounted } from "vue";
2025-07-30 09:55:15 +08:00
import Container from "@/components/Container.vue";
import ScreenHint2 from "@/components/ScreenHint2.vue";
import SButton from "@/components/SButton.vue";
2025-07-30 17:38:48 +08:00
import BowTargetEdit from "@/components/BowTargetEdit.vue";
2025-07-30 09:55:15 +08:00
const clickable = ref(false);
const showTip = ref(false);
2025-07-30 14:20:38 +08:00
const groups = ref(0);
const amount = ref(0);
const currentGroup = ref(1);
const currentArrow = ref(0);
const arrowGroups = ref({});
const ringColors = [
"#FADB80",
"#FADB80",
"#FADB80",
"#F97E81",
"#F97E81",
"#7AC7FF",
"#7AC7FF",
"#9B9B9B",
"#9B9B9B",
];
2025-07-30 09:55:15 +08:00
2025-07-31 14:32:14 +08:00
const onEdit = (arrows) => {
arrowGroups.value[currentGroup.value][currentArrow.value] = { ring };
};
2025-07-30 09:55:15 +08:00
const onBack = () => {
uni.navigateBack();
};
2025-07-30 14:20:38 +08:00
const onSubmit = () => {
if (currentGroup.value < groups.value) {
currentGroup.value++;
currentArrow.value = 0;
clickable.value = false;
} else {
2025-08-01 09:20:10 +08:00
uni.redirectTo({
url: `/pages/point-book-detail`,
});
2025-07-30 14:20:38 +08:00
}
};
const onClickRing = (ring) => {
if (arrowGroups.value[currentGroup.value]) {
2025-07-31 14:32:14 +08:00
arrowGroups.value[currentGroup.value][currentArrow.value] = { ring };
2025-07-30 14:20:38 +08:00
clickable.value = arrowGroups.value[currentGroup.value].every(
2025-07-31 14:32:14 +08:00
(item) => !!item.ring
2025-07-30 14:20:38 +08:00
);
2025-07-31 14:32:14 +08:00
if (currentArrow.value < amount.value - 1) currentArrow.value++;
2025-07-30 14:20:38 +08:00
}
};
2025-07-30 17:38:48 +08:00
const deleteArrow = () => {
2025-07-31 14:32:14 +08:00
arrowGroups.value[currentGroup.value][currentArrow.value] = {};
};
const onEditDone = (arrow) => {
2025-08-01 09:20:10 +08:00
arrowGroups.value[currentGroup.value][currentArrow.value] = arrow;
2025-07-31 14:32:14 +08:00
if (currentArrow.value < amount.value - 1) currentArrow.value++;
2025-07-30 17:38:48 +08:00
};
2025-07-30 14:20:38 +08:00
onMounted(() => {
const pointBook = uni.getStorageSync("point-book");
if (pointBook.amountGroup) {
groups.value = Number(pointBook.amountGroup.split("/")[0]);
amount.value = Number(pointBook.amountGroup.split("/")[1]);
for (let i = 1; i <= groups.value; i++) {
2025-07-31 14:32:14 +08:00
arrowGroups.value[i] = new Array(amount.value).fill({});
2025-07-30 14:20:38 +08:00
}
}
});
2025-07-30 09:55:15 +08:00
</script>
<template>
<Container
:bgType="2"
bgColor="#F5F5F5"
:whiteBackArrow="false"
:onBack="() => (showTip = true)"
>
2025-07-30 14:20:38 +08:00
<view class="container">
2025-07-31 14:32:14 +08:00
<BowTargetEdit
:onChange="onEditDone"
:arrows="arrowGroups[currentGroup]"
/>
2025-07-30 14:20:38 +08:00
<view class="title-bar">
2025-07-30 17:38:48 +08:00
<view>
<view />
<text> {{ currentGroup }} </text>
</view>
<view @click="deleteArrow">
<image src="../static/delete.png" />
<text>删除</text>
</view>
2025-07-30 14:20:38 +08:00
</view>
<view class="bow-arrows">
<view
v-if="arrowGroups[currentGroup]"
v-for="(arrow, index) in arrowGroups[currentGroup]"
:key="index"
@click="currentArrow = index"
:style="{
borderColor: currentArrow === index ? '#FED847' : '#eeeeee',
borderWidth: currentArrow === index ? '2px' : '1px',
}"
2025-07-31 14:32:14 +08:00
>{{
isNaN(arrow.ring)
? arrow.ring
: arrow.ring
? arrow.ring + " 环"
: ""
}}</view
2025-07-30 14:20:38 +08:00
>
</view>
<text>输入分值的情况下系统不提供落点稳定性分</text>
<view class="bow-rings">
2025-07-30 17:38:48 +08:00
<view @click="() => onClickRing('X')">X</view>
2025-07-30 14:20:38 +08:00
<view
v-for="i in 10"
:key="i"
@click="() => onClickRing(11 - i)"
:style="{ backgroundColor: ringColors[i] || '#d8d8d8' }"
>{{ 11 - i }}</view
>
2025-07-30 17:38:48 +08:00
<view @click="() => onClickRing('M')">M</view>
2025-07-30 14:20:38 +08:00
</view>
2025-07-30 09:55:15 +08:00
<ScreenHint2 :show="showTip">
<view class="tip-content">
<text>现在离开会导致</text>
<text>未提交的数据丢失是否继续</text>
<view>
<button hover-class="none" @click="onBack">退出</button>
<button hover-class="none" @click="showTip = false">
继续记录
</button>
</view>
</view>
</ScreenHint2>
</view>
<view :style="{ marginBottom: '20px' }">
<SButton
:disabled="!clickable"
2025-07-30 14:20:38 +08:00
:onClick="onSubmit"
2025-07-30 09:55:15 +08:00
disabledColor="#DDDDDD"
:color="clickable ? '#000' : '#fff'"
>
2025-07-30 14:20:38 +08:00
{{ currentGroup === groups ? "记完了,提交看分析" : "下一组" }}
2025-07-30 09:55:15 +08:00
</SButton>
</view>
</Container>
</template>
<style scoped>
2025-07-30 14:20:38 +08:00
.container {
width: 100%;
}
.container > text {
margin: 15px;
color: #999;
font-size: 13px;
font-weight: 200;
}
.bow-arrows,
.bow-rings {
margin: 15px;
display: grid;
column-gap: 1vw;
grid-template-columns: repeat(6, 1fr);
}
.bow-arrows > view,
.bow-rings > view {
background: #ffffff;
border-radius: 6px;
border: 1px solid #eeeeee;
box-sizing: border-box;
font-size: 12px;
color: #333;
text-align: center;
padding: 5px 0;
height: 32px;
line-height: 20px;
margin-bottom: 5px;
}
.bow-rings > view {
font-size: 13px;
height: 36px;
line-height: 24px;
color: #fff;
background-color: #d8d8d8;
}
.bow-rings > view:first-child {
background-color: #fadb80;
}
2025-07-30 09:55:15 +08:00
.tip-content {
width: 100%;
padding: 25px;
display: flex;
flex-direction: column;
}
.tip-content > text {
width: 100%;
text-align: center;
font-size: 14px;
margin-top: 5px;
}
.tip-content > view {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.tip-content > view > button {
width: 48%;
background: linear-gradient(180deg, #fbfbfb 0%, #f5f5f5 100%);
border-radius: 22px;
border: 1px solid #eeeeee;
padding: 12px 0;
font-size: 14px;
}
.tip-content > view > button:last-child {
background: #fed847;
}
2025-07-30 14:20:38 +08:00
.title-bar {
2025-07-30 17:38:48 +08:00
width: calc(100% - 30px);
2025-07-30 14:20:38 +08:00
display: flex;
align-items: center;
2025-07-30 17:38:48 +08:00
justify-content: space-between;
2025-07-30 14:20:38 +08:00
font-size: 13px;
2025-07-30 17:38:48 +08:00
margin: 0 15px;
}
.title-bar > view:first-child {
display: flex;
align-items: center;
2025-07-30 14:20:38 +08:00
color: #333;
font-weight: 500;
}
2025-07-30 17:38:48 +08:00
.title-bar > view:first-child > view:first-child {
2025-07-30 14:20:38 +08:00
width: 5px;
height: 15px;
border-radius: 10px;
background-color: #fed847;
margin-right: 7px;
2025-07-30 17:38:48 +08:00
}
.title-bar > view:nth-child(2) {
color: #287fff;
display: flex;
align-items: center;
}
.title-bar > view:nth-child(2) image {
width: 14px;
height: 14px;
margin-right: 5px;
2025-07-30 14:20:38 +08:00
}
2025-07-30 09:55:15 +08:00
</style>