add:新增喂养计算器表单部分
This commit is contained in:
1 parent
cf82fb2d07
commit
fc8900c66e
15 files changed
+258
-49
No files matched your search
@@ -2,11 +2,16 @@
|
||||
import feedSlogan from '@/static/image/feed-plan/feed-slogan.png'
|
||||
import ToolApi from '@/utils'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
bottom: number
|
||||
}>(), {
|
||||
bottom: 70,
|
||||
})
|
||||
const safeBottomMenuHeight = ToolApi.getMenuButtonInfoHeight()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-screen fixed left-0" :style="{ bottom: `${safeBottomMenuHeight + 70}px` }">
|
||||
<view class="w-screen fixed left-0" :style="{ bottom: `${safeBottomMenuHeight + props.bottom}px` }">
|
||||
<image :src="feedSlogan" class="w-[138px] h-[38px] mx-auto" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
import type { PetCard } from '@/model/pet-manual'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
title: string
|
||||
formType: number
|
||||
answerList: PetCard[]
|
||||
}>(), {
|
||||
title: '',
|
||||
formType: 1,
|
||||
})
|
||||
const emits = defineEmits(['next'])
|
||||
function handleChooseAnswer(answer: PetCard) {
|
||||
emits('next', answer)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-full flex justify-center items-center text-[20px] font-bold" :style="{ marginTop: formType === 3 ? '29px' : '69px' }">
|
||||
{{ props.title }}
|
||||
</view>
|
||||
<view v-if="formType === 1" class="flex w-full justify-center items-center mt-[37px] gap-3">
|
||||
<view v-for="(item, index) in props.answerList" :key="index" class="w-[136px] h-[154px] bg-[white] rounded-lg flex flex-col items-center " @click="handleChooseAnswer(item)">
|
||||
<image v-if="index === 0" :src="item?.image" class="w-[76px] h-[69px] mt-[40px]" />
|
||||
<image v-else :src="item?.image" class="w-[96px] h-[73px] mt-[35px]" />
|
||||
<text class="mt-3">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="formType === 2" class="flex flex-col w-full justify-center items-center mt-[37px] gap-4">
|
||||
<view v-for="(item, index) in props.answerList" :key="index" class="w-[200px] h-[56px] bg-[white] rounded-3 flex items-center justify-center" @click="handleChooseAnswer(item)">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="formType === 3" class="flex flex-wrap w-full justify-center items-center mt-[39px] gap-2.5">
|
||||
<view v-for="(item, index) in answerList" :key="index" class="w-[143px] h-[134px] bg-[white] rounded-5 flex flex-col items-center text-[12px]" @click="handleChooseAnswer(item)">
|
||||
<image :src="item.image" class="w-[101px] h-[76px] mt-[21px]" />
|
||||
<text class="mt-[13px]">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import type { FeedFormQuestions, PetCard, StepInfo } from '@/model/pet-manual'
|
||||
import FeedSlogan from '@/pages/feed-plan/components/FeedFlogan.vue'
|
||||
import FeedForm from '@/pages/feed-plan/components/FeedForm.vue'
|
||||
import ProgressBar from '@/pages/feed-plan/components/ProgressBar.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
list: FeedFormQuestions[]
|
||||
stepInfo: StepInfo[]
|
||||
}>()
|
||||
const emits = defineEmits(['back', 'step'])
|
||||
const step = ref(0)
|
||||
const progressNumber = computed<number>(() => {
|
||||
return Math.ceil((step.value + 1) / props.list.length * 100)
|
||||
})
|
||||
const feedSloganBottom = computed<number>(() => {
|
||||
return props.list[step.value].formType === 3 ? 40 : 70
|
||||
})
|
||||
const feedProgressTitle = computed<string>(() => {
|
||||
return step.value === 0 ? '返回' : '上一题'
|
||||
})
|
||||
|
||||
function handlePrevious() {
|
||||
if (step.value > 0) {
|
||||
step.value -= 1
|
||||
}
|
||||
else {
|
||||
emits('back')
|
||||
}
|
||||
}
|
||||
function handleAnswer(answer: PetCard) {
|
||||
console.log(answer, '答案')
|
||||
if (step.value === 2 || step.value === 7) {
|
||||
emits('step', step.value)
|
||||
}
|
||||
if (step.value < props.list.length - 1) {
|
||||
step.value += 1
|
||||
console.log(step.value, 'step')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ProgressBar :progress="progressNumber" :title-name="feedProgressTitle" @previous="handlePrevious" />
|
||||
<FeedForm :form-type="props.list[step].formType" :answer-list="props.list[step].question" :title="props.list[step].title" @next="handleAnswer" />
|
||||
<FeedSlogan :bottom="feedSloganBottom" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
+
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { StepInfo } from '@/model/pet-manual'
|
||||
import FeedFlogan from '@/pages/feed-plan/components/FeedFlogan.vue'
|
||||
import FeedStep from '@/pages/feed-plan/components/FeedStep.vue'
|
||||
import feedTitle from '@/static/image/feed-plan/feed-title.png'
|
||||
|
||||
const props = defineProps<{
|
||||
stepInfo: StepInfo[]
|
||||
}>()
|
||||
const emits = defineEmits(['ready'])
|
||||
function handleReady() {
|
||||
emits('ready')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-[273px] h-[125px] mx-auto mt-[105px]">
|
||||
<image :src="feedTitle" class="w-full h-full" />
|
||||
</view>
|
||||
|
||||
<view class="h-[121px] ml-15 mt-14">
|
||||
<FeedStep :list="props.stepInfo" />
|
||||
</view>
|
||||
<FeedFlogan />
|
||||
<view class="flex items-center justify-center">
|
||||
<button class="w-[176px] h-[47px] flex items-center justify-center bg-[#4545E5] border-none text-[white] rounded-3xl mt-[87px]" @tap="handleReady">
|
||||
准备好了
|
||||
</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import back from '@/static/image/pet-parameters/back.png'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
titleName: string
|
||||
progress: number
|
||||
}>(), {
|
||||
titleName: '返回',
|
||||
progress: 0,
|
||||
})
|
||||
|
||||
const emits = defineEmits(['previous'])
|
||||
|
||||
function handleBack() {
|
||||
emits('previous')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="m-4 flex items-center">
|
||||
<image :src="back" class="w-[6px] h-[10px]" @click="handleBack" />
|
||||
<text class="text-[12px] font-pingfangsc ml-1" @click="handleBack">
|
||||
{{ props.titleName }}
|
||||
</text>
|
||||
<view class="flex-1 h-[6px] bg-[#E7E7E7] ml-3 rounded relative">
|
||||
<view class="absolute h-[6px] bg-[#0052D9] rounded" :style="{ width: `${props.progress}%` }" />
|
||||
</view>
|
||||
<text class="text-[12px] font-pingfangsc ml-3">
|
||||
{{ props.progress }}%
|
||||
</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in new issue
Block a user