浏览代码

feat: 计算公式

IlhamTahir 11 月之前
父节点
当前提交
f99dca56ef

+ 2 - 28
pages.config.ts

@@ -23,6 +23,7 @@ export default defineUniPages({
       style: {
         navigationBarTitleText: '喂养计算器',
       },
+      layout: 'custom',
     },
     {
       path: 'pages/feed-plan/index',
@@ -58,39 +59,12 @@ export default defineUniPages({
       style: {
         navigationBarTitleText: '开始建档',
       },
+      layout: 'custom',
     },
     {
       path: 'pages/userInfo/index',
       type: 'page',
     },
-    {
-      path: 'pages/feed-questionnaire/components/FeedSlogan',
-      type: 'page',
-    },
-    {
-      path: 'pages/feed-questionnaire/components/FeedForm',
-      type: 'page',
-    },
-    {
-      path: 'pages/feed-questionnaire/components/FeedQuestionnaire',
-      type: 'page',
-    },
-    {
-      path: 'pages/feed-questionnaire/components/FeedStart',
-      type: 'page',
-    },
-    {
-      path: 'pages/feed-questionnaire/components/FeedStep',
-      type: 'page',
-    },
-    {
-      path: 'pages/feed-questionnaire/components/ProgressBar',
-      type: 'page',
-    },
-    {
-      path: 'pages/pet-manual/components/CardList',
-      type: 'page',
-    },
     {
       path: 'pages/feed-plan-calculator/index',
       type: 'page',

+ 6 - 0
src/components.d.ts

@@ -12,11 +12,17 @@ declare module 'vue' {
     BSlider: typeof import('./components/BSlider.vue')['default']
     Cell: typeof import('./components/Cell.vue')['default']
     CellGroup: typeof import('./components/CellGroup.vue')['default']
+    FeedForm: typeof import('./components/FeedForm.vue')['default']
+    FeedQuestionnaire: typeof import('./components/FeedQuestionnaire.vue')['default']
+    FeedSlogan: typeof import('./components/FeedSlogan.vue')['default']
+    FeedStart: typeof import('./components/FeedStart.vue')['default']
+    FeedStep: typeof import('./components/FeedStep.vue')['default']
     PickerDate: typeof import('./components/PickerDate.vue')['default']
     PickerItem: typeof import('./components/PickerItem.vue')['default']
     PopupInput: typeof import('./components/PopupInput.vue')['default']
     ProductItem: typeof import('./components/ProductItem.vue')['default']
     ProductReadonlyItem: typeof import('./components/ProductReadonlyItem.vue')['default']
+    ProgressBar: typeof import('./components/ProgressBar.vue')['default']
     SectionCard: typeof import('./components/SectionCard.vue')['default']
     TabBar: typeof import('./components/TabBar.vue')['default']
     TitleBar: typeof import('./components/TitleBar.vue')['default']

+ 1 - 1
src/components/BButton.vue

@@ -10,7 +10,7 @@ const props = withDefaults(defineProps<{
 
 <template>
   <button
-    class="px-[60px] py-[5px]  bg-primary border-none outline-none text-white rounded-3xl flex items-center justify-center text-lg disabled:bg-[red] after:border-none "
+    class="px-[60px] py-[5px] h-[47px]  bg-primary border-none outline-none text-white rounded-3xl flex items-center justify-center text-lg disabled:bg-[red] after:border-none "
     :disabled="disabled"
     :class="{
       '!bg-disabled !text-white': disabled,

+ 0 - 0
src/pages/feed-questionnaire/components/FeedForm.vue → src/components/FeedForm.vue


+ 17 - 22
src/pages/feed-questionnaire/components/FeedQuestionnaire.vue → src/components/FeedQuestionnaire.vue

@@ -1,8 +1,7 @@
 <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 FeedForm from '@/components/FeedForm.vue'
+import ProgressBar from '@/components/ProgressBar.vue'
 import avator from '@/static/image/pet-parameters/avatar.png'
 
 const props = defineProps<{
@@ -17,24 +16,10 @@ const emits = defineEmits<{
 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 ? '返回' : '上一题'
 })
@@ -57,6 +42,17 @@ function handleAnswer(answer: PetCard) {
   if (answer.key) {
     feedingPlanStore.setPetValue(answer.key, answer.value)
   }
+
+  if (step.value === 1 && answer.value === true) {
+    step.value = 4
+    return
+  }
+
+  if (step.value === 2 && answer.value === true) {
+    step.value = 4
+    return
+  }
+
   if (step.value === 2 || step.value === 7) {
     emits('step', step.value)
   }
@@ -79,9 +75,8 @@ async function confirm() {
 <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 v-if="isUserPage" class="w-full flex flex-col gap-4 px-4 items-center">
+    <view class="w-full h-[96px] bg-[white] rounded-3 mt-[31px] p-[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] ">
@@ -96,7 +91,7 @@ async function confirm() {
         </view>
       </view>
     </view>
-    <CellGroup>
+    <CellGroup class="w-full">
       <Cell title="喂养目标" border>
         <PickerItem v-model="feedingPlanStore.feedingPlan.feedingGoal" :options="feedingPlanStore.feedingGoalOptions" />
       </Cell>

+ 12 - 0
src/components/FeedSlogan.vue

@@ -0,0 +1,12 @@
+<script setup lang="ts">
+</script>
+
+<template>
+  <view class="w-screen mt-[50px]">
+    <image src="@/static/image/feed-plan/feed-slogan.png" class="w-[138px] h-[38px] mx-auto" />
+  </view>
+</template>
+
+<style scoped>
+
+</style>

+ 5 - 5
src/pages/feed-questionnaire/components/FeedStart.vue → src/components/FeedStart.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
-import type {StepInfo} from '@/model/pet-manual'
-import FeedStep from '@/pages/feed-questionnaire/components/FeedStep.vue'
+import type { StepInfo } from '@/model/pet-manual'
+import FeedStep from '@/components/FeedStep.vue'
 import feedTitle from '@/static/image/feed-plan/feed-title.png'
 
 const props = defineProps<{
@@ -22,12 +22,12 @@ function handleReady() {
   <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">
+  <view class="flex items-center justify-center mt-[92px]">
+    <BButton @tap="handleReady">
       准备好了
     </BButton>
   </view>
+  <FeedSlogan />
 </template>
 
 <style scoped>

+ 0 - 0
src/pages/feed-questionnaire/components/FeedStep.vue → src/components/FeedStep.vue


+ 0 - 0
src/pages/feed-questionnaire/components/ProgressBar.vue → src/components/ProgressBar.vue


+ 4 - 32
src/pages.json

@@ -43,7 +43,8 @@
       "type": "page",
       "style": {
         "navigationBarTitleText": "喂养计算器"
-      }
+      },
+      "layout": "custom"
     },
     {
       "path": "pages/home/index",
@@ -78,43 +79,14 @@
       "type": "page",
       "style": {
         "navigationBarTitleText": "开始建档"
-      }
+      },
+      "layout": "custom"
     },
     {
       "path": "pages/userInfo/index",
       "type": "page",
       "style": {}
     },
-    {
-      "path": "pages/feed-questionnaire/components/FeedForm",
-      "type": "page",
-      "style": {}
-    },
-    {
-      "path": "pages/feed-questionnaire/components/FeedQuestionnaire",
-      "type": "page",
-      "style": {}
-    },
-    {
-      "path": "pages/feed-questionnaire/components/FeedSlogan",
-      "type": "page",
-      "style": {}
-    },
-    {
-      "path": "pages/feed-questionnaire/components/FeedStart",
-      "type": "page",
-      "style": {}
-    },
-    {
-      "path": "pages/feed-questionnaire/components/FeedStep",
-      "type": "page",
-      "style": {}
-    },
-    {
-      "path": "pages/feed-questionnaire/components/ProgressBar",
-      "type": "page",
-      "style": {}
-    },
     {
       "path": "pages/pet-manual/components/CardList",
       "type": "page",

+ 1 - 1
src/pages/feed-plan-calculator/index.vue

@@ -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>

+ 0 - 21
src/pages/feed-questionnaire/components/FeedSlogan.vue

@@ -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>

+ 12 - 6
src/pages/feed-questionnaire/index.vue

@@ -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()

+ 20 - 11
src/pages/start-filing/index.vue

@@ -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>

+ 9 - 0
src/static/icons/cat-avatar-default.svg

@@ -0,0 +1,9 @@
+<svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
+    <circle cx="40" cy="40" r="40" fill="#D9D9D9"/>
+    <path d="M65.4528 37.21L66.6867 22.0241C66.8466 20.0982 65.0308 18.5967 63.1511 19.0972L48.0751 23.0631C45.377 23.6206 42.762 23.5003 39.9552 23.5003C37.1485 23.5003 34.3801 23.4496 31.9505 23.0631L16.8681 19.0972C14.982 18.603 13.1726 20.1045 13.3261 22.0241L14.56 37.21H14.5664C13.5562 39.7315 13 42.5064 13 45.5031C13 59.5423 25.0902 68 40 68C54.9098 68 67 59.5423 67 45.5031C67 42.5064 66.4438 39.7315 65.4336 37.2037H65.44L65.4528 37.21Z" fill="#C5C5C5"/>
+    <path d="M40.5671 51.7489L42.8179 49.2078C43.2338 48.7354 42.8913 48 42.2552 48H37.7475C37.1114 48 36.7628 48.7354 37.1848 49.2078L39.4356 51.7489C39.7353 52.0837 40.2674 52.0837 40.561 51.7489H40.5671Z" fill="#999999"/>
+    <path d="M32.3812 42.9611C32.3812 41.9255 31.5344 41.0859 30.4899 41.0859C29.4454 41.0859 28.5986 41.9255 28.5986 42.9611V45.2987C28.5986 46.3343 29.4454 47.1738 30.4899 47.1738C31.5344 47.1738 32.3812 46.3343 32.3812 45.2987V42.9611Z" fill="#999999"/>
+    <path d="M51.3961 42.9611C51.3961 41.9255 50.5493 41.0859 49.5048 41.0859C48.4603 41.0859 47.6135 41.9255 47.6135 42.9611V45.2987C47.6135 46.3343 48.4603 47.1738 49.5048 47.1738C50.5493 47.1738 51.3961 46.3343 51.3961 45.2987V42.9611Z" fill="#999999"/>
+    <path d="M48 24.4956C48 27.5389 43.2193 30 37.329 30C32.3564 30 28.1847 28.2534 27 25.8805L29.2694 24.4956L27 23.1107C28.1847 20.7466 32.3564 19 37.329 19C43.2193 19 48 21.4611 48 24.4956Z" fill="#E4E4E4"/>
+    <path d="M46.3877 25.2733L51.8272 28.8787C52.3442 29.2242 53 28.7901 53 28.0992V20.8971C53 20.2062 52.3519 19.781 51.8272 20.1176L46.3877 23.723C45.8708 24.0685 45.8708 24.9278 46.3877 25.2733Z" fill="#E4E4E4"/>
+</svg>

+ 78 - 2
src/stores/feeding-plan.ts

@@ -25,7 +25,7 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
   ]
 
   const dailyCalories = ref(400)
-
+  // @ts-expect-error @ts-ignore
   const pet = ref <CreatePetRequest>({
     birthday: new Date().toISOString().split('T')[0],
     bodyType: PetBodyType.IDEAL,
@@ -50,12 +50,86 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
     ]
   })
 
+  // 体脂率
+  const bodyFateRates: Record<PetBodyType, number> = {
+    [PetBodyType.EXTREMELY_THIN]: 5,
+    [PetBodyType.VERY_THIN]: 7.5,
+    [PetBodyType.THIN]: 12,
+    [PetBodyType.UNDERWEIGHT]: 17,
+    [PetBodyType.IDEAL]: 22,
+    [PetBodyType.OVERWEIGHT]: 27,
+    [PetBodyType.OBESE]: 37,
+    [PetBodyType.EXTREMELY_OBESE]: 42,
+  }
+
+  const calculateIdealWeight = () => {
+    return (pet.value.weight * ((100 - bodyFateRates[pet.value.bodyType]) / 100)) / 0.8
+  }
+
+  /**
+   * Calculate Resting Energy Requirement (RER)
+   * @param weightKg - The weight in kilograms
+   * @returns The RER value
+   */
+  function calculateRER(weightKg: number): number {
+    return weightKg ** 0.75 * 70
+  }
+
+  // @ts-expect-error @ts-ignore
   const feedingPlan = ref<CreateFeedingPlanRequest>({
     feedingGoal: FeedingGoal.LOSE,
-    targetWeight: pet.value.weight - 1,
+    targetWeight: calculateIdealWeight(),
     petId: savedPet.value?.id || '',
     products: [],
   })
+  const derRate = computed(() => {
+    // 如年龄填写为0-4月,或4-12月之间的,系数直接取2.5/2。
+    // 计算年龄(月龄)
+    const birthdayDate = new Date(pet.value.birthday)
+    const currentDate = new Date()
+    const ageInMonths = (currentDate.getFullYear() - birthdayDate.getFullYear()) * 12
+      + (currentDate.getMonth() - birthdayDate.getMonth())
+
+    // 根据年龄(月龄)判断系数
+    if (ageInMonths >= 0 && ageInMonths <= 4) {
+      return 2.5
+    }
+    if (ageInMonths > 4 && ageInMonths <= 12) {
+      return 2
+    }
+
+    if (pet.value.isLactation) {
+      return 4
+    }
+    if (pet.value.isPregnant) {
+      return 1.8
+    }
+
+    if (pet.value.isSterilization && ageInMonths > 12 && pet.value.isActive) {
+      return 1.2
+    }
+
+    if (pet.value.isActive && !pet.value.isSterilization && ageInMonths > 12) {
+      return 1.6
+    }
+
+    if (feedingPlan.value.targetWeight < pet.value.weight) {
+      return 0.8
+    }
+
+    if (feedingPlan.value.targetWeight > pet.value.weight) {
+      return 1.8
+    }
+
+    return 1
+  })
+
+  const rer = ref(0)
+
+  watch(() => pet.value.weight, () => {
+    feedingPlan.value.targetWeight = calculateIdealWeight()
+    rer.value = calculateRER(pet.value.weight)
+  })
 
   const feedingGoalOptions = [
     { value: FeedingGoal.GAIN, label: '增肥' },
@@ -72,6 +146,8 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
     savedPet.value = await createPet({
       ...pet.value,
     })
+
+    dailyCalories.value = Math.floor(rer.value * derRate.value)
   }
 
   /**

+ 0 - 6
src/uni-pages.d.ts

@@ -15,12 +15,6 @@ interface NavigateToOptions {
        "/pages/setting/index" |
        "/pages/start-filing/index" |
        "/pages/userInfo/index" |
-       "/pages/feed-questionnaire/components/FeedForm" |
-       "/pages/feed-questionnaire/components/FeedQuestionnaire" |
-       "/pages/feed-questionnaire/components/FeedSlogan" |
-       "/pages/feed-questionnaire/components/FeedStart" |
-       "/pages/feed-questionnaire/components/FeedStep" |
-       "/pages/feed-questionnaire/components/ProgressBar" |
        "/pages/pet-manual/components/CardList";
 }
 interface RedirectToOptions extends NavigateToOptions {}