Compare commits
3
Commits
1dfddbf1da
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53cf9d12ea | ||
|
|
9a4a230cc2 | ||
|
|
22f6bd7ff5 |
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
VITE_ENABLE_MOCK=false
|
||||
VITE_API_PREFIX=/api
|
||||
VITE_PROXY_ENDPOINT=https://bright.yilibili.com/api
|
||||
VITE_PROXY_ENDPOINT=http://localhost:3000
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
import type { CreatePetRequest, Pet } from '@/model/pet'
|
||||
import type { CreatePetRequest, Pet, PetVariety } from '@/model/pet'
|
||||
import httpClient from '@/api/httpClient'
|
||||
|
||||
export function createPet(createPetRequest: CreatePetRequest) {
|
||||
@@ -8,3 +8,7 @@ export function createPet(createPetRequest: CreatePetRequest) {
|
||||
export function getOwnPets() {
|
||||
return httpClient.get<Pet[]>('/pets/own')
|
||||
}
|
||||
|
||||
export function petVarietiesList() {
|
||||
return httpClient.get<PetVariety[]>('/pet-varieties/list')
|
||||
}
|
||||
@@ -12,6 +12,10 @@ const emits = defineEmits<{
|
||||
'update:modelValue': [string | number]
|
||||
}>()
|
||||
|
||||
if (props.options.length && !props.modelValue) {
|
||||
emits('update:modelValue', props.options[0].value)
|
||||
}
|
||||
|
||||
function bindPickerChange(e: { detail: { value: number | string } }) {
|
||||
const currentIndex = e.detail.value as number
|
||||
emits('update:modelValue', props.options[currentIndex].value)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { UniPopupDialogInstance } from '@uni-helper/uni-types'
|
||||
import type { UniPopupInstance } from '@uni-helper/uni-ui-types'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
withDefaults(defineProps<{
|
||||
modelValue: string | number
|
||||
placeholder?: string
|
||||
suffix?: string
|
||||
@@ -10,47 +7,18 @@ const props = withDefaults(defineProps<{
|
||||
placeholder: '请输入内容',
|
||||
})
|
||||
|
||||
const emits = defineEmits<{
|
||||
defineEmits<{
|
||||
'update:modelValue': [string | number]
|
||||
}>()
|
||||
|
||||
const uniPopupRef = ref<UniPopupInstance | null>(null)
|
||||
const uniPopupDialogRef = ref<UniPopupDialogInstance | null>(null)
|
||||
|
||||
function dialogInputConfirm(value: any) {
|
||||
if (value === '') {
|
||||
uni.showToast({
|
||||
title: props.placeholder,
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
emits('update:modelValue', value as (string | number))
|
||||
if (uniPopupRef.value && uniPopupRef.value.close) {
|
||||
uniPopupRef.value.close()
|
||||
}
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
if (uniPopupRef.value && uniPopupRef.value.open) {
|
||||
uniPopupRef.value.open()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="w-full" @click="handleClick">
|
||||
{{ modelValue }}
|
||||
<view class="w-full flex items-center gap-2">
|
||||
<input class="text-right" :value="modelValue" :placeholder="placeholder" @input="$emit('update:modelValue', $event.detail.value)">
|
||||
<text v-if="suffix">
|
||||
{{ suffix }}
|
||||
</text>
|
||||
</view>
|
||||
<uni-popup ref="uniPopupRef" type="dialog">
|
||||
<uni-popup-dialog
|
||||
ref="uniPopupDialogRef" mode="input" title="输入内容" :value="modelValue" :placeholder="placeholder"
|
||||
@confirm="dialogInputConfirm"
|
||||
/>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface Pet extends TraceableModel {
|
||||
type: PetType
|
||||
weight: number
|
||||
feedingPlan: FeedingPlan
|
||||
varietyName: string
|
||||
}
|
||||
|
||||
export interface CreatePetRequest extends Omit<Pet, keyof TraceableModel> {
|
||||
@@ -66,3 +67,7 @@ export interface CreateFeedingPlanRequest extends Omit<FeedingPlan, keyof BaseMo
|
||||
petId: string
|
||||
products: { id: string, dailyUsageWeight: number, percentage: number }[]
|
||||
}
|
||||
|
||||
export interface PetVariety extends BaseModel {
|
||||
name: string
|
||||
}
|
||||
@@ -5,7 +5,8 @@ export interface Product extends BaseModel {
|
||||
category: ProductCategory
|
||||
photo: string
|
||||
tags: string[]
|
||||
totalCalories: number
|
||||
meValue: number | null // ME值(kcal/g),直接配置的代谢能
|
||||
totalCalories: number // 产品总能量(kcal)
|
||||
totalWeight: number
|
||||
}
|
||||
export enum ProductCategory {
|
||||
|
||||
@@ -58,11 +58,7 @@ function reset() {
|
||||
function handleReady() {
|
||||
reset()
|
||||
titleName.value = '喂养问卷'
|
||||
controlFormDisplay.value.display2 = true
|
||||
setTimeout(() => {
|
||||
reset()
|
||||
controlFormDisplay.value.display3 = true
|
||||
}, 2000)
|
||||
controlFormDisplay.value.display3 = true
|
||||
}
|
||||
function handleBackFeedStart() {
|
||||
reset()
|
||||
|
||||
@@ -9,12 +9,18 @@ import ToolApi from '@/utils'
|
||||
const safeHeight = ToolApi.getSafeHeight()
|
||||
|
||||
const feedSloganBottom = ref<number>(13)
|
||||
function handleNext() {
|
||||
uni.navigateTo({ url: '/pages/feed-questionnaire/index' })
|
||||
}
|
||||
|
||||
const feedingPlanStore = useFeedingPlanStore()
|
||||
|
||||
function handleNext() {
|
||||
if (!feedingPlanStore.pet.varietyName) {
|
||||
uni.showToast({
|
||||
title: '请选择品种',
|
||||
icon: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.navigateTo({ url: '/pages/feed-questionnaire/index' })
|
||||
}
|
||||
const disabled = computed(() => {
|
||||
return feedingPlanStore.pet.type === PetType.DOG
|
||||
})
|
||||
@@ -35,9 +41,12 @@ const disabled = computed(() => {
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
<CellGroup class="w-full bg-[#fff] shadow-cell-group rounded-3 overflow-hidden">
|
||||
<Cell title="品种" border>
|
||||
<Cell title="类别" border>
|
||||
<PickerItem v-model="feedingPlanStore.pet.type" :options="feedingPlanStore.petTypeOptions" />
|
||||
</Cell>
|
||||
<Cell title="品种" border>
|
||||
<PickerItem v-model="feedingPlanStore.pet.varietyName" :options="feedingPlanStore.petVarietiesOptions" />
|
||||
</Cell>
|
||||
<Cell title="性别" border>
|
||||
<PickerItem v-model="feedingPlanStore.pet.gender" :options="feedingPlanStore.genderOptions" />
|
||||
</Cell>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { FeedingPlanProduct } from '@/model/feeding-plan'
|
||||
import type { Product } from '@/model/product'
|
||||
import { createFeedingPlan, updateFeedingPlan } from '@/api/feeding-plan'
|
||||
import { createPet } from '@/api/pet'
|
||||
import { createPet, petVarietiesList } from '@/api/pet'
|
||||
import {
|
||||
type CreateFeedingPlanRequest,
|
||||
type CreatePetRequest,
|
||||
@@ -25,6 +25,23 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
{ value: Gender.FEMALE, label: '女孩' },
|
||||
]
|
||||
|
||||
const petVarietiesOptions = ref<{
|
||||
value: string
|
||||
label: string
|
||||
}[]>([])
|
||||
|
||||
const fetchPetVarieties = async () => {
|
||||
const result = await petVarietiesList()
|
||||
petVarietiesOptions.value = result.map((item) => {
|
||||
return {
|
||||
value: item.name,
|
||||
label: item.name,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fetchPetVarieties()
|
||||
|
||||
const dailyCalories = ref(400)
|
||||
// @ts-expect-error @ts-ignore
|
||||
const pet = ref <CreatePetRequest>({
|
||||
@@ -39,6 +56,7 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
photo: '',
|
||||
type: PetType.CAT,
|
||||
weight: 0,
|
||||
varietyName: '',
|
||||
})
|
||||
|
||||
const savedPet = ref<Pet | null>(null)
|
||||
@@ -110,8 +128,9 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
return 1.2
|
||||
}
|
||||
|
||||
// 未绝育成年猫/活跃:系数1.4(根据新规则从1.6调整为1.4)
|
||||
if (pet.value.isActive && !pet.value.isSterilization && ageInMonths > 12) {
|
||||
return 1.6
|
||||
return 1.4
|
||||
}
|
||||
|
||||
if (feedingPlan.value.targetWeight < pet.value.weight) {
|
||||
@@ -127,9 +146,12 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
|
||||
const rer = ref(0)
|
||||
|
||||
watch(() => pet.value.weight, () => {
|
||||
feedingPlan.value.targetWeight = calculateIdealWeight()
|
||||
rer.value = calculateRER(pet.value.weight)
|
||||
// 监听体重和体型变化,重新计算理想体重和RER
|
||||
// RER应该使用理想体重而不是当前体重
|
||||
watch([() => pet.value.weight, () => pet.value.bodyType], () => {
|
||||
const idealWeight = calculateIdealWeight()
|
||||
feedingPlan.value.targetWeight = idealWeight
|
||||
rer.value = calculateRER(idealWeight)
|
||||
})
|
||||
|
||||
const feedingGoalOptions = [
|
||||
@@ -326,5 +348,6 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
confirm,
|
||||
initPet,
|
||||
initFeedingPlan,
|
||||
petVarietiesOptions,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,73 @@
|
||||
3.产品产能计算(ME)
|
||||
NEF:无氮浸出物(淀粉) GE(总能)DE(消化能)ME(代谢能)
|
||||
NEF(%)=1-蛋白质含量*(1-水分含量)-脂肪含量*(1-水分含量)-粗纤维*(1-水分含量)-粗灰分*(1-水分含量)-水分含量
|
||||
干物质%=1-水分含量%
|
||||
蛋白质质量=蛋白质含量值*干物质含量值
|
||||
脂肪质量=脂肪含量*干物质含量值
|
||||
粗纤维质量=粗纤维含量值*干物质含量值
|
||||
干物质中粗纤维含量占比=粗纤维质量/干物质占比*100
|
||||
步骤一:GE(kcal)=5.7*蛋白质质量+9.4*脂肪质量+4.1*(NEF+粗纤维质量)
|
||||
步骤二:能量消化率(%)=87.9-(0.88*干物质中粗纤维百分含量)
|
||||
步骤三:DE(kcal)=GE*能量消化率的百分数/100
|
||||
步骤四:ME(kcal)=DE-(0.77*蛋白质质量)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
产品具体成分见“产品成分保证值”
|
||||
举例某产品信息中:粗蛋白含量 40%,粗脂肪 19%,粗纤维2%,粗灰分 25%,水分6%
|
||||
干物质%=1-6%=94%
|
||||
NEF(%)=1-40%*(1-6%)-19%*(1-6%)-2%*(1-6%)-25%*(1-6%)-6%=13.16%
|
||||
蛋白质质量=40%*94%=0.38
|
||||
粗纤维质量=2%*94%=0.02
|
||||
粗脂肪质量=19%*94%=0.18
|
||||
干物质中粗纤维含量占比=0.02/94%*100=2.12765957
|
||||
GE(kcal)=5.7*0.38+9.4*0.18+4.1*(0.02+13.16%)=4.43212 步骤一计算完成
|
||||
能量消化率(%)=87.9-(0.88*干物质中粗纤维百分含量)
|
||||
=87.9-(0.88*2.12)=86.03 步骤二计算完成
|
||||
DE(kcal)=4.43212*86.03/100=3.82 步骤三计算完成
|
||||
ME(kcal)=DE-(0.77*蛋白质质量)
|
||||
=3.82-(0.77*0.38)=3.53 步骤四计算完成
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
4、每日喂食量计算
|
||||
计算公式:产品每日喂食量(g)=能量需求*选定产品1喂食比例/ME(产品1)
|
||||
热量需求在前面已经计算过了
|
||||
举例用户的猫咪所需要的热量需求是 300KJ,假定用户只喂养果蔬冻干,果蔬冻干在产品后台
|
||||
输入的信息是粗蛋白质 60%,粗脂肪 15%,粗灰分 10%,粗纤维6%,水分 6%
|
||||
按照上述产品产能计算流程:干物质=1-6%=94%
|
||||
NEF(%)=1-60%*(1-6%)-15%*(1-6%)-10%*(1-6%)-6%*(1-6%)-6%=8.46%
|
||||
蛋白质质量=60%*94%=0.564
|
||||
脂肪质量=15%*94%=0.141
|
||||
粗纤维质量=6%*94%=0.056
|
||||
干物质中粗纤维含量占比=0.056/94%*100=5.96
|
||||
步骤一:GE(kcal)=5.7*蛋白质质量+9.4*脂肪质量+4.1*(NEF+粗纤维质量)
|
||||
=5.7*0.564+9.4*0.141+4.1*(8.46%+0.056)=5.12
|
||||
步骤二:能量消化率(%)=87.9-(0.88*干物质中粗纤维百分含量)
|
||||
=87.9-(0.88*5.96)=82.6552
|
||||
步骤三:DE(kcal)=GE*能量消化率的百分数/100
|
||||
=5.12*82.6552/100=4.23
|
||||
步骤四:ME(kcal)=DE-(0.77*蛋白质质量)
|
||||
=4.23-(0.77*0.564)=3.79
|
||||
所以1g的果蔬冻干可以供能3.79KJ
|
||||
猫咪1天需要的能量是300KJ,这些能量全部由冻干提供,则每日需要吃的冻干=300*100%/3.79=79.2g
|
||||
|
||||
举例2:猫咪每日需要能量300KJ,吃主食餐盒和果蔬冻干,其中果蔬冻干占比60%,主食餐盒40%,1g主食餐盒提供能量为1.2KJ,1g的果蔬冻干可以供能3.79KJ
|
||||
所需果蔬冻干=300*60%/3.79=47.5g
|
||||
所需主食餐盒=300*40%/1.2=100g
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export default async ({ command, mode }) => {
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5175,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: env.VITE_PROXY_ENDPOINT,
|
||||
|
||||
Reference in new issue
Block a user