Compare commits
7
Commits
b2d41fd537
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53cf9d12ea | ||
|
|
9a4a230cc2 | ||
|
|
22f6bd7ff5 | ||
|
|
1dfddbf1da | ||
|
|
b730f7966b | ||
|
|
f99dca56ef | ||
|
|
f8cb974280 |
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
|
||||
|
||||
+2
-28
@@ -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',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import carousalApi from '@/api/carousal'
|
||||
import CardList from '@/pages/pet-manual/components/CardList.vue'
|
||||
import CardList from '../src/components/CardList.vue'
|
||||
// const searchValue = ref('')
|
||||
import bg from '@/static/image/feed-plan/bg.png'
|
||||
import circle from '@/static/image/feed-plan/circle.png'
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { Article } from '@/model/pet-manual'
|
||||
import httpClient from '@/api/httpClient'
|
||||
|
||||
export async function getArticle(id: string) {
|
||||
return httpClient.get<Article>(`/articles/${id}`)
|
||||
}
|
||||
@@ -4,3 +4,11 @@ import httpClient from '@/api/httpClient'
|
||||
export async function createFeedingPlan(createFeedingPlanRequest: CreateFeedingPlanRequest) {
|
||||
return httpClient.post<FeedingPlan>('/feeding-plans', createFeedingPlanRequest)
|
||||
}
|
||||
|
||||
export async function getFeedingPlan(id: string) {
|
||||
return httpClient.get<FeedingPlan>(`/feeding-plans/${id}`)
|
||||
}
|
||||
|
||||
export async function updateFeedingPlan(id: string, createFeedingPlanRequest: CreateFeedingPlanRequest) {
|
||||
return httpClient.put<FeedingPlan>(`/feeding-plans/${id}`, createFeedingPlanRequest)
|
||||
}
|
||||
+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')
|
||||
}
|
||||
Vendored
+7
@@ -10,13 +10,20 @@ declare module 'vue' {
|
||||
AddFeedingPlan: typeof import('./components/AddFeedingPlan.vue')['default']
|
||||
BButton: typeof import('./components/BButton.vue')['default']
|
||||
BSlider: typeof import('./components/BSlider.vue')['default']
|
||||
CardList: typeof import('./components/CardList.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']
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -34,12 +34,19 @@ function handleLoadMore() {
|
||||
}
|
||||
emit('loadMore')
|
||||
}
|
||||
|
||||
function goToArticle(id: string) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/article/detail?id=${id}`,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="flex flex-col gap-4 px-4">
|
||||
<view
|
||||
v-for="(item, index) in props.cardList" :key="index" class="bg-[white] rounded-md shadow-lg flex w-full h-[120px] overflow-hidden"
|
||||
@tap="() => goToArticle(item.id)"
|
||||
>
|
||||
<image class="w-[120px] h-[120px] rounded-l-md shrink-0" :src="item?.imageUrl || titleBg" />
|
||||
<view class="p-4 flex flex-col">
|
||||
File renamed without changes.
+17
-22
@@ -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>
|
||||
@@ -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
@@ -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>
|
||||
File renamed without changes.
@@ -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>
|
||||
|
||||
File renamed without changes.
@@ -15,13 +15,13 @@ function handleTap() {
|
||||
|
||||
<template>
|
||||
<view class="w-full relative rounded-3 overflow-hidden shadow-cell-group bg-[#fff]">
|
||||
<view v-if="operationTitle" class="w-[111px] h-[44px] bg-[#1a1a1a] absolute right-0 top-0" @tap="handleTap">
|
||||
<view v-if="operationTitle" class="w-[111px] h-[44px] bg-[#1a1a1a] absolute right-0 top-0">
|
||||
<view class="text-[#999] text-xs absolute right-4 leading-[34px]">
|
||||
{{ operationTitle }}
|
||||
</view>
|
||||
</view>
|
||||
<image class="w-[343px] h-[179px] absolute right-0 top-0 " src="@/static/image/shape-bg.png" />
|
||||
<view class="pl-4 relative flex gap-1 h-[44px] items-center text-xs">
|
||||
<image class="w-[343px] h-[179px] absolute right-0 top-0" src="@/static/image/shape-bg.png" />
|
||||
<view class="pl-4 relative flex gap-1 h-[44px] items-center text-xs" @tap="handleTap">
|
||||
<view>{{ title }}</view>
|
||||
<view v-if="subtitle" class="text-[#D9D9D9]">
|
||||
{{ subtitle }}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Paging } from '@/model/base'
|
||||
import type { BaseModel, Paging } from '@/model/base'
|
||||
import type { CreatePetRequest } from '@/model/pet'
|
||||
|
||||
export interface CreateCarousalsRequest {
|
||||
@@ -20,14 +20,13 @@ export interface ArticleParams extends Paging {
|
||||
categoryId: string
|
||||
}
|
||||
|
||||
export interface Article {
|
||||
id: string
|
||||
export interface Article extends BaseModel {
|
||||
content: string
|
||||
status: string
|
||||
title: string
|
||||
description: string
|
||||
updatedTime?: string
|
||||
imageUrl?: string
|
||||
category: Category
|
||||
}
|
||||
|
||||
export interface Recommends {
|
||||
|
||||
+9
-1
@@ -1,4 +1,5 @@
|
||||
import type { BaseModel, TraceableModel } from '@/model/base'
|
||||
import type { FeedingPlanProduct } from '@/model/feeding-plan'
|
||||
|
||||
export interface Pet extends TraceableModel {
|
||||
birthday: string
|
||||
@@ -12,6 +13,8 @@ export interface Pet extends TraceableModel {
|
||||
photo: string
|
||||
type: PetType
|
||||
weight: number
|
||||
feedingPlan: FeedingPlan
|
||||
varietyName: string
|
||||
}
|
||||
|
||||
export interface CreatePetRequest extends Omit<Pet, keyof TraceableModel> {
|
||||
@@ -57,9 +60,14 @@ export enum FeedingGoal {
|
||||
export interface FeedingPlan extends BaseModel {
|
||||
feedingGoal: FeedingGoal
|
||||
targetWeight: number
|
||||
feedingPlanProducts: FeedingPlanProduct[]
|
||||
}
|
||||
|
||||
export interface CreateFeedingPlanRequest extends Omit<FeedingPlan, keyof BaseModel> {
|
||||
petId: string
|
||||
products: { id: string, dailyUsageWeight: number }[]
|
||||
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 {
|
||||
|
||||
+9
-37
@@ -7,6 +7,11 @@
|
||||
},
|
||||
"entryPagePath": "pages/home/index",
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/article/detail",
|
||||
"type": "page",
|
||||
"style": {}
|
||||
},
|
||||
{
|
||||
"path": "pages/feed-plan/index",
|
||||
"type": "page",
|
||||
@@ -43,7 +48,8 @@
|
||||
"type": "page",
|
||||
"style": {
|
||||
"navigationBarTitleText": "喂养计算器"
|
||||
}
|
||||
},
|
||||
"layout": "custom"
|
||||
},
|
||||
{
|
||||
"path": "pages/home/index",
|
||||
@@ -78,47 +84,13 @@
|
||||
"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",
|
||||
"style": {}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import type { Article } from '@/model/pet-manual'
|
||||
import { getArticle } from '@/api/article'
|
||||
|
||||
const article = ref<Article | null>()
|
||||
|
||||
const id = ref('')
|
||||
|
||||
onLoad((options) => {
|
||||
id.value = options!.id as string
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
async function fetchData() {
|
||||
article.value = await getArticle(id.value)
|
||||
await uni.setNavigationBarTitle({
|
||||
title: article.value.category.name,
|
||||
})
|
||||
}
|
||||
|
||||
const fixedContent = computed(() => {
|
||||
if (!article.value) {
|
||||
return ''
|
||||
}
|
||||
return article.value.content.replace(/<img/g, '<img class="w-full"')
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-if="article" class="w-full h-screen p-4 bg-[#F5F6F7]">
|
||||
<view class="mb-2 text-xl font-semibold">
|
||||
{{ article.title }}
|
||||
</view>
|
||||
<view class="flex text-xs text-[#999] mb-6">
|
||||
<view>{{ article.createdTime }}</view>
|
||||
</view>
|
||||
<rich-text :nodes="fixedContent" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -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,12 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { getFeedingPlan } from '@/api/feeding-plan'
|
||||
import { getOwnPets } from '@/api/pet'
|
||||
import { type Pet, PetType } from '@/model/pet'
|
||||
import { type FeedingPlan, type Pet, PetType } from '@/model/pet'
|
||||
import { watch } from 'vue'
|
||||
|
||||
const pets = ref<Pet[]>([])
|
||||
async function fetchPets() {
|
||||
pets.value = await getOwnPets()
|
||||
}
|
||||
|
||||
const feedingPlan = ref<FeedingPlan | null>(null)
|
||||
|
||||
const currentIndex = ref(0)
|
||||
const currentPet = computed(() => pets.value[currentIndex.value])
|
||||
|
||||
@@ -20,10 +24,44 @@ const petTags = computed(() => {
|
||||
]
|
||||
})
|
||||
|
||||
function selectPet(index: number) {
|
||||
watch(currentPet, async () => {
|
||||
if (currentPet.value && currentPet.value.feedingPlan) {
|
||||
feedingPlan.value = await getFeedingPlan(currentPet.value.feedingPlan.id)
|
||||
}
|
||||
else {
|
||||
feedingPlan.value = null
|
||||
}
|
||||
})
|
||||
|
||||
async function selectPet(index: number) {
|
||||
currentIndex.value = index
|
||||
}
|
||||
|
||||
const feedingPlanStore = useFeedingPlanStore()
|
||||
|
||||
async function handleAddFeedingPlan() {
|
||||
feedingPlanStore.initPet(currentPet.value)
|
||||
uni.navigateTo({
|
||||
url: '/pages/feed-plan-calculator/index',
|
||||
})
|
||||
}
|
||||
|
||||
function handleAddPet() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/start-filing/index',
|
||||
})
|
||||
}
|
||||
|
||||
async function handleEdit() {
|
||||
if (!feedingPlan.value)
|
||||
return
|
||||
feedingPlanStore.initPet(currentPet.value)
|
||||
feedingPlanStore.initFeedingPlan(feedingPlan.value)
|
||||
uni.navigateTo({
|
||||
url: '/pages/feed-plan-calculator/index',
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(fetchPets)
|
||||
</script>
|
||||
|
||||
@@ -41,9 +79,9 @@ onMounted(fetchPets)
|
||||
{{ item.name }}
|
||||
<view v-if="index === currentIndex" class="absolute w-[30%] h-[3px] bg-primary bottom-[-4px] rounded-full" />
|
||||
</view>
|
||||
<image src="@/static/icons/plus-circle.svg" class="w-[24px] h-[24px]" />
|
||||
<image src="@/static/icons/plus-circle.svg" class="w-[24px] h-[24px]" @tap="handleAddPet" />
|
||||
</template>
|
||||
<view v-else class="text-primary text-xl relative flex justify-center font-semibold">
|
||||
<view v-else class="text-primary text-xl relative flex justify-center font-semibold" @tap="handleAddPet">
|
||||
待添加
|
||||
</view>
|
||||
</view>
|
||||
@@ -61,78 +99,17 @@ onMounted(fetchPets)
|
||||
</view>
|
||||
<image class="w-[20px] h-[20px]" src="@/static/icons/edit.svg" />
|
||||
</view>
|
||||
<view class="w-full relative rounded-3 overflow-hidden shadow-cell-group bg-[#fff]">
|
||||
<view class="w-[111px] h-[44px] bg-[#1a1a1a] absolute right-0 top-0">
|
||||
<view class="text-[#999] text-xs absolute right-4 leading-[34px]">
|
||||
编辑计划
|
||||
<SectionCard v-if="feedingPlan" title="喂养计划" subtitle="FEEDING PLAN" operation-title="编辑计划" :on-operation-click="handleEdit">
|
||||
<ProductReadonlyItem v-for="item in feedingPlan.feedingPlanProducts" :key="item.product.id" :data="item" />
|
||||
</SectionCard>
|
||||
<SectionCard v-else title="喂养计划" subtitle="FEEDING PLAN" operation-title="无计划">
|
||||
<view class="w-full h-[120px] flex flex-col items-center justify-center gap-1.5" @tap="handleAddFeedingPlan">
|
||||
<image src="@/static/icons/plus-circle-2.svg" class="w-[47px] h-[47px]" />
|
||||
<view class="text-xs text-disabled">
|
||||
添加您的喂养计划
|
||||
</view>
|
||||
</view>
|
||||
<image class="w-[343px] h-[179px] absolute right-0 top-0 " src="@/static/image/shape-bg.png" />
|
||||
<view class="pl-4 relative flex gap-1 h-[44px] items-center text-xs">
|
||||
<view>喂养计划</view>
|
||||
<view class="text-[#D9D9D9]">
|
||||
FEEDING PLAN
|
||||
</view>
|
||||
</view>
|
||||
<view class="py-4 pl-2 pr-8 w-full flex gap-3 relative items-center border-b-[1px] border-[#E7E7E7] last-of-type:border-0">
|
||||
<image src="@/static/image/product-default.png" class="w-[80px] h-[80px]" />
|
||||
<view class="flex-1 flex flex-col justify-between h-[80px] py-2">
|
||||
<view class="font-semibold">
|
||||
MINI主食包
|
||||
</view>
|
||||
<view class="flex gap-2">
|
||||
<view class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75">
|
||||
湿粮
|
||||
</view>
|
||||
<view class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75">
|
||||
湿粮
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-right">
|
||||
<view class="text-xs font-semibold">
|
||||
每日
|
||||
</view>
|
||||
<view class="text-xl font-bold mb-4">
|
||||
500<text class="text-xs font-medium">
|
||||
g
|
||||
</text>
|
||||
</view>
|
||||
<view class="text-[9px] text-[#CDCDCD]">
|
||||
1200Kcal
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="py-4 pl-2 pr-8 w-full flex gap-3 relative items-center border-b-[1px] border-[#E7E7E7] last-of-type:border-0">
|
||||
<image src="@/static/image/product-default.png" class="w-[80px] h-[80px]" />
|
||||
<view class="flex-1 flex flex-col justify-between h-[80px] py-2">
|
||||
<view class="font-semibold">
|
||||
MINI主食包
|
||||
</view>
|
||||
<view class="flex gap-2">
|
||||
<view class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75">
|
||||
湿粮
|
||||
</view>
|
||||
<view class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75">
|
||||
湿粮
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-right">
|
||||
<view class="text-xs font-semibold">
|
||||
每日
|
||||
</view>
|
||||
<view class="text-xl font-bold mb-4">
|
||||
500<text class="text-xs font-medium">
|
||||
g
|
||||
</text>
|
||||
</view>
|
||||
<view class="text-[9px] text-[#CDCDCD]">
|
||||
1200Kcal
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</SectionCard>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -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,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,
|
||||
@@ -52,11 +58,7 @@ function reset() {
|
||||
function handleReady() {
|
||||
reset()
|
||||
titleName.value = '喂养问卷'
|
||||
controlFormDisplay.value.display2 = true
|
||||
setTimeout(() => {
|
||||
reset()
|
||||
controlFormDisplay.value.display3 = true
|
||||
}, 3000)
|
||||
controlFormDisplay.value.display3 = true
|
||||
}
|
||||
function handleBackFeedStart() {
|
||||
reset()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { Paging } from '@/model/base'
|
||||
import type { Article, ArticleParams, Category, CreateCarousalsRequest, Recommends } from '@/model/pet-manual'
|
||||
import carousalApi from '@/api/carousal'
|
||||
import CardList from '@/pages/pet-manual/components/CardList.vue'
|
||||
import CardList from '@/components/CardList.vue'
|
||||
import circle from '@/static/image/feed-plan/circle.png'
|
||||
import message from '@/static/image/feed-plan/message.png'
|
||||
import ToolApi from '@/utils'
|
||||
|
||||
@@ -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'
|
||||
@@ -8,16 +9,27 @@ import ToolApi from '@/utils'
|
||||
const safeHeight = ToolApi.getSafeHeight()
|
||||
|
||||
const feedSloganBottom = ref<number>(13)
|
||||
|
||||
const feedingPlanStore = useFeedingPlanStore()
|
||||
function handleNext() {
|
||||
if (!feedingPlanStore.pet.varietyName) {
|
||||
uni.showToast({
|
||||
title: '请选择品种',
|
||||
icon: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.navigateTo({ url: '/pages/feed-questionnaire/index' })
|
||||
}
|
||||
|
||||
const { pet, petTypeOptions, genderOptions } = 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 +37,35 @@ 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="feedingPlanStore.pet.type" :options="feedingPlanStore.petTypeOptions" />
|
||||
</Cell>
|
||||
<Cell title="品种" border>
|
||||
<PickerItem v-model="pet.type" :options="petTypeOptions" />
|
||||
<PickerItem v-model="feedingPlanStore.pet.varietyName" :options="feedingPlanStore.petVarietiesOptions" />
|
||||
</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>
|
||||
|
||||
@@ -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>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
+155
-5
@@ -1,11 +1,12 @@
|
||||
import type { FeedingPlanProduct } from '@/model/feeding-plan'
|
||||
import type { Product } from '@/model/product'
|
||||
import { createFeedingPlan } from '@/api/feeding-plan'
|
||||
import { createPet } from '@/api/pet'
|
||||
import { createFeedingPlan, updateFeedingPlan } from '@/api/feeding-plan'
|
||||
import { createPet, petVarietiesList } from '@/api/pet'
|
||||
import {
|
||||
type CreateFeedingPlanRequest,
|
||||
type CreatePetRequest,
|
||||
FeedingGoal,
|
||||
type FeedingPlan,
|
||||
Gender,
|
||||
type Pet,
|
||||
PetBodyType,
|
||||
@@ -24,8 +25,25 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
{ value: Gender.FEMALE, label: '女孩' },
|
||||
]
|
||||
|
||||
const dailyCalories = ref(400)
|
||||
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>({
|
||||
birthday: new Date().toISOString().split('T')[0],
|
||||
bodyType: PetBodyType.IDEAL,
|
||||
@@ -38,6 +56,7 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
photo: '',
|
||||
type: PetType.CAT,
|
||||
weight: 0,
|
||||
varietyName: '',
|
||||
})
|
||||
|
||||
const savedPet = ref<Pet | null>(null)
|
||||
@@ -50,12 +69,90 @@ 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
|
||||
}
|
||||
|
||||
// 未绝育成年猫/活跃:系数1.4(根据新规则从1.6调整为1.4)
|
||||
if (pet.value.isActive && !pet.value.isSterilization && ageInMonths > 12) {
|
||||
return 1.4
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
// 监听体重和体型变化,重新计算理想体重和RER
|
||||
// RER应该使用理想体重而不是当前体重
|
||||
watch([() => pet.value.weight, () => pet.value.bodyType], () => {
|
||||
const idealWeight = calculateIdealWeight()
|
||||
feedingPlan.value.targetWeight = idealWeight
|
||||
rer.value = calculateRER(idealWeight)
|
||||
})
|
||||
|
||||
const feedingGoalOptions = [
|
||||
{ value: FeedingGoal.GAIN, label: '增肥' },
|
||||
@@ -72,6 +169,8 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
savedPet.value = await createPet({
|
||||
...pet.value,
|
||||
})
|
||||
|
||||
dailyCalories.value = Math.floor(rer.value * derRate.value)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,6 +243,8 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
})
|
||||
}
|
||||
|
||||
const isEdit = ref(false)
|
||||
|
||||
/**
|
||||
* 修改指定 productId 的 percentage
|
||||
* @param productId 产品的id
|
||||
@@ -169,6 +270,7 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
arrangeDailyConsumeWeight()
|
||||
}
|
||||
}
|
||||
const savedFeedingPlan = ref<FeedingPlan | null>(null)
|
||||
|
||||
const confirm = async () => {
|
||||
if (savedPet.value === null) {
|
||||
@@ -180,9 +282,54 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
return {
|
||||
id: item.product.id,
|
||||
dailyUsageWeight: item.dailyUsageWeight,
|
||||
percentage: item.percentage,
|
||||
}
|
||||
})
|
||||
await createFeedingPlan(feedingPlan.value)
|
||||
|
||||
if ((isEdit.value && savedFeedingPlan.value)) {
|
||||
await updateFeedingPlan(savedFeedingPlan.value.id, feedingPlan.value)
|
||||
}
|
||||
else {
|
||||
await createFeedingPlan(feedingPlan.value)
|
||||
}
|
||||
}
|
||||
|
||||
const initPet = (payload: Pet) => {
|
||||
// @ts-expect-error @ts-ignore
|
||||
pet.value = {
|
||||
birthday: payload.birthday,
|
||||
bodyType: payload.bodyType,
|
||||
gender: payload.gender,
|
||||
isActive: payload.isActive,
|
||||
isLactation: payload.isLactation,
|
||||
isPregnant: payload.isPregnant,
|
||||
isSterilization: payload.isSterilization,
|
||||
name: payload.name,
|
||||
photo: payload.photo,
|
||||
type: payload.type,
|
||||
weight: payload.weight,
|
||||
}
|
||||
savedPet.value = payload
|
||||
feedingPlan.value.targetWeight = calculateIdealWeight()
|
||||
rer.value = calculateRER(pet.value.weight)
|
||||
}
|
||||
|
||||
const initFeedingPlan = (payload: FeedingPlan) => {
|
||||
// @ts-expect-error @ts-ignore
|
||||
feedingPlan.value = {
|
||||
feedingGoal: payload.feedingGoal,
|
||||
targetWeight: payload.targetWeight,
|
||||
petId: savedPet.value?.id || '',
|
||||
products: payload.feedingPlanProducts.map((item) => {
|
||||
return {
|
||||
id: item.product.id,
|
||||
dailyUsageWeight: item.dailyUsageWeight,
|
||||
}
|
||||
}),
|
||||
}
|
||||
savedFeedingPlan.value = payload
|
||||
selectedProducts.value = payload.feedingPlanProducts
|
||||
dailyCalories.value = Math.floor(rer.value * derRate.value)
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -199,5 +346,8 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
|
||||
changePercentage,
|
||||
dailyCalories,
|
||||
confirm,
|
||||
initPet,
|
||||
initFeedingPlan,
|
||||
petVarietiesOptions,
|
||||
}
|
||||
})
|
||||
Vendored
+3
-9
@@ -4,7 +4,8 @@
|
||||
// Generated by vite-plugin-uni-pages
|
||||
|
||||
interface NavigateToOptions {
|
||||
url: "/pages/feed-plan/index" |
|
||||
url: "/pages/article/detail" |
|
||||
"/pages/feed-plan/index" |
|
||||
"/pages/feed-plan-calculator/choose-product" |
|
||||
"/pages/feed-plan-calculator/confirm" |
|
||||
"/pages/feed-plan-calculator/index" |
|
||||
@@ -14,14 +15,7 @@ interface NavigateToOptions {
|
||||
"/pages/pet-manual/index" |
|
||||
"/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";
|
||||
"/pages/userInfo/index";
|
||||
}
|
||||
interface RedirectToOptions extends NavigateToOptions {}
|
||||
|
||||
|
||||
@@ -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