diff --git a/src/common/apis/shop/type.ts b/src/common/apis/shop/type.ts
index 0803c5f..219bd05 100644
--- a/src/common/apis/shop/type.ts
+++ b/src/common/apis/shop/type.ts
@@ -7,6 +7,7 @@ export type Goods = {
status: number,
coverImg: string,
goodsDetail: string,
+ usageInstruction: string,
cellId: number
}
diff --git a/src/pages/product/ProductList.vue b/src/pages/product/ProductList.vue
index ed1177d..6a8cf35 100644
--- a/src/pages/product/ProductList.vue
+++ b/src/pages/product/ProductList.vue
@@ -42,6 +42,8 @@ const currentProduct = computed(() =>
// 购物车弹窗控制
const showCartPopup = ref(false)
+const searchQuery = ref('')
+
// 点击分类导航
function handleCategoryClick(index: number) {
activeCategory.value = index
@@ -99,8 +101,16 @@ function getCartItemCount(cellId: number) {
return item ? item.quantity : 0
}
+function filterProductsByName(products: Product[], query: string) {
+ if (!query) return products
+ return products.filter(p =>
+ p.name.toLowerCase().includes(query.toLowerCase())
+ )
+}
+
const currentProducts = computed(() => {
- return categories.value.filter(c => c.label === labels.value[activeCategory.value].id)
+ const filteredByCategory = categories.value.filter(c => c.label === labels.value[activeCategory.value].id)
+ return filterProductsByName(filteredByCategory, searchQuery.value)
})
// 组件挂载时添加滚动监听
@@ -143,6 +153,12 @@ watch(() => route.path, (newPath) => {
+
diff --git a/src/pages/product/components/checkout.vue b/src/pages/product/components/checkout.vue
index b1206a0..96e4fe5 100644
--- a/src/pages/product/components/checkout.vue
+++ b/src/pages/product/components/checkout.vue
@@ -154,41 +154,40 @@ async function handleSubmit() {
-
-
-
-
+
+
+
+
+
-
-
- {{ item.product.name }}
+
+
+ {{ item.product.name }}
+
+
+
+ ¥{{ item.product.price.toFixed(2) }}
+
+
+ ×{{ item.quantity }}
+
+
-
-
- ¥{{ item.product.price.toFixed(2) }}
-
-
- ×{{ item.quantity }}
-
+
+
+
+ 使用说明:{{ item.product.usageInstruction }}
-
-
+
+
-
+
-
+
微信支付
@@ -197,8 +196,7 @@ async function handleSubmit() {
+ @click="selectedPayment = 'balance'">
余额支付
diff --git a/src/pinia/stores/product.ts b/src/pinia/stores/product.ts
index 92e9864..7a91c07 100644
--- a/src/pinia/stores/product.ts
+++ b/src/pinia/stores/product.ts
@@ -10,6 +10,7 @@ export interface Product {
image: string // 商品图片URL
label: number // 商品标签
cellId: number // 商品所在的格子ID
+ usageInstruction: string // 商品使用说明
}
export const useProductStore = defineStore("product", () => {
@@ -48,7 +49,8 @@ export const useProductStore = defineStore("product", () => {
description: g.goodsDetail || "暂无描述",
image: g.coverImg,
label: g.categoryId,
- cellId: g.cellId
+ cellId: g.cellId,
+ usageInstruction: g.usageInstruction || ""
}))
} catch (error) {
console.error("获取商品数据失败:", error)
diff --git a/types/auto/components.d.ts b/types/auto/components.d.ts
index 39a8321..ae7f7b0 100644
--- a/types/auto/components.d.ts
+++ b/types/auto/components.d.ts
@@ -27,6 +27,7 @@ declare module 'vue' {
VanNavBar: typeof import('vant/es')['NavBar']
VanPicker: typeof import('vant/es')['Picker']
VanPopup: typeof import('vant/es')['Popup']
+ VanSearch: typeof import('vant/es')['Search']
VanSidebar: typeof import('vant/es')['Sidebar']
VanSidebarItem: typeof import('vant/es')['SidebarItem']
VanTabbar: typeof import('vant/es')['Tabbar']