update:代码备份
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { computed, nextTick, ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import TargetPicker from "@/components/TargetPicker.vue";
|
||||
import TrainingDifficultyBadge from "@/components/training/TrainingDifficultyBadge.vue";
|
||||
import TrainingDifficultyPreviewCard from "@/components/training/TrainingDifficultyPreviewCard.vue";
|
||||
import TrainingDifficultyStartButton from "@/components/training/TrainingDifficultyStartButton.vue";
|
||||
@@ -41,6 +42,7 @@ const emptyDifficulty = {
|
||||
const modeKey = ref(defaultModeKey);
|
||||
const unlockedDifficultyId = ref(defaultUnlockedDifficultyId);
|
||||
const selectedDifficultyId = ref(defaultUnlockedDifficultyId);
|
||||
const showTargetPicker = ref(false);
|
||||
const nodesScrollTop = ref(0);
|
||||
const nodesScrollWithAnimation = ref(false);
|
||||
|
||||
@@ -318,7 +320,11 @@ const initPageState = (options = {}) => {
|
||||
});
|
||||
};
|
||||
|
||||
const saveTrainingContext = () => {
|
||||
const resolveTargetPaperType = (target) => {
|
||||
return Number(target) === 1 ? "20厘米全环靶" : "40厘米全环靶";
|
||||
};
|
||||
|
||||
const saveTrainingContext = (target) => {
|
||||
const difficulty = selectedDifficulty.value;
|
||||
|
||||
if (!difficulty.id) {
|
||||
@@ -330,7 +336,9 @@ const saveTrainingContext = () => {
|
||||
trainingTitle: pageConfig.value.title,
|
||||
difficultyId: difficulty.id,
|
||||
difficultyLabel: difficulty.label,
|
||||
targetPaperType: difficulty.targetPaperType,
|
||||
targetPaperType: target
|
||||
? resolveTargetPaperType(target)
|
||||
: difficulty.targetPaperType,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -369,6 +377,26 @@ const handleStart = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const openTargetPicker = () => {
|
||||
if (!selectedDifficulty.value.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
showTargetPicker.value = true;
|
||||
};
|
||||
|
||||
const handleTargetConfirm = (target) => {
|
||||
showTargetPicker.value = false;
|
||||
saveTrainingContext(target);
|
||||
// uni.showToast({
|
||||
// title: `${selectedDifficulty.value.title} 即将开始`,
|
||||
// icon: "none",
|
||||
// });
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/training/practise-one?target=${target}`,
|
||||
});
|
||||
};
|
||||
|
||||
onLoad((options = {}) => {
|
||||
initPageState(options);
|
||||
@@ -424,10 +452,15 @@ onLoad((options = {}) => {
|
||||
<view class="difficulty-page__start">
|
||||
<TrainingDifficultyStartButton
|
||||
:text="selectedDifficulty.startText"
|
||||
@click="handleStart"
|
||||
@click="openTargetPicker"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<TargetPicker
|
||||
:show="showTargetPicker"
|
||||
:onClose="() => (showTargetPicker = false)"
|
||||
:onConfirm="handleTargetConfirm"
|
||||
/>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user