diff --git a/pet-manual/index.vue b/pet-manual/index.vue
index 21de306..d0a5c87 100644
--- a/pet-manual/index.vue
+++ b/pet-manual/index.vue
@@ -1,6 +1,6 @@
goToArticle(item.id)"
>
diff --git a/src/model/pet-manual.ts b/src/model/pet-manual.ts
index 5aeba6b..b2e23f4 100644
--- a/src/model/pet-manual.ts
+++ b/src/model/pet-manual.ts
@@ -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 {
diff --git a/src/pages.json b/src/pages.json
index 9ff0d9c..c9a4557 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -7,6 +7,11 @@
},
"entryPagePath": "pages/home/index",
"pages": [
+ {
+ "path": "pages/article/detail",
+ "type": "page",
+ "style": {}
+ },
{
"path": "pages/feed-plan/index",
"type": "page",
@@ -86,11 +91,6 @@
"path": "pages/userInfo/index",
"type": "page",
"style": {}
- },
- {
- "path": "pages/pet-manual/components/CardList",
- "type": "page",
- "style": {}
}
],
"globalStyle": {
diff --git a/src/pages/article/detail.vue b/src/pages/article/detail.vue
new file mode 100644
index 0000000..30b1165
--- /dev/null
+++ b/src/pages/article/detail.vue
@@ -0,0 +1,46 @@
+
+
+
+
+
+ {{ article.title }}
+
+
+ {{ article.createdTime }}
+
+
+
+
+
+
diff --git a/src/pages/pet-manual/index.vue b/src/pages/pet-manual/index.vue
index 25b5992..fbc9f13 100644
--- a/src/pages/pet-manual/index.vue
+++ b/src/pages/pet-manual/index.vue
@@ -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'
diff --git a/src/stores/feeding-plan.ts b/src/stores/feeding-plan.ts
index 2a3a822..bc10e82 100644
--- a/src/stores/feeding-plan.ts
+++ b/src/stores/feeding-plan.ts
@@ -1,6 +1,6 @@
import type { FeedingPlanProduct } from '@/model/feeding-plan'
import type { Product } from '@/model/product'
-import { createFeedingPlan } from '@/api/feeding-plan'
+import { createFeedingPlan, updateFeedingPlan } from '@/api/feeding-plan'
import { createPet } from '@/api/pet'
import {
type CreateFeedingPlanRequest,
@@ -221,6 +221,8 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
})
}
+ const isEdit = ref(false)
+
/**
* 修改指定 productId 的 percentage
* @param productId 产品的id
@@ -246,6 +248,7 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
arrangeDailyConsumeWeight()
}
}
+ const savedFeedingPlan = ref(null)
const confirm = async () => {
if (savedPet.value === null) {
@@ -260,7 +263,13 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
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) => {
@@ -282,7 +291,6 @@ export const useFeedingPlanStore = defineStore('feeding-plan', () => {
feedingPlan.value.targetWeight = calculateIdealWeight()
rer.value = calculateRER(pet.value.weight)
}
- const savedFeedingPlan = ref(null)
const initFeedingPlan = (payload: FeedingPlan) => {
// @ts-expect-error @ts-ignore
diff --git a/src/uni-pages.d.ts b/src/uni-pages.d.ts
index 0d7842b..25822d8 100644
--- a/src/uni-pages.d.ts
+++ b/src/uni-pages.d.ts
@@ -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,8 +15,7 @@ interface NavigateToOptions {
"/pages/pet-manual/index" |
"/pages/setting/index" |
"/pages/start-filing/index" |
- "/pages/userInfo/index" |
- "/pages/pet-manual/components/CardList";
+ "/pages/userInfo/index";
}
interface RedirectToOptions extends NavigateToOptions {}