添加计分本草稿功能
This commit is contained in:
@@ -55,6 +55,7 @@ const onSubmit = async () => {
|
||||
Object.values(arrowGroups.value)
|
||||
);
|
||||
if (res.record_id) {
|
||||
uni.removeStorageSync("last-point-record");
|
||||
uni.redirectTo({
|
||||
url: `/pages/point-book-detail?id=${res.record_id}`,
|
||||
});
|
||||
@@ -65,26 +66,25 @@ const onClickRing = (ring) => {
|
||||
if (arrowGroups.value[currentGroup.value]) {
|
||||
arrowGroups.value[currentGroup.value][currentArrow.value] = { ring };
|
||||
if (currentArrow.value < amount.value - 1) currentArrow.value++;
|
||||
uni.setStorageSync("last-point-record", arrowGroups.value);
|
||||
}
|
||||
};
|
||||
const deleteArrow = () => {
|
||||
arrowGroups.value[currentGroup.value][currentArrow.value] = {};
|
||||
const arrow = arrowGroups.value[currentGroup.value][currentArrow.value];
|
||||
if (JSON.stringify(arrow) === "{}") {
|
||||
currentArrow.value -= 1;
|
||||
} else {
|
||||
arrowGroups.value[currentGroup.value][currentArrow.value] = {};
|
||||
}
|
||||
uni.setStorageSync("last-point-record", arrowGroups.value);
|
||||
};
|
||||
const onEditDone = (arrow) => {
|
||||
arrowGroups.value[currentGroup.value][currentArrow.value] = arrow;
|
||||
if (currentArrow.value < amount.value - 1) currentArrow.value++;
|
||||
uni.setStorageSync("last-point-record", arrowGroups.value);
|
||||
};
|
||||
|
||||
onLoad(() => {
|
||||
uni.enableAlertBeforeUnload({
|
||||
message: "现在离开会导致未提交的数据丢失,是否继续?",
|
||||
success: (res) => {
|
||||
console.log("已启用离开提示");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
onLoad((options) => {
|
||||
const pointBook = uni.getStorageSync("last-point-book");
|
||||
if (pointBook.bowtargetType) {
|
||||
bowtarget.value = pointBook.bowtargetType;
|
||||
@@ -102,6 +102,22 @@ onMounted(() => {
|
||||
arrowGroups.value[i] = new Array(amount.value).fill({});
|
||||
}
|
||||
}
|
||||
if (options.withDraft) {
|
||||
const draft = uni.getStorageSync("last-point-record");
|
||||
if (draft) {
|
||||
Object.values(draft).some((arrows, index1) =>
|
||||
arrows.some((arrow, index2) => {
|
||||
currentArrow.value = index2;
|
||||
currentGroup.value = index1 + 1;
|
||||
return JSON.stringify(arrow) === "{}";
|
||||
})
|
||||
);
|
||||
arrowGroups.value = draft;
|
||||
}
|
||||
}
|
||||
// uni.enableAlertBeforeUnload({
|
||||
// message: "现在离开会导致未提交的数据丢失,是否继续?",
|
||||
// });
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -140,8 +156,8 @@ onMounted(() => {
|
||||
: arrow.ring
|
||||
? arrow.ring + " 环"
|
||||
: ""
|
||||
}}</view
|
||||
>
|
||||
}}
|
||||
</view>
|
||||
</view>
|
||||
<text>推荐在靶纸上落点计分,这样可获得稳定性分析</text>
|
||||
<view class="bow-rings">
|
||||
|
||||
Reference in New Issue
Block a user