feat: 计算公式
This commit is contained in:
1 parent
f8cb974280
commit
f99dca56ef
17 files changed
+167
-135
No files matched your search
@@ -22,7 +22,7 @@ function handleNext() {
|
||||
<view class="w-full bg-regular flex flex-col items-center">
|
||||
<view class="mt-[54px] flex flex-col gap-1 mb-[60px] items-center">
|
||||
<view class="gradient-text text-[48px] font-bold">
|
||||
400<text class="text-[24px] font-semibold">
|
||||
{{ feedingPlanStore.dailyCalories }}<text class="text-[24px] font-semibold">
|
||||
Kcal
|
||||
</text>
|
||||
</view>
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<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: [PetCard]
|
||||
}>()
|
||||
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>
|
||||
@@ -1,119 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { FeedFormQuestions, PetCard, StepInfo, UserList } from '@/model/pet-manual'
|
||||
import FeedForm from '@/pages/feed-questionnaire/components/FeedForm.vue'
|
||||
import FeedSlogan from '@/pages/feed-questionnaire/components/FeedSlogan.vue'
|
||||
import ProgressBar from '@/pages/feed-questionnaire/components/ProgressBar.vue'
|
||||
import avator from '@/static/image/pet-parameters/avatar.png'
|
||||
|
||||
const props = defineProps<{
|
||||
list: FeedFormQuestions[]
|
||||
stepInfo: StepInfo[]
|
||||
userList: UserList
|
||||
}>()
|
||||
const emits = defineEmits<{
|
||||
back: [void]
|
||||
step: [number]
|
||||
}>()
|
||||
const step = ref<number>(0)
|
||||
const addPage = ref<number>(1)
|
||||
const isUserPage = ref<boolean>(false)
|
||||
const aimList = ref<string[]>(['增肥', '减肥'])
|
||||
const aimIndex = ref<number>(0)
|
||||
const weightList = ref<string[]>(['6kg', '7kg'])
|
||||
const weightIndex = ref<number>(0)
|
||||
function handleAimChange(e: CustomEvent, type: string) {
|
||||
if (type === 'aim') {
|
||||
aimIndex.value = e.detail.value
|
||||
}
|
||||
else if (type === 'weight') {
|
||||
weightIndex.value = e.detail.value
|
||||
}
|
||||
}
|
||||
const progressNumber = computed<number>(() => {
|
||||
return Math.ceil((step.value + 1) / (props.list.length + addPage.value) * 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 === props.list.length - 1 + addPage.value) {
|
||||
isUserPage.value = false
|
||||
}
|
||||
if (step.value > 0) {
|
||||
step.value -= 1
|
||||
}
|
||||
else {
|
||||
emits('back')
|
||||
}
|
||||
}
|
||||
|
||||
const feedingPlanStore = useFeedingPlanStore()
|
||||
|
||||
function handleAnswer(answer: PetCard) {
|
||||
if (answer.key) {
|
||||
feedingPlanStore.setPetValue(answer.key, answer.value)
|
||||
}
|
||||
if (step.value === 2 || step.value === 7) {
|
||||
emits('step', step.value)
|
||||
}
|
||||
if (step.value === props.list.length - 1) {
|
||||
isUserPage.value = true
|
||||
}
|
||||
if (step.value < props.list.length - 1 + addPage.value) {
|
||||
step.value += 1
|
||||
}
|
||||
}
|
||||
|
||||
async function confirm() {
|
||||
await feedingPlanStore.persistentPet()
|
||||
uni.navigateTo({
|
||||
url: '/pages/feed-plan-calculator/index',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ProgressBar :progress="progressNumber" :title-name="feedProgressTitle" @previous="handlePrevious" />
|
||||
<FeedForm v-if="!isUserPage" :form-type="props.list[step].formType" :answer-list="props.list[step].question" :title="props.list[step].title" @next="handleAnswer" />
|
||||
<FeedSlogan :bottom="feedSloganBottom" />
|
||||
<view v-if="isUserPage">
|
||||
<view class="w-[calc(100% - 32px)] h-[96px] bg-[white] rounded-3 mt-[31px] p-[16px] mx-[16px] flex flex-col justify-center">
|
||||
<view class="flex gap-4">
|
||||
<image :src="avator" class="w-[64px] h-[64px] rounded-full" />
|
||||
<view class="mt-[5px] ">
|
||||
<text class="font-bold text-[16px] ">
|
||||
{{ feedingPlanStore.pet.name }}
|
||||
</text>
|
||||
<view class="mt-[8px] flex gap-2">
|
||||
<view v-for="item in feedingPlanStore.petTags" :key="item.key" class="text-[12px] text-[#999] bg-[#F3F3F3] rounded-[3px] py-[2px] px-[8px]">
|
||||
{{ item.value }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CellGroup>
|
||||
<Cell title="喂养目标" border>
|
||||
<PickerItem v-model="feedingPlanStore.feedingPlan.feedingGoal" :options="feedingPlanStore.feedingGoalOptions" />
|
||||
</Cell>
|
||||
<Cell title="目标体重">
|
||||
<PopupInput v-model="feedingPlanStore.feedingPlan.targetWeight" placeholder="请输入目标体重" />
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
<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-[210px]" @tap="confirm">
|
||||
下一步
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.card_border_bottom{
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
}
|
||||
</style>
|
||||
@@ -1,21 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
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 + props.bottom}px` }">
|
||||
<image :src="feedSlogan" class="w-[138px] h-[38px] mx-auto" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,35 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type {StepInfo} from '@/model/pet-manual'
|
||||
import FeedStep from '@/pages/feed-questionnaire/components/FeedStep.vue'
|
||||
import feedTitle from '@/static/image/feed-plan/feed-title.png'
|
||||
|
||||
const props = defineProps<{
|
||||
stepInfo: StepInfo[]
|
||||
}>()
|
||||
const emits = defineEmits<{
|
||||
ready: [void]
|
||||
}>()
|
||||
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">
|
||||
<BButton class="w-[176px] h-[47px] flex items-center justify-center bg-[#4545E5] border-none text-[white] rounded-3xl mt-[87px]" @tap="handleReady">
|
||||
准备好了
|
||||
</BButton>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,57 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(defineProps<{
|
||||
list: Array<{
|
||||
step: number
|
||||
title: string
|
||||
}>
|
||||
stage: number
|
||||
}>(), {
|
||||
stage: -1,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-for="(item, index) in props.list" :key="index">
|
||||
<view class="flex">
|
||||
<view class="flex items-center justify-center text-[white]" :class="props.stage === index ? 'step_select' : props.stage === -1 ? 'step' : 'step step_left' ">
|
||||
{{ item.step }}
|
||||
</view>
|
||||
<view class="ml-1 font-pingfangsc tracking-[0.8px]" :class="props.stage === index ? 'step_title_select' : 'step_title' ">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="index !== props.list.length - 1" class="w-[1px] h-[13px] bg-[#999] mt-1 mb-1 step_line" :class="props.stage === -1 ? 'step_line' : 'step_line_select' " />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.step{
|
||||
background: #999999;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
border-radius: 30px;
|
||||
}
|
||||
.step_left{
|
||||
margin-left: 3px;
|
||||
}
|
||||
.step_select{
|
||||
background: #0052D9;
|
||||
width: 27px;
|
||||
height: 27px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.step_title{
|
||||
color: #999999;
|
||||
font-size:16px;
|
||||
}
|
||||
.step_title_select{
|
||||
color: #151515;
|
||||
font-size: 20px;
|
||||
}
|
||||
.step_line{
|
||||
margin-left: 10px;
|
||||
}
|
||||
.step_line_select{
|
||||
margin-left: 13px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,38 +0,0 @@
|
||||
<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: [void]
|
||||
}>()
|
||||
|
||||
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>
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { FeedFormQuestions, UserList } from '@/model/pet-manual'
|
||||
import FeedQuestionnaire from '@/components/FeedQuestionnaire.vue'
|
||||
import FeedStart from '@/components/FeedStart.vue'
|
||||
import FeedStep from '@/components/FeedStep.vue'
|
||||
import { PetBodyType } from '@/model/pet'
|
||||
import FeedQuestionnaire from '@/pages/feed-questionnaire/components/FeedQuestionnaire.vue'
|
||||
import FeedStart from '@/pages/feed-questionnaire/components/FeedStart.vue'
|
||||
import FeedStep from '@/pages/feed-questionnaire/components/FeedStep.vue'
|
||||
import extremelyObese from '@/static/image/body-type/extremely-obese.svg'
|
||||
import extremelyThin from '@/static/image/body-type/extremely-thin.svg'
|
||||
import ideal from '@/static/image/body-type/ideal.svg'
|
||||
@@ -33,8 +33,14 @@ const controlFormDisplay = ref({
|
||||
display3: false,
|
||||
})
|
||||
const feedFormQuestions = ref<FeedFormQuestions[]>(
|
||||
[{ title: '猫咪是否活跃?', question: [{ name: '活跃', key: 'isActive', value: true }, { name: '不活跃', key: 'isActive', value: false }], formType: 2 }, { title: '猫咪是否怀孕?', question: [{ name: '怀孕', key: 'isPregnant', value: true }, { name: '未怀孕', key: 'isPregnant', value: false }], formType: 2 }, { title: '猫咪是否绝育?', question: [{ name: '绝育', key: 'isSterilization', value: true }, { name: '未绝育', key: 'isSterilization', value: false }], formType: 2 }, { title: '猫咪是否在哺乳?', question: [{ name: '哺乳中', key: 'isLactation', value: true }, { name: '未哺乳', key: 'isLactation', value: false }], formType: 2 }, { title: '请选择猫咪的体型', question:
|
||||
[{ image: extremelyThin, name: '极度消廋', key: 'bodyType', value: PetBodyType.EXTREMELY_THIN }, { image: veryThin, name: '非常廋', key: 'bodyType', value: PetBodyType.VERY_THIN }, { image: thin, name: '消瘦', key: 'bodyType', value: PetBodyType.THIN }, { image: underWeight, name: '体重偏低', key: 'bodyType', value: PetBodyType.UNDERWEIGHT }, { image: ideal, name: '理想体重', key: 'bodyType', value: PetBodyType.IDEAL }, { image: overWeight, name: '体重偏重', key: 'bodyType', value: PetBodyType.OVERWEIGHT }, { image: obese, name: '肥胖', key: 'bodyType', value: PetBodyType.OBESE }, { image: extremelyObese, name: '极度肥胖', key: 'bodyType', value: PetBodyType.EXTREMELY_OBESE }], formType: 3 }],
|
||||
[
|
||||
{ title: '猫咪是否活跃?', question: [{ name: '活跃', key: 'isActive', value: true }, { name: '不活跃', key: 'isActive', value: false }], formType: 2 },
|
||||
{ title: '猫咪是否绝育?', question: [{ name: '绝育', key: 'isSterilization', value: true }, { name: '未绝育', key: 'isSterilization', value: false }], formType: 2 },
|
||||
{ title: '猫咪是否怀孕?', question: [{ name: '怀孕', key: 'isPregnant', value: true }, { name: '未怀孕', key: 'isPregnant', value: false }], formType: 2 },
|
||||
{ title: '猫咪是否在哺乳?', question: [{ name: '哺乳中', key: 'isLactation', value: true }, { name: '未哺乳', key: 'isLactation', value: false }], formType: 2 },
|
||||
{ title: '请选择猫咪的体型', question:
|
||||
[{ image: extremelyThin, name: '极度消廋', key: 'bodyType', value: PetBodyType.EXTREMELY_THIN }, { image: veryThin, name: '非常廋', key: 'bodyType', value: PetBodyType.VERY_THIN }, { image: thin, name: '消瘦', key: 'bodyType', value: PetBodyType.THIN }, { image: underWeight, name: '体重偏低', key: 'bodyType', value: PetBodyType.UNDERWEIGHT }, { image: ideal, name: '理想体重', key: 'bodyType', value: PetBodyType.IDEAL }, { image: overWeight, name: '体重偏重', key: 'bodyType', value: PetBodyType.OVERWEIGHT }, { image: obese, name: '肥胖', key: 'bodyType', value: PetBodyType.OBESE }, { image: extremelyObese, name: '极度肥胖', key: 'bodyType', value: PetBodyType.EXTREMELY_OBESE }], formType: 3 },
|
||||
],
|
||||
)
|
||||
const userList = ref<UserList>({
|
||||
image: avatar,
|
||||
@@ -56,7 +62,7 @@ function handleReady() {
|
||||
setTimeout(() => {
|
||||
reset()
|
||||
controlFormDisplay.value.display3 = true
|
||||
}, 3000)
|
||||
}, 2000)
|
||||
}
|
||||
function handleBackFeedStart() {
|
||||
reset()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import FeedSlogan from '@/components/FeedSlogan.vue'
|
||||
import PickerItem from '@/components/PickerItem.vue'
|
||||
import FeedSlogan from '@/pages/feed-questionnaire/components/FeedSlogan.vue'
|
||||
import { PetType } from '@/model/pet'
|
||||
import edit from '@/static/image/start-filing/edit.png'
|
||||
import { useFeedingPlanStore } from '@/stores/feeding-plan'
|
||||
import ToolApi from '@/utils'
|
||||
@@ -12,12 +13,17 @@ function handleNext() {
|
||||
uni.navigateTo({ url: '/pages/feed-questionnaire/index' })
|
||||
}
|
||||
|
||||
const { pet, petTypeOptions, genderOptions } = useFeedingPlanStore()
|
||||
const feedingPlanStore = useFeedingPlanStore()
|
||||
|
||||
const disabled = computed(() => {
|
||||
return feedingPlanStore.pet.type === PetType.DOG
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="flex flex-col bg-[#F5F6F7] overflow-y-auto" :style="`height:calc(100vh - ${safeHeight}px)`">
|
||||
<view class="w-[80px] h-[80px] rounded-full bg-[#D9D9D9] relative mt-[88px] mx-auto">
|
||||
<image src="@/static/icons/cat-avatar-default.svg" class="w-[80px] h-[80px] rounded-full" />
|
||||
<view class="absolute right-1 bottom-1 w-[18px] h-[18px] bg-[#0052D9] rounded-full flex items-center justify-center">
|
||||
<image :src="edit" class="w-[10px] h-[10px]" />
|
||||
</view>
|
||||
@@ -25,29 +31,32 @@ const { pet, petTypeOptions, genderOptions } = useFeedingPlanStore()
|
||||
<view class="w-full px-4 flex flex-col gap-4 mt-[28px]">
|
||||
<CellGroup class="w-full bg-[#fff] shadow-cell-group rounded-3 overflow-hidden">
|
||||
<Cell title="宠物名称">
|
||||
<PopupInput v-model="pet.name" placeholder="请输入宠物名称" />
|
||||
<PopupInput v-model="feedingPlanStore.pet.name" placeholder="请输入宠物名称" />
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
<CellGroup class="w-full bg-[#fff] shadow-cell-group rounded-3 overflow-hidden">
|
||||
<Cell title="品种" border>
|
||||
<PickerItem v-model="pet.type" :options="petTypeOptions" />
|
||||
<PickerItem v-model="feedingPlanStore.pet.type" :options="feedingPlanStore.petTypeOptions" />
|
||||
</Cell>
|
||||
<Cell title="性别" border>
|
||||
<PickerItem v-model="pet.gender" :options="genderOptions" />
|
||||
<PickerItem v-model="feedingPlanStore.pet.gender" :options="feedingPlanStore.genderOptions" />
|
||||
</Cell>
|
||||
<Cell title="出生日期" border>
|
||||
<PickerDate v-model="pet.birthday" />
|
||||
<PickerDate v-model="feedingPlanStore.pet.birthday" />
|
||||
</Cell>
|
||||
<Cell title="体重">
|
||||
<PopupInput v-model="pet.weight" placeholder="请输入宠物体重" suffix="kg" />
|
||||
<PopupInput v-model="feedingPlanStore.pet.weight" placeholder="请输入宠物体重" suffix="kg" />
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
</view>
|
||||
|
||||
<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-[58px]" @tap="handleNext">
|
||||
下一题
|
||||
</button>
|
||||
<view class="flex items-center mt-[50px] flex-col">
|
||||
<view v-if="disabled" class="text-xs text-disabled">
|
||||
建设中
|
||||
</view>
|
||||
<BButton :disabled="disabled" @tap="handleNext">
|
||||
建档完成
|
||||
</BButton>
|
||||
</view>
|
||||
<FeedSlogan :bottom="feedSloganBottom" />
|
||||
</view>
|
||||
|
||||
Reference in new issue
Block a user