From 1662bdab3acd0407c160ab3a802499aadf083d55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E5=AD=90=E7=90=A6?= <1702282943@qq.com>
Date: Wed, 25 Feb 2026 12:38:53 +0800
Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=BE=8E=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/src/App.vue | 134 +++++-
frontend/src/views/Home.vue | 488 +++++++++++++++++--
frontend/src/views/Login.vue | 234 +++++++++-
frontend/src/views/Orders.vue | 673 ++++++++++++++++++++++++---
frontend/src/views/ProductDetail.vue | 577 ++++++++++++++++++++---
frontend/src/views/Register.vue | 252 +++++++++-
6 files changed, 2181 insertions(+), 177 deletions(-)
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 7aef593..a608488 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -11,9 +11,139 @@ export default {
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue
index cf1a23f..7a42e9f 100644
--- a/frontend/src/views/Home.vue
+++ b/frontend/src/views/Home.vue
@@ -2,39 +2,116 @@
@@ -111,43 +188,382 @@ export default {
diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue
index d78e84d..4b44e66 100644
--- a/frontend/src/views/Login.vue
+++ b/frontend/src/views/Login.vue
@@ -1,17 +1,57 @@
-
+
-
- 登录
-
-
-
+
+
+ 🌸
+ 🌺
+ 🌻
+ 🌷
+ 🌹
+ 🌼
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+ 立即登录
+
- 登录
- 没有账号?注册
+
@@ -22,23 +62,33 @@ import { login } from '../api/auth';
export default {
data() {
return {
- form: { username: '', password: '' }
+ form: { username: '', password: '' },
+ loading: false
};
},
methods: {
submit() {
+ if (!this.form.username || !this.form.password) {
+ this.$message.warning('请填写完整信息');
+ return;
+ }
+ this.loading = true;
login(this.form).then((res) => {
if (!res || !res.data || res.data.code !== 0) {
+ this.loading = false;
return;
}
const data = res.data.data;
if (!data) {
+ this.loading = false;
return;
}
localStorage.setItem('token', data.token);
localStorage.setItem('user', JSON.stringify(data.user));
- this.$message.success('登录成功');
+ this.$message.success('登录成功,欢迎回来!');
this.$router.push('/');
+ }).catch(() => {
+ this.loading = false;
});
}
}
@@ -47,12 +97,166 @@ export default {
diff --git a/frontend/src/views/Orders.vue b/frontend/src/views/Orders.vue
index 1c521e0..e6aad43 100644
--- a/frontend/src/views/Orders.vue
+++ b/frontend/src/views/Orders.vue
@@ -1,56 +1,191 @@
-
+
-
- 返回首页
-
-
-
-
-
-
- {{ statusText(scope.row.order.status) }}
-
-
-
-
-
- 支付
- 取消
- 告白弹幕
- 评价
-
-
-
+
+
+
+
+
+
+
+
⏳
+
+
{{ pendingCount }}
+
待支付
+
+
+
+
+
+
💳
+
+
{{ paidCount }}
+
已支付
+
+
+
+
+
+
🚚
+
+
{{ shippedCount }}
+
配送中
+
+
+
+
+
+
✨
+
+
{{ completedCount }}
+
已完成
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+
+
{{ item.productName }}
+
+ ¥{{ item.unitPrice }}
+ x{{ item.quantity }}
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
![]()
+
{{ reviewProduct.productName }}
+
+
+
+
+
+
+
+
+
+
+
@@ -64,15 +199,32 @@ export default {
data() {
return {
orders: [],
+ filteredOrders: [],
+ filterStatus: 'all',
showReview: false,
reviewForm: {
orderId: null,
productId: null,
rating: 5,
content: ''
- }
+ },
+ reviewProduct: null
};
},
+ computed: {
+ pendingCount() {
+ return this.orders.filter(o => o.order.status === 'CREATED').length;
+ },
+ paidCount() {
+ return this.orders.filter(o => o.order.status === 'PAID').length;
+ },
+ shippedCount() {
+ return this.orders.filter(o => o.order.status === 'SHIPPED').length;
+ },
+ completedCount() {
+ return this.orders.filter(o => o.order.status === 'COMPLETED').length;
+ }
+ },
created() {
this.loadOrders();
},
@@ -81,17 +233,35 @@ export default {
const map = {
CREATED: '待支付',
PAID: '已支付',
- SHIPPED: '已发货',
+ SHIPPED: '配送中',
COMPLETED: '已完成',
CANCELED: '已取消'
};
return map[status] || status;
},
+ statusType(status) {
+ const map = {
+ CREATED: 'danger',
+ PAID: 'warning',
+ SHIPPED: 'primary',
+ COMPLETED: 'success',
+ CANCELED: 'info'
+ };
+ return map[status] || 'info';
+ },
loadOrders() {
listOrders().then((res) => {
this.orders = res.data.data || [];
+ this.filteredOrders = this.orders;
});
},
+ filterOrders() {
+ if (this.filterStatus === 'all') {
+ this.filteredOrders = this.orders;
+ } else {
+ this.filteredOrders = this.orders.filter(o => o.order.status === this.filterStatus);
+ }
+ },
pay(id) {
payOrder(id).then(() => {
this.$message.success('支付成功');
@@ -125,12 +295,14 @@ export default {
rating: 5,
content: ''
};
+ this.reviewProduct = firstItem;
this.showReview = true;
},
submitReview() {
createReview(this.reviewForm).then(() => {
this.$message.success('提交成功,等待审核');
this.showReview = false;
+ this.reviewProduct = null;
});
}
}
@@ -140,8 +312,403 @@ export default {
diff --git a/frontend/src/views/ProductDetail.vue b/frontend/src/views/ProductDetail.vue
index 46d54d3..3efbeba 100644
--- a/frontend/src/views/ProductDetail.vue
+++ b/frontend/src/views/ProductDetail.vue
@@ -1,38 +1,129 @@
-
+
-
- 返回首页
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
![]()
+
+ 库存紧张
+
+
+
-
- {{ product.name }}
- {{ product.description }}
- ¥{{ product.price }}
-
-
-
-
-
-
立即购买
+
+
+
+
+
+
+
{{ product.description }}
+
+
+
+
优惠价
+
+ ¥
+ {{ product.price }}
+
+
+ 原价 ¥{{ product.originalPrice }}
+
+
+
+
+
+ 数量
+
+
+ 库存 {{ product.stock }} 件
+
+
+
+
+ 配送地址
+
+
+
+
+ 添加地址
+
+
+
+
+
+
+ 立即购买
+
+
+
+ 写寄语
+
+
+
+
+
+ 新鲜保证
+ 同城配送
+ 精美包装
+ 售后无忧
+
-
- 用户评价
- 暂无评价
-
+
+
+
+
+
+
+
💬
+
暂无评价,快来成为第一个评价的人吧!
+
+
+
@@ -55,9 +146,16 @@ export default {
addresses: [],
addressId: null,
reviews: [],
- placeholder: 'https://via.placeholder.com/400x300?text=Flower'
+ placeholder: 'https://via.placeholder.com/600x600?text=Flower'
};
},
+ computed: {
+ averageRating() {
+ if (this.reviews.length === 0) return 0;
+ const sum = this.reviews.reduce((acc, review) => acc + review.rating, 0);
+ return Math.round((sum / this.reviews.length) * 10) / 10;
+ }
+ },
created() {
this.loadDetail();
this.loadAddresses();
@@ -121,46 +219,417 @@ export default {
diff --git a/frontend/src/views/Register.vue b/frontend/src/views/Register.vue
index 84446ef..02b67ce 100644
--- a/frontend/src/views/Register.vue
+++ b/frontend/src/views/Register.vue
@@ -1,20 +1,65 @@
-
+
-
- 注册
-
-
-
+
+
+ 🌸
+ 🌺
+ 🌻
+ 🌷
+ 🌹
+ 🌼
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+ 立即注册
+
- 注册
- 已有账号?登录
+
@@ -25,23 +70,37 @@ import { register } from '../api/auth';
export default {
data() {
return {
- form: { username: '', password: '', nickname: '' }
+ form: { username: '', password: '', nickname: '' },
+ loading: false
};
},
methods: {
submit() {
+ if (!this.form.username || !this.form.password || !this.form.nickname) {
+ this.$message.warning('请填写完整信息');
+ return;
+ }
+ if (this.form.password.length < 6) {
+ this.$message.warning('密码至少需要6位');
+ return;
+ }
+ this.loading = true;
register(this.form).then((res) => {
if (!res || !res.data || res.data.code !== 0) {
+ this.loading = false;
return;
}
const data = res.data.data;
if (!data) {
+ this.loading = false;
return;
}
localStorage.setItem('token', data.token);
localStorage.setItem('user', JSON.stringify(data.user));
- this.$message.success('注册成功');
+ this.$message.success('注册成功,欢迎加入!');
this.$router.push('/');
+ }).catch(() => {
+ this.loading = false;
});
}
}
@@ -50,12 +109,171 @@ export default {