10 Commits
56 changed files with 1337 additions and 352 deletions

No files matched your search

+1 -1
View File
@@ -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
+18 -20
View File
@@ -18,11 +18,12 @@ export default defineUniPages({
},
},
{
path: 'pages/feed-calculator/index',
path: 'pages/feed-questionnaire/index',
type: 'page',
style: {
navigationBarTitleText: '喂养计算器',
},
layout: 'custom',
},
{
path: 'pages/feed-plan/index',
@@ -58,38 +59,35 @@ export default defineUniPages({
style: {
navigationBarTitleText: '开始建档',
},
layout: 'custom',
},
{
path: 'pages/userInfo/index',
type: 'page',
},
{
path: 'pages/feed-calculator/components/FeedSlogan',
path: 'pages/feed-plan-calculator/index',
type: 'page',
style: {
navigationBarTitleText: '喂养问卷',
},
layout: 'custom',
},
{
path: 'pages/feed-calculator/components/FeedForm',
path: 'pages/feed-plan-calculator/choose-product',
type: 'page',
style: {
navigationBarTitleText: '喂养问卷',
},
layout: 'custom',
},
{
path: 'pages/feed-calculator/components/FeedQuestionnaire',
type: 'page',
},
{
path: 'pages/feed-calculator/components/FeedStart',
type: 'page',
},
{
path: 'pages/feed-calculator/components/FeedStep',
type: 'page',
},
{
path: 'pages/feed-calculator/components/ProgressBar',
type: 'page',
},
{
path: 'pages/pet-manual/components/CardList',
path: 'pages/feed-plan-calculator/confirm',
type: 'page',
style: {
navigationBarTitleText: '喂养问卷',
},
layout: 'custom',
},
],
globalStyle: {
+1 -1
View File
@@ -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'
+1 -5
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useAppStore } from '@/stores/app'
import {useAppStore} from '@/stores/app'
onLaunch(() => {
const authStore = useAppStore()
@@ -8,7 +8,3 @@ onLaunch(() => {
}
})
</script>
<template>
<TabBar />
</template>
+6
View File
@@ -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}`)
}
+14
View File
@@ -0,0 +1,14 @@
import type { CreateFeedingPlanRequest, FeedingPlan } from '@/model/pet'
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)
}
+6 -2
View File
@@ -1,10 +1,14 @@
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) {
return httpClient.post('/pets', createPetRequest)
return httpClient.post<Pet>('/pets', createPetRequest)
}
export function getOwnPets() {
return httpClient.get<Pet[]>('/pets/own')
}
export function petVarietiesList() {
return httpClient.get<PetVariety[]>('/pet-varieties/list')
}
+6
View File
@@ -0,0 +1,6 @@
import type {Product} from '@/model/product'
import httpClient from '@/api/httpClient'
export function fetchProductList() {
return httpClient.get<Product[]>('/products/list')
}
+13
View File
@@ -7,11 +7,24 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
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']
}
+14
View File
@@ -0,0 +1,14 @@
<script setup lang="ts">
</script>
<template>
<view class="w-full h-[135px] bg-white shadow-cell-group rounded-xl flex flex-col justify-center items-center gap-[5px] text-xs text-disabled">
<image src="@/static/icons/plus-circle-2.svg" class="w-[47px] h-[47px]" />
添加
</view>
</template>
<style scoped>
</style>
+28
View File
@@ -0,0 +1,28 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
disabled: boolean
type: 'primary' | 'default'
}>(), {
disabled: false,
type: 'primary',
})
</script>
<template>
<button
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,
'bg-primary button-shadow': !disabled && type === 'primary',
}"
>
<slot />
</button>
</template>
<style scoped>
.button-shadow {
box-shadow: 0 4px 12px 0 rgba(69, 69, 229, 0.30);
}
</style>
+102
View File
@@ -0,0 +1,102 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
modelValue: number
splitNumber?: number
step?: number
readonly?: boolean
}>(), {
splitNumber: 9,
step: 10,
readonly: false,
})
const emit = defineEmits<{
'update:modelValue': [number]
'change': [number]
}>()
// 将内部状态通过 update:modelValue 通知父组件
function updateValue(val: number) {
// 限制取值在 [0, 100] 之间
val = Math.max(0, Math.min(val, 100))
// 通知父组件 (v-model)
emit && emit('update:modelValue', val)
emit && emit('change', val)
}
const trackLeft = ref(0) // 轨道的X起点
const trackWidth = ref(0) // 轨道的宽度
onMounted(() => {
const instance = getCurrentInstance()
if (!instance)
return
uni.createSelectorQuery().in(instance.proxy).select('.slider-wrapper').boundingClientRect((data) => {
if (Array.isArray(data))
return
trackLeft.value = data.left || 0
trackWidth.value = data.width || 0
}).exec()
})
function onTouchStart(e: Event) {
e.preventDefault()
}
function onTouchMove(e: any) {
if (props.readonly)
return
// 1. 获取当前触点X坐标
const pageX = e.touches[0].pageX
// 2. 计算相对于轨道左侧的距离
const delta = pageX - trackLeft.value
// 3. 转化为 0~1 的进度,再*100变成百分比
let percent = (delta / trackWidth.value) * 100
// 4. 对 percent 进行 step 吸附(step默认为10,即0%、10%、20%等)
if (props.step > 0) {
const stepCount = Math.round(percent / props.step) // 离哪个step更近
percent = stepCount * props.step
}
// 5. 更新 currentValue 并emit通知父组件
updateValue(percent)
}
function onTouchEnd(e: Event) {
e.preventDefault()
}
</script>
<template>
<view
class="h-[8px] slider-wrapper rounded-full bg-[#E7E7E7] relative flex items-center" @touchstart="onTouchStart"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
>
<view class="w-full h-full flex justify-around items-center absolute left-0 top-0 z-0">
<view v-for="i of splitNumber" :key="i" class="w-1 h-1.5 bg-disabled" />
</view>
<view
class="h-full absolute left-0 top-0 z-1 bg-primary rounded-full" :style="{
width: `${modelValue}%`,
}"
/>
<view
v-if="!readonly"
class="w-[14px] h-[14px] rounded-full slider-thumb bg-[white] absolute left-0 z-2" :style="{
left: `calc(${modelValue}% - 7px)`,
}"
/>
</view>
</template>
<style scoped>
.slider-thumb {
box-shadow: 0 0 6px 0 rgba(69, 69, 229, 0.53);
}
</style>
@@ -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">
@@ -1,8 +1,7 @@
<script setup lang="ts">
import type { FeedFormQuestions, PetCard, StepInfo, UserList } from '@/model/pet-manual'
import FeedForm from '@/pages/feed-calculator/components/FeedForm.vue'
import FeedSlogan from '@/pages/feed-calculator/components/FeedSlogan.vue'
import ProgressBar from '@/pages/feed-calculator/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)
}
@@ -67,14 +63,20 @@ function handleAnswer(answer: PetCard) {
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 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] ">
@@ -89,7 +91,7 @@ function handleAnswer(answer: PetCard) {
</view>
</view>
</view>
<CellGroup>
<CellGroup class="w-full">
<Cell title="喂养目标" border>
<PickerItem v-model="feedingPlanStore.feedingPlan.feedingGoal" :options="feedingPlanStore.feedingGoalOptions" />
</Cell>
@@ -98,7 +100,7 @@ function handleAnswer(answer: PetCard) {
</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]">
<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>
+12
View File
@@ -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>
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { StepInfo } from '@/model/pet-manual'
import FeedStep from '@/pages/feed-calculator/components/FeedStep.vue'
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">
<button 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">
准备好了
</button>
</BButton>
</view>
<FeedSlogan />
</template>
<style scoped>
+4
View File
@@ -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)
+4 -36
View File
@@ -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>
+40
View File
@@ -0,0 +1,40 @@
<script setup lang="ts">
import type { FeedingPlanProduct } from '@/model/feeding-plan'
defineProps<{
data: FeedingPlanProduct
}>()
</script>
<template>
<view class="pl-2.5 py-4 pr-5 rounded-xl bg-white shadow-cell-group flex items-center">
<image :src="data.product.photo" class="w-[120px] h-[120px]" />
<view class="flex-1 flex flex-col justify-between h-[80px] py-2">
<view class="font-semibold">
{{ data.product.name }}
</view>
<view class="flex gap-2">
<view v-for="tag in data.product.tags" :key="tag" class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75 text-xs">
{{ tag }}
</view>
</view>
</view>
<view class="text-right">
<view class="text-xs font-semibold">
每日
</view>
<view class="text-xl font-bold mb-4">
{{ data.dailyUsageWeight }}<text class="text-xs font-medium">
g
</text>
</view>
<view class="text-[9px] text-[#CDCDCD]">
{{ data.product.totalCalories }}Kcal
</view>
</view>
</view>
</template>
<style scoped>
</style>
+40
View File
@@ -0,0 +1,40 @@
<script setup lang="ts">
import type { FeedingPlanProduct } from '@/model/feeding-plan'
defineProps<{
data: FeedingPlanProduct
}>()
</script>
<template>
<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="data.product.photo" class="w-[80px] h-[80px]" />
<view class="flex-1 flex flex-col justify-between h-[80px] py-2">
<view class="font-semibold">
{{ data.product.name }}
</view>
<view class="flex gap-2">
<view v-for="tag in data.product.tags" :key="tag" class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75 text-xs">
{{ tag }}
</view>
</view>
</view>
<view class="text-right">
<view class="text-xs font-semibold">
每日
</view>
<view class="text-xl font-bold mb-4">
{{ data.dailyUsageWeight }}<text class="text-xs font-medium">
g
</text>
</view>
<view class="text-[9px] text-[#CDCDCD]">
{{ data.product.totalCalories }}Kcal
</view>
</view>
</view>
</template>
<style scoped>
</style>
+38
View File
@@ -0,0 +1,38 @@
<script setup lang="ts">
const props = defineProps<{
title: string
subtitle?: string
onOperationClick?: () => void
operationTitle?: string
}>()
function handleTap() {
if (props.onOperationClick) {
props.onOperationClick()
}
}
</script>
<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">
<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" @tap="handleTap">
<view>{{ title }}</view>
<view v-if="subtitle" class="text-[#D9D9D9]">
{{ subtitle }}
</view>
</view>
<view class="relative">
<slot />
</view>
</view>
</template>
<style scoped>
</style>
+11
View File
@@ -0,0 +1,11 @@
<script setup lang="ts"></script>
<template>
<view class="w-screen h-screen overflow-y-auto pb-safe-bottom relative bg-regular">
<slot />
</view>
</template>
<style scoped>
</style>
+7
View File
@@ -0,0 +1,7 @@
import type { Product } from '@/model/product'
export interface FeedingPlanProduct {
percentage: number
dailyUsageWeight: number
product: Product
}
+3 -4
View File
@@ -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 {
+10
View File
@@ -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,7 +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, percentage: number }[]
}
export interface PetVariety extends BaseModel {
name: string
}
+15
View File
@@ -0,0 +1,15 @@
import type { BaseModel } from '@/model/base'
export interface Product extends BaseModel {
name: string
category: ProductCategory
photo: string
tags: string[]
meValue: number | null // ME值(kcal/g),直接配置的代谢能
totalCalories: number // 产品总能量(kcal)
totalWeight: number
}
export enum ProductCategory {
DRY_FOOD = '干粮',
WET_FOOD = '湿粮',
}
+36 -40
View File
@@ -8,11 +8,9 @@
"entryPagePath": "pages/home/index",
"pages": [
{
"path": "pages/feed-calculator/index",
"path": "pages/article/detail",
"type": "page",
"style": {
"navigationBarTitleText": "喂养计算器"
}
"style": {}
},
{
"path": "pages/feed-plan/index",
@@ -21,6 +19,38 @@
"navigationBarTitleText": "喂养计划"
}
},
{
"path": "pages/feed-plan-calculator/choose-product",
"type": "page",
"style": {
"navigationBarTitleText": "喂养问卷"
},
"layout": "custom"
},
{
"path": "pages/feed-plan-calculator/confirm",
"type": "page",
"style": {
"navigationBarTitleText": "喂养问卷"
},
"layout": "custom"
},
{
"path": "pages/feed-plan-calculator/index",
"type": "page",
"style": {
"navigationBarTitleText": "喂养问卷"
},
"layout": "custom"
},
{
"path": "pages/feed-questionnaire/index",
"type": "page",
"style": {
"navigationBarTitleText": "喂养计算器"
},
"layout": "custom"
},
{
"path": "pages/home/index",
"type": "page",
@@ -54,47 +84,13 @@
"type": "page",
"style": {
"navigationBarTitleText": "开始建档"
}
},
"layout": "custom"
},
{
"path": "pages/userInfo/index",
"type": "page",
"style": {}
},
{
"path": "pages/feed-calculator/components/FeedForm",
"type": "page",
"style": {}
},
{
"path": "pages/feed-calculator/components/FeedQuestionnaire",
"type": "page",
"style": {}
},
{
"path": "pages/feed-calculator/components/FeedSlogan",
"type": "page",
"style": {}
},
{
"path": "pages/feed-calculator/components/FeedStart",
"type": "page",
"style": {}
},
{
"path": "pages/feed-calculator/components/FeedStep",
"type": "page",
"style": {}
},
{
"path": "pages/feed-calculator/components/ProgressBar",
"type": "page",
"style": {}
},
{
"path": "pages/pet-manual/components/CardList",
"type": "page",
"style": {}
}
],
"globalStyle": {
+46
View File
@@ -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>
@@ -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>
@@ -0,0 +1,53 @@
<script setup lang="ts">
import type { Product } from '@/model/product'
import { useFeedingPlanStore } from '@/stores/feeding-plan'
import { useProductStore } from '@/stores/product'
const productStore = useProductStore()
onMounted(() => {
productStore.fetchAllProducts()
})
const feedingPlanStore = useFeedingPlanStore()
function selectProduct(product: Product) {
feedingPlanStore.addProductToSelected(product)
uni.navigateBack()
}
</script>
<template>
<view class="w-full h-full overflow-y-auto bg-regular px-4 py-5">
<view class="w-full flex gap-2">
<view
v-for="category in productStore.categoryList" :key="category.value" class="rounded-t-xl px-4 py-[9px] font-semibold" :class="{
'bg-white ': category.value === productStore.currentProductCategory,
'bg-disabled text-white': category.value !== productStore.currentProductCategory,
}"
@tap="() => productStore.switchCurrentProductCategory(category.value)"
>
{{ category.label }}
</view>
</view>
<view class="w-full bg-white rounded-tr-xl shadow-cell-group">
<view v-for="product in productStore.productList" :key="product.id" class="py-4 px-8 flex gap-3 items-center border-b-1" @tap="() => selectProduct(product)">
<image :src="product.photo" class="w-[80px] h-[80px]" />
<view class="h-full flex flex-col gap-4">
<view class="font-semibold">
{{ product.name }}
</view>
<view class="flex gap-2">
<view v-for="tag in product.tags" :key="tag" class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75">
{{ tag }}
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<style scoped>
</style>
@@ -0,0 +1,54 @@
<script setup lang="ts">
import ProductReadonlyItem from '@/components/ProductReadonlyItem.vue'
const feedingPlanStore = useFeedingPlanStore()
async function handleConfirm() {
await feedingPlanStore.confirm()
uni.navigateTo({
url: '/pages/feed-plan/index',
})
}
</script>
<template>
<view class="p-4 flex flex-col items-center gap-4">
<view v-if="feedingPlanStore.pet" class="shadow-cell-group w-full px-4 py-8 bg-[white] rounded-3 flex items-center gap-4">
<image class="w-[64px] h-[64px] rounded-full" src="@/static/image/pet-default-avatar.png" />
<view class="flex-1">
<view class="font-semibold mb-1.5">
{{ feedingPlanStore.pet.name }}
</view>
<view class="flex gap-2 flex-wrap">
<view v-for="petTag in feedingPlanStore.petTags" :key="petTag.key" class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75 text-[#000] text-xs">
{{ petTag.value }}
</view>
</view>
</view>
<image class="w-[99px] h-[101px]" src="@/static/svg/complete-badge.svg" />
</view>
<SectionCard v-if="feedingPlanStore.selectedProducts.length" class="w-full" title="产品比例" subtitle="FEEDING PLAN" operation-title="重新编辑">
<view v-for="(item, index) in feedingPlanStore.selectedProducts" :key="item.product.id" class="p-4 flex flex-col gap-3">
<view class="w-full flex justify-between">
<view class="font-semibold">
{{ item.product.name }}
</view>
<view class="w-[48px] h-[28px] flex items-center justify-center rounded-1 bg-[#f3f3f3] font-semibold">
{{ feedingPlanStore.selectedProducts[index].percentage }}%
</view>
</view>
<BSlider readonly :model-value="item.percentage" @change="(value) => feedingPlanStore.changePercentage(item.product.id, value)" />
</view>
</SectionCard>
<view v-if="feedingPlanStore.selectedProducts.length" class="w-full relative rounded-3 overflow-hidden shadow-cell-group bg-[#fff]">
<ProductReadonlyItem v-for="item in feedingPlanStore.selectedProducts" :key="item.product.id" :data="item" />
</view>
<BButton class="fixed bottom-6 mb-safe-bottom z-3" @tap="handleConfirm">
确认
</BButton>
</view>
</template>
<style scoped>
</style>
+67
View File
@@ -0,0 +1,67 @@
<script setup lang="ts">
import AddFeedingPlan from '@/components/AddFeedingPlan.vue'
import ProductItem from '@/components/ProductItem.vue'
import { useFeedingPlanStore } from '@/stores/feeding-plan'
function goToChooseProductPage() {
uni.navigateTo({
url: '/pages/feed-plan-calculator/choose-product',
})
}
const feedingPlanStore = useFeedingPlanStore()
function handleNext() {
uni.navigateTo({
url: '/pages/feed-plan-calculator/confirm',
})
}
</script>
<template>
<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">
{{ feedingPlanStore.dailyCalories }}<text class="text-[24px] font-semibold">
Kcal
</text>
</view>
<view class="font-semibold">
总热量
</view>
<view v-if="!feedingPlanStore.selectedProducts.length" class="text-xs text-disabled font-semibold">
(未添加产品)
</view>
</view>
<image src="@/static/svg/plate.svg" class="w-[289px] h-[176px] mb-[50px]" />
<view class="w-full px-4 mb-[52px] flex flex-col gap-3">
<SectionCard v-if="feedingPlanStore.selectedProducts.length" title="产品比例" subtitle="FEEDING PLAN" operation-title="推荐比例">
<view v-for="(item, index) in feedingPlanStore.selectedProducts" :key="item.product.id" class="p-4 flex flex-col gap-3">
<view class="w-full flex justify-between">
<view class="font-semibold">
{{ item.product.name }}
</view>
<view class="w-[48px] h-[28px] flex items-center justify-center rounded-1 bg-[#f3f3f3] font-semibold">
{{ feedingPlanStore.selectedProducts[index].percentage }}%
</view>
</view>
<BSlider :model-value="item.percentage" @change="(value) => feedingPlanStore.changePercentage(item.product.id, value)" />
</view>
</SectionCard>
<ProductItem v-for="item in feedingPlanStore.selectedProducts" :key="item.product.id" :data="item" />
<AddFeedingPlan @tap="goToChooseProductPage" />
</view>
<BButton class="fixed bottom-6 mb-safe-bottom z-3" :disabled="!feedingPlanStore.selectedProducts.length" @tap="handleNext">
下一步
</BButton>
</view>
</template>
<style scoped>
.gradient-text {
background: linear-gradient(180deg, #151515 0%, #7B7B7B 100%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
</style>
+93 -154
View File
@@ -1,179 +1,118 @@
<script setup lang="ts">
import type { Pet } from '@/model/pet'
import { getFeedingPlan } from '@/api/feeding-plan'
import { getOwnPets } from '@/api/pet'
import avatar from '@/static/image/pet-parameters/avatar.png'
import addBtn from '@/static/image/pet-plan/add_btn.png'
import card from '@/static/image/pet-plan/card.png'
import editBtn from '@/static/image/pet-plan/edit.png'
import userAddBtn from '@/static/image/pet-plan/user_add_btn.png'
interface User {
name: string
image: string
label: string[]
isClick: boolean
plan: { image: string, name: string, weight: string, energy: string, label: string[] }[]
}
import { type FeedingPlan, type Pet, PetType } from '@/model/pet'
import { watch } from 'vue'
const pets = ref<Pet[]>([])
async function fetchPets() {
pets.value = await getOwnPets()
}
onMounted(fetchPets)
const feedingPlan = ref<FeedingPlan | null>(null)
const userList = ref<User[]>([])
const clickUser = computed(() => {
return userList.value.filter(user => user.isClick === true)
const currentIndex = ref(0)
const currentPet = computed(() => pets.value[currentIndex.value])
const petTags = computed(() => {
if (!currentPet.value)
return []
return [
{ key: 'age', value: `${new Date().getFullYear() - new Date(currentPet.value.birthday).getFullYear()}岁` },
{ key: 'type', value: currentPet.value.type === PetType.CAT ? '猫猫' : '狗狗' },
{ key: 'weight', value: `${currentPet.value.weight}kg` },
]
})
function resetUserClick() {
userList.value.forEach(i => (i.isClick = false))
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
}
function handleUser(index: number) {
resetUserClick()
userList.value[index].isClick = true
const feedingPlanStore = useFeedingPlanStore()
async function handleAddFeedingPlan() {
feedingPlanStore.initPet(currentPet.value)
uni.navigateTo({
url: '/pages/feed-plan-calculator/index',
})
}
function handleAdd() {
uni.navigateTo({ url: '/pages/start-filing/index' })
function handleAddPet() {
uni.navigateTo({
url: '/pages/start-filing/index',
})
}
function handleEdit() {
uni.navigateTo({ url: '/pages/feed-calculator/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>
<template>
<view class="flex flex-col bg-[#F5F6F7] overflow-y-auto h-screen">
<!-- 喂养计划未注册 -->
<view v-if="pets.length === 0" class="w-[calc(100% - 32px)] min-h-[135px] rounded-lg m-[16px] relative">
<image :src="card" class="w-full h-full absolute z-20" />
<view class="z-20 absolute w-full mt-[35px] flex flex-col">
<image :src="addBtn" class="w-[47px] h-[47px] mx-auto" @click="handleAdd" />
<text class="text-[12px] text-[#D9D9D9] mx-auto mt-[6px]" @click="handleAdd">
添加你的喂养计划
</text>
</view>
<view class="w-[111px] h-[42px] bg-[black] absolute top-0 right-0 rounded-tr-xl z-10">
<text class="text-[#999] absolute right-5 top-2 text-[12px]">
无计划
</text>
</view>
<view class="absolute right-0 top-0 w-[78px] h-[24px] z-20" @tap="handleAdd" />
</view>
<!-- 喂养计划已注册 -->
<view v-else>
<view class="w-[calc(100% - 32px)] m-[16px] flex items-center">
<view v-for="(item, index) in userList" :key="index" class="text-[16px] font-500 mr-[12px] flex flex-col items-center justify-center" :style="{ fontSize: item.isClick ? '20px' : '16px', color: item.isClick ? '#4545E5' : 'black', fontWeight: item.isClick ? '600' : '500' }" @click="handleUser(index)">
<text>{{ item.name }}</text>
<view v-if="item.isClick" class="w-[16px] h-[3px] bg-[#4545E5]" />
<view class="flex flex-col bg-[#F5F6F7] overflow-y-auto h-screen p-4 gap-4">
<view class="w-full flex gap-3 items-center h-[32px]">
<template v-if="pets.length">
<view
v-for="(item, index) in pets" :key="item.id" class="text-base font-medium relative flex justify-center transition-all"
:class="{
'text-primary text-xl font-semibold': index === currentIndex,
}"
@click="() => selectPet(index)"
>
{{ item.name }}
<view v-if="index === currentIndex" class="absolute w-[30%] h-[3px] bg-primary bottom-[-4px] rounded-full" />
</view>
<image :src="userAddBtn" class="w-[24px] h-[24px]" @tap="handleAdd" />
</view>
<view v-for="(item, index) in clickUser" :key="index" class="w-[calc(100% - 32px)] min-h-[129px] rounded-lg m-[16px] relative bg-[white] p-[16px] flex items-center">
<image :src="avatar" class="w-[64px] h-[64px] rounded-full" />
<view class="ml-[16px] min-h-[54px] flex-1">
<text class="font-600">
{{ item.name }}
</text>
<view class="flex gap-2 flex-wrap mt-[6px]">
<view v-for="(label, labelIndex) in item.label" :key="labelIndex" class="px-[8px] py-[4px] rounded bg-[#f3f3f3] text-[#999] text-[12px]">
{{ label }}
</view>
</view>
</view>
<image :src="editBtn" class="w-[20px] h-[20px]" />
</view>
<view class="w-[calc(100% - 32px)] min-h-[135px] rounded-lg bg-[white] mx-[16px] relative">
<image :src="card" class="w-full h-[130px] absolute z-20" />
<view class="absolute z-20 w-full rounded-lg">
<view class="ml-[12px] mt-[5px]">
<text class="text-[12px]">
喂养计划
</text>
<text class="text-[12px] text-[#D9D9D9]">
FEEDING PLAN
</text>
</view>
</view>
<view class="absolute z-20 w-full rounded-lg bg-[white] top-[30px]">
<view v-for="(item, index) in clickUser[0].plan" :key="index" class="w-full mt-3 pl-[10px] pr-[20px] flex " :class="[clickUser[0].plan.length - 1 === index ? 'rounded-b-lg' : 'plan_card_bottom']">
<image :src="item.image" class="w-[80px] h-[80px]" />
<view class="ml-[12px] mt-[10px] flex-1">
<text class="font-600">
{{ item.name }}
</text>
<view class="flex gap-2 flex-wrap mt-[16px]">
<view v-for="(label, labelIndex) in item.label" :key="labelIndex" class="px-[8px] py-[4px] rounded bg-[#f3f3f3] text-[12px] ">
{{ label }}
</view>
</view>
</view>
<view v-if="index === 0" class="flex flex-col mt-[10px]">
<view class="text-[12px] font-600 flex justify-end">
每日
</view>
<view class="flex items-end">
<text class="source_family font-700 text-[20px]">
{{ item.weight }}
</text>
<text class="poppins_family font-500 text-[12px]">
g
</text>
</view>
<view class="source_family text-[9px] text-[#CDCDCD] mt-[10px] flex justify-end">
{{ item.energy }}
</view>
</view>
<view v-else class="flex flex-col mt-[2px] relative items-center top-[8px] right-0">
<view class="absolute z-20 top-[-10px] right-0 flex items-center justify-center w-full">
<view class="w-[25px] h-[25px] rounded-full bg-[#4545e5] text-[10px] text-[white] flex items-center justify-center ">
日
</view>
</view>
<view class="h-[52px] bg-[#D9D9D9] rounded-2xl px-[4px]">
<view class="mt-[14px] flex items-end justify-center ">
<text class="text-[16px] font-700">
{{ item.weight }}
</text>
<text class="text-[12px] font-500">
g
</text>
</view>
<view class="text-[9px] text-[#7C7C7C] flex justify-center">
{{ item.energy }}
</view>
</view>
</view>
</view>
</view>
<view class="w-[111px] h-[42px] bg-[black] absolute top-0 right-0 rounded-tr-xl z-10">
<text class="text-[#999] absolute right-5 top-2 text-[12px]">
编辑计划
</text>
</view>
<view class="absolute right-0 top-0 w-[78px] h-[24px] z-20" @tap="handleEdit" />
<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" @tap="handleAddPet">
待添加
</view>
</view>
<view v-if="currentPet" class="shadow-cell-group w-full px-4 py-8 bg-[white] rounded-3 flex items-center gap-4">
<image class="w-[64px] h-[64px] rounded-full" src="@/static/image/pet-default-avatar.png" />
<view class="flex-1">
<view class="font-semibold mb-1.5">
{{ currentPet.name }}
</view>
<view class="flex gap-2">
<view v-for="petTag in petTags" :key="petTag.key" class="px-2 py-0.5 bg-[#f3f3f3] rounded-0.75 text-[#999999]">
{{ petTag.value }}
</view>
</view>
</view>
<image class="w-[20px] h-[20px]" src="@/static/icons/edit.svg" />
</view>
<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>
</SectionCard>
</view>
</template>
<style scoped>
.select_user_span{
color: #4545E5;
}
.user_span{
color:black;
}
.source_family{
font-family: Source Han Sans CN, sans-serif;
}
.poppins_family{
font-family: Poppins, sans-serif;
}
.plan_card_bottom{
border-bottom: 0.5px solid #EAEAEA;
}
</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-calculator/components/FeedQuestionnaire.vue'
import FeedStart from '@/pages/feed-calculator/components/FeedStart.vue'
import FeedStep from '@/pages/feed-calculator/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()
+1 -1
View File
@@ -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'
+32 -14
View File
@@ -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-calculator/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)
function handleNext() {
uni.navigateTo({ url: '/pages/feed-calculator/index' })
}
const { pet, petTypeOptions, genderOptions } = useFeedingPlanStore()
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
})
</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>
+2 -2
View File
@@ -31,9 +31,9 @@ import union from '@/static/image/user-info/union.png'
<uni-list-item show-arrow title="地址" right-text="杭州" />
</uni-card>
<view class=" w-full flex justify-center items-center mt-[80px]">
<button class="w-[176px] h-[47px] font-normal bg-[#4545E5] text-[18px] rounded-[69px] text-[#fff] flex justify-center items-center">
<BButton class="w-[176px] h-[47px] font-normal bg-[#4545E5] text-[18px] rounded-[69px] text-[#fff] flex justify-center items-center">
确认
</button>
</BButton>
</view>
<view class="mt-[20px] flex justify-center items-center">
<image
+9
View File
@@ -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

+4
View File
@@ -0,0 +1,4 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.6024 2.17124L17.6566 6.22546L18.5405 5.34158L14.4863 1.28735L13.6024 2.17124Z" fill="#999999"/>
<path d="M2.94021 17.3291L7.45641 16.4259L16.5784 7.30385L12.5242 3.24963L3.40219 12.3716L2.49895 16.8878C2.44647 17.1502 2.67781 17.3816 2.94021 17.3291ZM12.5242 5.01739L14.8106 7.30385L6.84014 15.2744L3.98207 15.846L4.55369 12.9879L12.5242 5.01739Z" fill="#999999"/>
</svg>

After

Width:  |  Height:  |  Size: 489 B

+4
View File
@@ -0,0 +1,4 @@
<svg width="47" height="47" viewBox="0 0 47 47" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.8214 25.1766V35.248H25.1786V25.1766H35.25V21.8194H25.1786V11.748H21.8214V21.8194H11.75V25.1766H21.8214Z" fill="#D9D9D9"/>
<path d="M23.5 46.998C36.4787 46.998 47 36.4767 47 23.498C47 10.5193 36.4787 -0.00201416 23.5 -0.00201416C10.5213 -0.00201416 0 10.5193 0 23.498C0 36.4767 10.5213 46.998 23.5 46.998ZM23.5 43.6408C12.3754 43.6408 3.35714 34.6226 3.35714 23.498C3.35714 12.3734 12.3754 3.35513 23.5 3.35513C34.6246 3.35513 43.6429 12.3734 43.6429 23.498C43.6429 34.6226 34.6246 43.6408 23.5 43.6408Z" fill="#D9D9D9"/>
</svg>

After

Width:  |  Height:  |  Size: 645 B

+4
View File
@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.25 12.75V17.25H12.75V12.75H17.25V11.25H12.75V6.75H11.25V11.25H6.75V12.75H11.25Z" fill="#999999"/>
<path d="M12 22.5C17.799 22.5 22.5 17.799 22.5 12C22.5 6.20101 17.799 1.5 12 1.5C6.20101 1.5 1.5 6.20101 1.5 12C1.5 17.799 6.20101 22.5 12 22.5ZM12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21Z" fill="#999999"/>
</svg>

After

Width:  |  Height:  |  Size: 498 B

+3
View File
@@ -0,0 +1,3 @@
<svg width="343" height="135" viewBox="0 0 343 135" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M267.92 20.701L256.09 5.31098C253.52 1.96098 249.53 0.000976562 245.31 0.000976562H13.6C6.09 0.0109766 0 6.10098 0 13.611V179.011H343V39.611C343 32.101 336.91 26.011 329.4 26.011H278.69C274.47 26.011 270.49 24.051 267.91 20.701H267.92Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

+9
View File
@@ -0,0 +1,9 @@
<svg width="99" height="101" viewBox="0 0 99 101" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="99" height="101" fill="url(#pattern0_259_3397)"/>
<defs>
<pattern id="pattern0_259_3397" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0_259_3397" transform="matrix(0.00155763 0 0 0.00152679 0 -0.000786527)"/>
</pattern>
<image id="image0_259_3397" width="642" height="656" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoIAAAKQCAYAAAAL7huFAAAACXBIWXMAAC4jAAAuIwF4pT92AAAgAElEQVR4nO3dvYssbVr48ZrDwchAMHISAxMzwWgTE4NmoycxMxLMDDQwEgQTMTJ6IpF1EQTB5BFM1P6DJv5h5svu/IKzvadPT79UV90v13Xfnw88iGfPmamp7qn69nVXdb+8v78vACM7HN6ePtAdj68vNbYFIJIXIQiMaEv83SIKgVEJQWAoJQPwkiAERiMEgSHUDMBLghAYxafeGwCwV8sI7PH9AGoxEQRS6x1lpoNAZkIQSKl3AJ4Tg0BWloaBdCJF4LLE2x6AtUwEgVSiR5fpIJCJEARSiB6A58QgkIWlYSC8TBG4LPm2F5iXiSAQWvaoMh0EIhOCQEjZA/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E4GgPSjaHw9vq9/IDyOR0bLt1nItEBLYzUnekXxoe6cEYgQMRwHolloUdd/sZYZk49URQBMZjqRhgnRLHRRHY1wgdkjYER9j5oxKDAM/ZEm4iMIbD4e09c5OkWxrOvLNn5P38AD7a85YxAjCujEvFqUJQBObkoFWXSSvR+N1+bGsIOp7Gly0G04SgCMzNwas8AUh0fr+vLine truncated
</defs>
</svg>

After

Width:  |  Height:  |  Size: 14 KiB

+60
View File
@@ -0,0 +1,60 @@
<svg width="314" height="202" viewBox="0 0 314 202" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_259_3139)">
<g filter="url(#filter0_d_259_3139)">
<path d="M301.8 164.36C301.8 177.5 236.93 188.16 156.9 188.16C76.87 188.16 12 177.5 12 164.36L42.78 95.93C42.78 106.29 93.81 115.52 156.9 115.52C219.99 115.52 271.03 106.29 271.03 95.93L301.8 164.36Z" fill="url(#paint0_linear_259_3139)"/>
</g>
<g filter="url(#filter1_d_259_3139)">
<path d="M156.9 115.52C219.987 115.52 271.13 107.121 271.13 96.76C271.13 86.3991 219.987 78 156.9 78C93.8124 78 42.6699 86.3991 42.6699 96.76C42.6699 107.121 93.8124 115.52 156.9 115.52Z" fill="#5B5BF4"/>
</g>
<path d="M156.9 109.72C214.802 109.72 261.74 103.918 261.74 96.76C261.74 89.6024 214.802 83.8 156.9 83.8C98.9985 83.8 52.0601 89.6024 52.0601 96.76C52.0601 103.918 98.9985 109.72 156.9 109.72Z" fill="#4545E5"/>
<path d="M164.63 132.34H144.5L138.3 171.5H159.26C166.24 171.5 172.11 167.43 173.3 159.95C174.17 154.45 171.25 152.42 169.81 151.43C171.15 150.6 174.62 148.13 175.33 143.68C176.4 136.92 172.78 132.35 164.64 132.35L164.63 132.34ZM163.75 159.4C163.49 161.05 162.32 162.86 159.68 162.86H153.19H149.28L150.36 156.05H154.27V155.99H160.77C163.41 155.99 164.01 157.75 163.75 159.4ZM165.61 144.17C165.37 145.71 164.28 147.36 161.64 147.36H155.65H151.74L152.75 141H156.66L162.65 140.99C165.29 140.99 165.85 142.64 165.61 144.18V144.17Z" fill="white"/>
</g>
<g filter="url(#filter2_d_259_3139)">
<path d="M157.24 47.59V16.67" stroke="#4545E5" stroke-width="11.34" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M214.62 55.85L236.48 33.98" stroke="#4545E5" stroke-width="11.34" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M99.86 55.85L78 33.98" stroke="#4545E5" stroke-width="11.34" stroke-miterlimit="10" stroke-linecap="round"/>
</g>
<defs>
<filter id="filter0_d_259_3139" x="0" y="84.93" width="313.8" height="116.23" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dy="1"/>
<feGaussianBlur stdDeviation="6"/>
<feComposite in2="hardAlpha" operator="out"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.270588 0 0 0 0 0.270588 0 0 0 0 0.898039 0 0 0 0.6 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_259_3139"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_259_3139" result="shape"/>
</filter>
<filter id="filter1_d_259_3139" x="30.6699" y="67" width="252.46" height="61.52" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dy="1"/>
<feGaussianBlur stdDeviation="6"/>
<feComposite in2="hardAlpha" operator="out"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.270588 0 0 0 0 0.270588 0 0 0 0 0.898039 0 0 0 0.6 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_259_3139"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_259_3139" result="shape"/>
</filter>
<filter id="filter2_d_259_3139" x="60.3301" y="0" width="193.82" height="74.52" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dy="1"/>
<feGaussianBlur stdDeviation="6"/>
<feComposite in2="hardAlpha" operator="out"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.270588 0 0 0 0 0.270588 0 0 0 0 0.898039 0 0 0 0.6 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_259_3139"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_259_3139" result="shape"/>
</filter>
<linearGradient id="paint0_linear_259_3139" x1="131.64" y1="246.3" x2="199.46" y2="27.12" gradientUnits="userSpaceOnUse">
<stop stop-color="#6191FF"/>
<stop offset="0.13" stop-color="#597CF7"/>
<stop offset="0.32" stop-color="#5063EF"/>
<stop offset="0.52" stop-color="#4A52E9"/>
<stop offset="0.74" stop-color="#4648E6"/>
<stop offset="1" stop-color="#4545E5"/>
</linearGradient>
<clipPath id="clip0_259_3139">
<rect width="314" height="135" fill="white" transform="translate(0 67)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

+285 -1
View File
@@ -1,8 +1,14 @@
import type { FeedingPlanProduct } from '@/model/feeding-plan'
import type { Product } from '@/model/product'
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,
PetType,
} from '@/model/pet'
@@ -19,6 +25,25 @@ 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>({
birthday: new Date().toISOString().split('T')[0],
bodyType: PetBodyType.IDEAL,
@@ -31,8 +56,11 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
photo: '',
type: PetType.CAT,
weight: 0,
varietyName: '',
})
const savedPet = ref<Pet | null>(null)
const petTags = computed(() => {
return [
{ key: 'age', value: `${new Date().getFullYear() - new Date(pet.value.birthday).getFullYear()}岁` },
@@ -41,9 +69,89 @@ 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 = [
@@ -57,13 +165,189 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
pet.value[key] = (value as CreatePetRequest[keyof CreatePetRequest])
}
const persistentPet = async () => {
savedPet.value = await createPet({
...pet.value,
})
dailyCalories.value = Math.floor(rer.value * derRate.value)
}
/**
* 用户选中的商品列表,每个含有 product 信息和 percentage 百分比
*/
const selectedProducts = ref<FeedingPlanProduct[]>([])
const arrangeDailyConsumeWeight = () => {
selectedProducts.value.forEach((item) => {
item.dailyUsageWeight = Math.floor((dailyCalories.value * item.percentage / 100) / item.product.totalCalories * item.product.totalWeight)
})
}
/**
* 将所有已选商品的 percentage【平分】为 100 / total,
* 并用 Math.floor 取整后,将多余 remainder 逐个分配(防止总和小于 100)。
*/
function recalculatePercentage() {
const total = selectedProducts.value.length
if (total === 0)
return
// 1. 先把 100 整除
const base = Math.floor(100 / total) // 每个至少分到多少
const remainder = 100 - base * total // 还剩多少未分配
// 2. 所有人先设置为 base
selectedProducts.value.forEach((item) => {
item.percentage = base
})
// 3. 余数 remainder 逐个+1 分配给前 remainder 个
// 如果你不在意 1% 的误差,可以省略这一步
for (let i = 0; i < remainder; i++) {
selectedProducts.value[i].percentage += 1
}
}
/**
* 添加一个新商品
* - 如果已存在则直接 return
* - 如果不存在则 push 到 selectedProducts,并平均分配
*/
function addProductToSelected(product: Product) {
// 如果已存在,不重复添加
if (selectedProducts.value.some(item => item.product.id === product.id)) {
return
}
// 新商品默认 0%(稍后 re calc 会统一分配)
selectedProducts.value.push({
product,
percentage: 0,
dailyUsageWeight: 0,
})
// 重新平分所有商品的比例
recalculatePercentage()
arrangeDailyConsumeWeight()
}
/**
* 给除 exceptId 之外的商品,分摊 -delta;
* 也就是说,如果 delta 是正,其他商品就要减掉 delta;如果 delta 是负,其他商品就要加上 -delta。
*
* 注意:这里用 `-=` 实现把 diff 分摊给其他产品
*/
function modifyPercentageExceptId(exceptId: string, delta: number) {
selectedProducts.value.forEach((item) => {
if (item.product.id !== exceptId) {
item.percentage -= delta
}
})
}
const isEdit = ref(false)
/**
* 修改指定 productId 的 percentage
* @param productId 产品的id
* @param newVal 用户想要设置的新值 (0~100)
*/
function changePercentage(productId: string, newVal: number) {
const product = selectedProducts.value.find(item => item.product.id === productId)
if (product) {
const oldVal = product.percentage
const diff = newVal - oldVal
// 先更新本产品的新值
product.percentage = newVal
// 计算需要从(或给)其他商品分配的增量
// total-1 防止只有一个商品时出现除以0
const total = selectedProducts.value.length
if (total > 1) {
const deltaPerProduct = diff / (total - 1)
// 其他商品分摊 -deltaPerProduct (实际在函数里 -= deltaPerProduct)
modifyPercentageExceptId(productId, deltaPerProduct)
}
arrangeDailyConsumeWeight()
}
}
const savedFeedingPlan = ref<FeedingPlan | null>(null)
const confirm = async () => {
if (savedPet.value === null) {
return
}
feedingPlan.value.petId = savedPet.value.id
feedingPlan.value.products = selectedProducts.value.map((item) => {
return {
id: item.product.id,
dailyUsageWeight: item.dailyUsageWeight,
percentage: item.percentage,
}
})
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 {
pet,
petTypeOptions,
genderOptions,
setPetValue,
persistentPet,
petTags,
feedingPlan,
feedingGoalOptions,
selectedProducts,
addProductToSelected,
changePercentage,
dailyCalories,
confirm,
initPet,
initFeedingPlan,
petVarietiesOptions,
}
})
+36
View File
@@ -0,0 +1,36 @@
import {fetchProductList} from '@/api/product'
import {type Product, ProductCategory} from '@/model/product'
import {defineStore} from 'pinia'
export const useProductStore = defineStore('product', () => {
const allProducts = ref<Product[]>([])
const currentProductCategory = ref<ProductCategory>(ProductCategory.WET_FOOD)
const categoryList = [
{ label: '湿粮', value: ProductCategory.WET_FOOD },
{ label: '干粮', value: ProductCategory.DRY_FOOD },
]
const productList = computed<Product[]>(() => {
return allProducts.value.filter(product => product.category === currentProductCategory.value)
})
const switchCurrentProductCategory = (category: ProductCategory) => {
currentProductCategory.value = category
}
const fetchAllProducts = async () => {
allProducts.value = await fetchProductList()
}
return {
allProducts,
currentProductCategory,
productList,
categoryList,
switchCurrentProductCategory,
fetchAllProducts,
}
})
+6 -9
View File
@@ -4,21 +4,18 @@
// Generated by vite-plugin-uni-pages
interface NavigateToOptions {
url: "/pages/feed-calculator/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" |
"/pages/feed-questionnaire/index" |
"/pages/home/index" |
"/pages/me/index" |
"/pages/pet-manual/index" |
"/pages/setting/index" |
"/pages/start-filing/index" |
"/pages/userInfo/index" |
"/pages/feed-calculator/components/FeedForm" |
"/pages/feed-calculator/components/FeedQuestionnaire" |
"/pages/feed-calculator/components/FeedSlogan" |
"/pages/feed-calculator/components/FeedStart" |
"/pages/feed-calculator/components/FeedStep" |
"/pages/feed-calculator/components/ProgressBar" |
"/pages/pet-manual/components/CardList";
"/pages/userInfo/index";
}
interface RedirectToOptions extends NavigateToOptions {}
+16 -3
View File
@@ -13,9 +13,22 @@ else {
}
const theme: Config['theme'] = {
colors: {
primary: '#4545E5',
default: '#828282',
extend: {
colors: {
primary: '#4545E5',
default: '#828282',
disabled: '#D9D9D9',
},
backgroundColor: {
regular: '#F5F6F7',
},
spacing: {
'safe-top': 'env(safe-area-inset-top)',
'safe-bottom': 'env(safe-area-inset-bottom)',
'safe-left': 'env(safe-area-inset-left)',
'safe-right': 'env(safe-area-inset-right)',
},
},
boxShadow: {
'cell-group': '0px 4px 12px 0px rgba(0, 0, 0, 0.10)',
+73
View File
@@ -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
+1
View File
@@ -32,6 +32,7 @@ export default async ({ command, mode }) => {
},
},
server: {
port: 5175,
proxy: {
'/api': {
target: env.VITE_PROXY_ENDPOINT,