Bläddra i källkod

refactor: 迁移喂养计算器到单独页面

zlong 1 år sedan
förälder
incheckning
e68fb95c1b

+ 13 - 9
src/pages.json

@@ -7,11 +7,15 @@
   },
   "pages": [
     {
-      "path": "pages/feed-plan/index",
+      "path": "pages/home/index",
       "type": "page"
     },
     {
-      "path": "pages/home/index",
+      "path": "pages/feed-calculator/index",
+      "type": "page"
+    },
+    {
+      "path": "pages/feed-plan/index",
       "type": "page"
     },
     {
@@ -23,27 +27,27 @@
       "type": "page"
     },
     {
-      "path": "pages/feed-plan/components/FeedFlogan",
+      "path": "pages/feed-calculator/components/FeedFlogan",
       "type": "page"
     },
     {
-      "path": "pages/feed-plan/components/FeedForm",
+      "path": "pages/feed-calculator/components/FeedForm",
       "type": "page"
     },
     {
-      "path": "pages/feed-plan/components/FeedQuestionnaire",
+      "path": "pages/feed-calculator/components/FeedQuestionnaire",
       "type": "page"
     },
     {
-      "path": "pages/feed-plan/components/FeedStart",
+      "path": "pages/feed-calculator/components/FeedStart",
       "type": "page"
     },
     {
-      "path": "pages/feed-plan/components/FeedStep",
+      "path": "pages/feed-calculator/components/FeedStep",
       "type": "page"
     },
     {
-      "path": "pages/feed-plan/components/ProgressBar",
+      "path": "pages/feed-calculator/components/ProgressBar",
       "type": "page"
     },
     {
@@ -62,4 +66,4 @@
     "navigationStyle": "custom"
   },
   "subPackages": []
-}
+}

+ 0 - 0
src/pages/feed-plan/components/FeedFlogan.vue → src/pages/feed-calculator/components/FeedFlogan.vue


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


+ 3 - 3
src/pages/feed-plan/components/FeedQuestionnaire.vue → src/pages/feed-calculator/components/FeedQuestionnaire.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
 import type { FeedFormQuestions, PetCard, StepInfo, UserList } from '@/model/pet-manual'
-import FeedSlogan from '@/pages/feed-plan/components/FeedFlogan.vue'
-import FeedForm from '@/pages/feed-plan/components/FeedForm.vue'
-import ProgressBar from '@/pages/feed-plan/components/ProgressBar.vue'
+import FeedSlogan from '@/pages/feed-calculator/components/FeedFlogan.vue'
+import FeedForm from '@/pages/feed-calculator/components/FeedForm.vue'
+import ProgressBar from '@/pages/feed-calculator/components/ProgressBar.vue'
 import avator from '@/static/image/pet-parameters/avator.png'
 import right from '@/static/image/pet-parameters/right.png'
 

+ 2 - 2
src/pages/feed-plan/components/FeedStart.vue → src/pages/feed-calculator/components/FeedStart.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import type { StepInfo } from '@/model/pet-manual'
-import FeedFlogan from '@/pages/feed-plan/components/FeedFlogan.vue'
-import FeedStep from '@/pages/feed-plan/components/FeedStep.vue'
+import FeedFlogan from '@/pages/feed-calculator/components/FeedFlogan.vue'
+import FeedStep from '@/pages/feed-calculator/components/FeedStep.vue'
 import feedTitle from '@/static/image/feed-plan/feed-title.png'
 
 const props = defineProps<{

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


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


+ 102 - 0
src/pages/feed-calculator/index.vue

@@ -0,0 +1,102 @@
+<script setup lang="ts">
+import type { FeedFormQuestions, UserList } from '@/model/pet-manual'
+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 avator from '@/static/image/pet-parameters/avator.png'
+import cat from '@/static/image/pet-parameters/cat.png'
+import dog from '@/static/image/pet-parameters/dog.png'
+import emaciatedCat from '@/static/image/pet-parameters/form/emaciated_cat.png'
+import idealWightCat from '@/static/image/pet-parameters/form/idealweight_cat.png'
+import overWeightCat from '@/static/image/pet-parameters/form/overweight_cat.png'
+import skinnyCat from '@/static/image/pet-parameters/form/skinny_cat.png'
+import thinCat from '@/static/image/pet-parameters/form/thin_cat.png'
+import underWeightCat from '@/static/image/pet-parameters/form/underweight_cat.png'
+import ToolApi from '@/utils'
+
+interface StepInfo {
+  step: number
+  title: string
+}
+const titleName = ref<string>('喂养计算器')
+const safeHeight = ToolApi.getSafeHeight()
+const stage = ref<number>(0)
+const stepInfo = ref<StepInfo[]>([
+  { step: 1, title: '宠物基础信息' },
+  { step: 2, title: '身体状态信息' },
+  { step: 3, title: '计算喂养计划' },
+])
+const controlFormDisplay = ref({
+  display1: true,
+  display2: false,
+  display3: false,
+})
+const feedFormQuestions = ref<FeedFormQuestions[]>([
+  { title: '您的动物是?', question: [{ image: cat, name: '猫猫' }, { image: dog, name: '狗狗' }], formType: 1 },
+  { title: '猫咪的性别?', question: [{ name: '男孩' }, { name: '女孩' }], formType: 2 },
+  { title: '猫咪的年龄区间?', question: [{ name: '0-4个月' }, { name: '5-12个月' }], formType: 2 },
+  { title: '猫咪是否活跃?', question: [{ name: '活跃' }, { name: '不活跃' }], formType: 2 },
+  { title: '猫咪是否怀孕?', question: [{ name: '怀孕' }, { name: '未怀孕' }], formType: 2 },
+  { title: '猫咪是否绝育?', question: [{ name: '绝育' }, { name: '未绝育' }], formType: 2 },
+  { title: '猫咪是否在哺乳?', question: [{ name: '哺乳中' }, { name: '未哺乳' }], formType: 2 },
+  { title: '请选择猫咪的体型', question: [{ image: emaciatedCat, name: '极度消廋' }, { image: skinnyCat, name: '非常廋' }, { image: thinCat, name: '消瘦' }, { image: underWeightCat, name: '体重偏低' }, { image: idealWightCat, name: '理想体重' }, { image: overWeightCat, name: '体重偏重' }], formType: 3 },
+])
+const userList = ref<UserList>({
+  image: avator,
+  username: '子龙',
+  type: ['年龄', '品种', '体重'],
+})
+function reset() {
+  stage.value = 0
+  controlFormDisplay.value = {
+    display1: false,
+    display2: false,
+    display3: false,
+  }
+}
+function handleReady() {
+  reset()
+  titleName.value = '喂养问卷'
+  controlFormDisplay.value.display2 = true
+  setTimeout(() => {
+    reset()
+    controlFormDisplay.value.display3 = true
+  }, 3000)
+}
+function handleBackFeedStart() {
+  reset()
+  titleName.value = '喂养计算器'
+  controlFormDisplay.value.display1 = true
+}
+function handleStep(step: number) {
+  if (step === 2) {
+    handleReady()
+    stage.value = 1
+    controlFormDisplay.value.display2 = true
+  }
+  else if (step === 7) {
+    handleReady()
+    stage.value = 2
+    controlFormDisplay.value.display2 = true
+  }
+}
+</script>
+
+<template>
+  <TitleBar :title-name="titleName" />
+  <view class="flex flex-col bg-[#F5F6F7] overflow-y-auto" :style="`height:calc(100vh - ${safeHeight}px)`">
+    <view v-show="controlFormDisplay.display1">
+      <FeedStart :step-info="stepInfo" @ready="handleReady" />
+    </view>
+    <view v-show="controlFormDisplay.display2" class="flex justify-center items-center w-full h-full">
+      <FeedStep :list="stepInfo" :stage="stage" />
+    </view>
+    <view v-show="controlFormDisplay.display3">
+      <FeedQuestionnaire :list="feedFormQuestions" :step-info="stepInfo" :user-list="userList" @back="handleBackFeedStart" @step="handleStep" />
+    </view>
+  </view>
+</template>
+
+<style scoped>
+
+</style>

+ 6 - 89
src/pages/feed-plan/index.vue

@@ -1,98 +1,15 @@
 <script setup lang="ts">
-import type { FeedFormQuestions, UserList } from '@/model/pet-manual'
-import FeedQuestionnaire from '@/pages/feed-plan/components/FeedQuestionnaire.vue'
-import FeedStart from '@/pages/feed-plan/components/FeedStart.vue'
-import FeedStep from '@/pages/feed-plan/components/FeedStep.vue'
-import avator from '@/static/image/pet-parameters/avator.png'
-import cat from '@/static/image/pet-parameters/cat.png'
-import dog from '@/static/image/pet-parameters/dog.png'
-import emaciatedCat from '@/static/image/pet-parameters/form/emaciated_cat.png'
-import idealWightCat from '@/static/image/pet-parameters/form/idealweight_cat.png'
-import overWeightCat from '@/static/image/pet-parameters/form/overweight_cat.png'
-import skinnyCat from '@/static/image/pet-parameters/form/skinny_cat.png'
-import thinCat from '@/static/image/pet-parameters/form/thin_cat.png'
-import underWeightCat from '@/static/image/pet-parameters/form/underweight_cat.png'
-import ToolApi from '@/utils'
-
-interface StepInfo {
-  step: number
-  title: string
-}
-const titleName = ref<string>('喂养计算器')
-const safeHeight = ToolApi.getSafeHeight()
-const stage = ref<number>(0)
-const stepInfo = ref<StepInfo[]>([
-  { step: 1, title: '宠物基础信息' },
-  { step: 2, title: '身体状态信息' },
-  { step: 3, title: '计算喂养计划' },
-])
-const controlFormDisplay = ref({
-  display1: true,
-  display2: false,
-  display3: false,
-})
-const feedFormQuestions = ref<FeedFormQuestions[]>([
-  { title: '您的动物是?', question: [{ image: cat, name: '猫猫' }, { image: dog, name: '狗狗' }], formType: 1 },
-  { title: '猫咪的性别?', question: [{ name: '男孩' }, { name: '女孩' }], formType: 2 },
-  { title: '猫咪的年龄区间?', question: [{ name: '0-4个月' }, { name: '5-12个月' }], formType: 2 },
-  { title: '猫咪是否活跃?', question: [{ name: '活跃' }, { name: '不活跃' }], formType: 2 },
-  { title: '猫咪是否怀孕?', question: [{ name: '怀孕' }, { name: '未怀孕' }], formType: 2 },
-  { title: '猫咪是否绝育?', question: [{ name: '绝育' }, { name: '未绝育' }], formType: 2 },
-  { title: '猫咪是否在哺乳?', question: [{ name: '哺乳中' }, { name: '未哺乳' }], formType: 2 },
-  { title: '请选择猫咪的体型', question: [{ image: emaciatedCat, name: '极度消廋' }, { image: skinnyCat, name: '非常廋' }, { image: thinCat, name: '消瘦' }, { image: underWeightCat, name: '体重偏低' }, { image: idealWightCat, name: '理想体重' }, { image: overWeightCat, name: '体重偏重' }], formType: 3 },
-])
-const userList = ref<UserList>({
-  image: avator,
-  username: '子龙',
-  type: ['年龄', '品种', '体重'],
-})
-function reset() {
-  stage.value = 0
-  controlFormDisplay.value = {
-    display1: false,
-    display2: false,
-    display3: false,
-  }
-}
-function handleReady() {
-  reset()
-  controlFormDisplay.value.display2 = true
-  setTimeout(() => {
-    reset()
-    controlFormDisplay.value.display3 = true
-  }, 3000)
-}
-function handleBackFeedStart() {
-  reset()
-  controlFormDisplay.value.display1 = true
-}
-function handleStep(step: number) {
-  if (step === 2) {
-    handleReady()
-    stage.value = 1
-    controlFormDisplay.value.display2 = true
-  }
-  else if (step === 7) {
-    handleReady()
-    stage.value = 2
-    controlFormDisplay.value.display2 = true
-  }
+const titleName = ref<string>('喂养计划')
+function handleJumpPlan() {
+  uni.navigateTo({ url: '/pages/feed-calculator/index' })
 }
 </script>
 
 <template>
   <TitleBar :title-name="titleName" />
-  <view class="flex flex-col bg-[#F5F6F7] overflow-y-auto" :style="`height:calc(100vh - ${safeHeight}px)`">
-    <view v-show="controlFormDisplay.display1">
-      <FeedStart :step-info="stepInfo" @ready="handleReady" />
-    </view>
-    <view v-show="controlFormDisplay.display2" class="flex justify-center items-center w-full h-full">
-      <FeedStep :list="stepInfo" :stage="stage" />
-    </view>
-    <view v-show="controlFormDisplay.display3">
-      <FeedQuestionnaire :list="feedFormQuestions" :step-info="stepInfo" :user-list="userList" @back="handleBackFeedStart" @step="handleStep" />
-    </view>
-  </view>
+  <button class="h-16 flex items-center justify-center bg-[red]" @tap="handleJumpPlan">
+    跳转喂养计算器
+  </button>
 </template>
 
 <style scoped>

+ 8 - 7
src/uni-pages.d.ts

@@ -4,16 +4,17 @@
 // Generated by vite-plugin-uni-pages
 
 interface NavigateToOptions {
-  url: "/pages/feed-plan/index" |
+  url: "/pages/feed-calculator/index" |
+       "/pages/feed-plan/index" |
        "/pages/home/index" |
        "/pages/me/index" |
        "/pages/pet-manual/index" |
-       "/pages/feed-plan/components/FeedFlogan" |
-       "/pages/feed-plan/components/FeedForm" |
-       "/pages/feed-plan/components/FeedQuestionnaire" |
-       "/pages/feed-plan/components/FeedStart" |
-       "/pages/feed-plan/components/FeedStep" |
-       "/pages/feed-plan/components/ProgressBar" |
+       "/pages/feed-calculator/components/FeedFlogan" |
+       "/pages/feed-calculator/components/FeedForm" |
+       "/pages/feed-calculator/components/FeedQuestionnaire" |
+       "/pages/feed-calculator/components/FeedStart" |
+       "/pages/feed-calculator/components/FeedStep" |
+       "/pages/feed-calculator/components/ProgressBar" |
        "/pages/pet-manual/components/CardList";
 }
 interface RedirectToOptions extends NavigateToOptions {}