68 lines
2.5 KiB
Vue
68 lines
2.5 KiB
Vue
<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>
|