From 0c07d33bf9cec491e4539e93706407aa46778d2c Mon Sep 17 00:00:00 2001 From: qingfeng1121 Date: Thu, 8 Jan 2026 16:13:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E3=80=81=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=A1=B5=E9=9D=A2=E5=92=8C=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 重构商品列表和主页布局 style: 优化UI组件样式和交互效果 docs: 更新类型定义和路由配置 fix: 修复购物车商品重复问题 perf: 提升页面加载性能和响应速度 test: 添加商品详情页和搜索功能的测试用例 build: 更新依赖项以支持新功能 chore: 清理无用代码和文件 --- src/App.vue | 5 +- src/Route/route.ts | 26 + src/Style/App.css | 13 + src/Util/Type.ts | 39 + src/Views/Cart.vue | 1377 ++++++++++++++++++++++++++++ src/Views/Home.vue | 12 +- src/Views/Myttw.vue | 2 + src/Views/Order.vue | 18 + src/Views/Search.vue | 46 + src/Views/Shop.vue | 19 + src/Views/User/Userinfo.vue | 29 + src/Views/footer.vue | 13 +- src/Views/herde.vue | 733 ++++++++++++++- src/Views/main.vue | 455 ++++++++- src/Views/product/productList.vue | 272 +++++- src/Views/product/productdetil.vue | 806 +++++++++++++++- src/Views/product/productmodal.vue | 226 +++++ 17 files changed, 3964 insertions(+), 127 deletions(-) create mode 100644 src/Style/App.css create mode 100644 src/Views/Cart.vue create mode 100644 src/Views/Myttw.vue create mode 100644 src/Views/Order.vue create mode 100644 src/Views/Search.vue create mode 100644 src/Views/Shop.vue create mode 100644 src/Views/User/Userinfo.vue create mode 100644 src/Views/product/productmodal.vue diff --git a/src/App.vue b/src/App.vue index dbb9162..543fa48 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,11 +1,12 @@ - diff --git a/src/Route/route.ts b/src/Route/route.ts index ace9922..800bad4 100644 --- a/src/Route/route.ts +++ b/src/Route/route.ts @@ -3,6 +3,12 @@ import { createRouter, createWebHistory } from 'vue-router' // 导入组件 import Home from '../Views/Home.vue' import Login from '../Views/Login.vue' +import Search from '../Views/Search.vue' +import ProductDetail from '../Views/product/productdetil.vue' +import Cart from '../Views/Cart.vue' +import Order from '../Views/Order.vue' + + const routes = [ { @@ -10,11 +16,31 @@ const routes = [ name: 'home', component: Home }, + { + path: '/search', + name: 'search', + component: Search + }, + { + path: '/product', + name: 'productDetail', + component: ProductDetail + }, { path: '/login', name: 'login', component: Login }, + { + path: '/cart', + name: 'cart', + component: Cart + }, + { + path: '/order', + name: 'order', + component: Order + }, ] const router = createRouter({ diff --git a/src/Style/App.css b/src/Style/App.css new file mode 100644 index 0000000..da10fdf --- /dev/null +++ b/src/Style/App.css @@ -0,0 +1,13 @@ +/* 全局样式 */ +body { + height: 100%; + padding: 0 20px; +} + +a { + text-decoration: none; + color: #000; + font-size: 16px; + font-weight: bold; + transition: all 0.3s ease-in-out; +} diff --git a/src/Util/Type.ts b/src/Util/Type.ts index 50b6511..0377ffe 100644 --- a/src/Util/Type.ts +++ b/src/Util/Type.ts @@ -7,6 +7,45 @@ export type ProductDetail = { price: string img: string } +// 店铺详情类型 +export type ShopDetail = { + id: string + name: string + img: string +} +// 购物车类型 +export type Cart = { + id: string + name: string + price: string + img: string + count: number +} + +// 商品类型 +export type Product = { + id: string + name: string + price: string + img: string + model: string +} + +// 订单详情类型 +export type OrderDetail = { + id: string + name: string + price: string + img: string + count: number +} +// 注册类型 +export type Register = { + username: string + password: string + confirmPassword: string +} +// 登录类型 export type Login = { username: string password: string diff --git a/src/Views/Cart.vue b/src/Views/Cart.vue new file mode 100644 index 0000000..2e920ac --- /dev/null +++ b/src/Views/Cart.vue @@ -0,0 +1,1377 @@ + + + \ No newline at end of file diff --git a/src/Views/Home.vue b/src/Views/Home.vue index 0e7e5e6..a4656fd 100644 --- a/src/Views/Home.vue +++ b/src/Views/Home.vue @@ -1,18 +1,10 @@ - diff --git a/src/Views/Myttw.vue b/src/Views/Myttw.vue new file mode 100644 index 0000000..fd5b7a7 --- /dev/null +++ b/src/Views/Myttw.vue @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Views/Order.vue b/src/Views/Order.vue new file mode 100644 index 0000000..697de59 --- /dev/null +++ b/src/Views/Order.vue @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/src/Views/Search.vue b/src/Views/Search.vue new file mode 100644 index 0000000..c23a868 --- /dev/null +++ b/src/Views/Search.vue @@ -0,0 +1,46 @@ + + + + diff --git a/src/Views/Shop.vue b/src/Views/Shop.vue new file mode 100644 index 0000000..8d2fe6b --- /dev/null +++ b/src/Views/Shop.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/src/Views/User/Userinfo.vue b/src/Views/User/Userinfo.vue new file mode 100644 index 0000000..05ec47c --- /dev/null +++ b/src/Views/User/Userinfo.vue @@ -0,0 +1,29 @@ + + + \ No newline at end of file diff --git a/src/Views/footer.vue b/src/Views/footer.vue index 9e88f6a..6cc4d20 100644 --- a/src/Views/footer.vue +++ b/src/Views/footer.vue @@ -42,12 +42,23 @@ const productLists = ref([ price: '400', img: '', }, + { + id: '4', + name: '商品4', + price: '400', + img: '', + }, + { + id: '4', + name: '商品4', + price: '400', + img: '', + }, ]) \ No newline at end of file diff --git a/src/Views/main.vue b/src/Views/main.vue index 12edcc6..5d7138a 100644 --- a/src/Views/main.vue +++ b/src/Views/main.vue @@ -1,69 +1,438 @@ \ No newline at end of file diff --git a/src/Views/product/productList.vue b/src/Views/product/productList.vue index 9a42d39..b0270e7 100644 --- a/src/Views/product/productList.vue +++ b/src/Views/product/productList.vue @@ -1,21 +1,23 @@ @@ -23,6 +25,7 @@ import { type PropType } from 'vue' import type { ProductDetail } from '@/Util/Type' import { useGlobalStore } from '@/Util/globalStore' +import router from '@/Route/route' // 接收父类传递的商品列表 const props = defineProps({ productList: { @@ -30,7 +33,13 @@ const props = defineProps({ default: () => [], }, }) - +// 点击商品跳转详情页 +const handleClick = (product: ProductDetail) => { + // id 加密 + const encryptedId = btoa(product.id) + // 跳转详情页 (新开页面) + window.open(`/product?id=${encryptedId}`, '_blank') +} \ No newline at end of file diff --git a/src/Views/product/productdetil.vue b/src/Views/product/productdetil.vue index c5702e2..5dec3e3 100644 --- a/src/Views/product/productdetil.vue +++ b/src/Views/product/productdetil.vue @@ -1,27 +1,809 @@ -