From b0470b8f86c70e246d1a8a553d03812331e42e2b Mon Sep 17 00:00:00 2001 From: xiaowang Date: Tue, 3 Mar 2026 17:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E4=B8=AA=E4=BA=BA=E8=B4=A6=E5=8F=B7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=8C=E5=96=84=EF=BC=8C=E6=B3=A8=E5=86=8C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=8C=E5=96=84=EF=BC=8C=E6=94=B6=E8=97=8F=EF=BC=8C?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= =?UTF-8?q?=EF=BC=8C=E5=88=9D=E7=89=88=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E6=8A=95=E5=85=A5=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/App.vue | 2 - Frontend/src/api/file.ts | 6 + Frontend/src/api/index.ts | 3 + Frontend/src/api/product.ts | 18 ++ Frontend/src/api/user.ts | 4 + Frontend/src/router/index.ts | 13 ++ Frontend/src/views/AccountSettingsView.vue | 151 +++++++++++---- Frontend/src/views/AuthView.vue | 179 +++++++++++++++++- Frontend/src/views/CartView.vue | 64 +++++-- Frontend/src/views/PasswordSettingsView.vue | 14 +- Frontend/src/views/ProductDetailView.vue | 106 +++++++++-- Frontend/src/views/ProductListView.vue | 77 +++++++- Frontend/src/views/ProfileView.vue | 16 +- Frontend/src/views/WishlistView.vue | 136 ++++++++++--- Frontend/src/views/admin/ProductsView.vue | 6 +- Frontend/src/views/admin/UsersView.vue | 7 +- .../controller/TagController.java | 3 +- .../controller/UserController.java | 43 +++++ .../yuminailcore/dto/LoginRequestDTO.java | 2 + .../dto/PhoneLoginRequestDTO.java | 2 + .../service/impl/UserServiceImpl.java | 50 ++++- .../src/main/resources/files/YumiNail.sql | 25 ++- .../src/main/resources/application.yaml | 6 + 23 files changed, 804 insertions(+), 129 deletions(-) diff --git a/Frontend/src/App.vue b/Frontend/src/App.vue index 73ac5f6f..417febba 100644 --- a/Frontend/src/App.vue +++ b/Frontend/src/App.vue @@ -74,8 +74,6 @@ watch(() => route.path, async () => { // 页面加载时获取购物车数量 loadCartCount() -// 每30秒自动更新一次购物车数量 -setInterval(loadCartCount, 30000) \ No newline at end of file diff --git a/Frontend/src/views/CartView.vue b/Frontend/src/views/CartView.vue index b8e503dc..b588c0e6 100644 --- a/Frontend/src/views/CartView.vue +++ b/Frontend/src/views/CartView.vue @@ -24,23 +24,22 @@ class="cart-item" :body-style="{ padding: '16px' }" hoverable - @click="handleProductClick(item)" >
-
+
-
+
{{ item.productTitle[0] }}
-

{{ item.productTitle }}

+

{{ item.productTitle }}

¥{{ item.price.toFixed(2) }}

@@ -744,36 +743,66 @@ onMounted(() => { .coupon-card { border-radius: 12px; overflow: hidden; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); + border: 1px solid #f0f0f0; + transition: all 0.3s ease; +} + +.coupon-card:hover { + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); + transform: translateY(-2px); } .coupon-header { display: flex; justify-content: space-between; align-items: center; - padding: 16px; + padding: 18px 20px; cursor: pointer; + background: linear-gradient(135deg, #f6f9ff 0%, #ffffff 100%); + border-bottom: 1px solid #e6f7ff; } .coupon-header:hover { - background-color: #f5f5f5; + background: linear-gradient(135deg, #e6f7ff 0%, #f6f9ff 100%); } .coupon-title { - font-size: 15px; + font-size: 16px; font-weight: 600; color: #333; + display: flex; + align-items: center; + gap: 8px; +} + +.coupon-title::before { + content: "🎁"; + font-size: 18px; } .coupon-value { - font-size: 14px; + font-size: 13px; + font-weight: 500; color: #1890ff; display: flex; align-items: center; - gap: 4px; + gap: 6px; + padding: 6px 12px; + background: rgba(24, 144, 255, 0.1); + border-radius: 20px; + transition: all 0.3s ease; + box-shadow: 0 1px 3px rgba(24, 144, 255, 0.2); +} + +.coupon-value:hover { + background: rgba(24, 144, 255, 0.2); + transform: scale(1.05); + box-shadow: 0 2px 6px rgba(24, 144, 255, 0.3); } .coupon-discount { - padding: 12px 16px; + padding: 14px 20px; background-color: #f0f9ff; border-top: 1px solid #e6f7ff; display: flex; @@ -783,13 +812,22 @@ onMounted(() => { .discount-label { font-size: 14px; - color: #333; + color: #666; + display: flex; + align-items: center; + gap: 6px; +} + +.discount-label::before { + content: "💰"; + font-size: 14px; } .discount-amount { - font-size: 16px; - font-weight: 600; + font-size: 18px; + font-weight: 700; color: #1890ff; + text-shadow: 0 1px 2px rgba(24, 144, 255, 0.3); } .discount { diff --git a/Frontend/src/views/PasswordSettingsView.vue b/Frontend/src/views/PasswordSettingsView.vue index 8e87d10f..98153660 100644 --- a/Frontend/src/views/PasswordSettingsView.vue +++ b/Frontend/src/views/PasswordSettingsView.vue @@ -82,6 +82,13 @@ const formState = reactive({ confirmPassword: '' }) +const validateConfirmPassword = (_, value: string) => { + if (value !== formState.password) { + return Promise.reject(new Error('两次输入的密码不一致')) + } + return Promise.resolve() +} + const formRules = { password: [ { required: true, message: '请输入新密码', trigger: 'blur' }, @@ -94,13 +101,6 @@ const formRules = { ] } -const validateConfirmPassword = (_, value: string) => { - if (value !== formState.password) { - return Promise.reject(new Error('两次输入的密码不一致')) - } - return Promise.resolve() -} - const handleSubmit = async () => { if (!formRef.value) return diff --git a/Frontend/src/views/ProductDetailView.vue b/Frontend/src/views/ProductDetailView.vue index 620507ed..d25f2c8c 100644 --- a/Frontend/src/views/ProductDetailView.vue +++ b/Frontend/src/views/ProductDetailView.vue @@ -69,7 +69,27 @@
- + + {{ tag.tagName }} + + {{ product.category }}
@@ -96,8 +116,9 @@ import { ArrowLeft, Star, Clock, Collection, ShoppingCart, Right } from '@elemen import { useRouter, useRoute } from 'vue-router' import { ElMessage } from 'element-plus' import { productApi, type ProductVO } from '@/api/product' - import { cartApi } from '@/api/cart' +import { wishlistApi } from '@/api/wishlist' +import { fileApi } from '@/api/file' // 注入更新购物车数量的方法 const updateCartCount = inject<() => Promise>('updateCartCount', async () => {}) @@ -122,6 +143,8 @@ const product = ref({ const isFavorite = ref(false) const currentImageIndex = ref(0) const productImages = ref([]) +const imageIdCache = ref>({}) +const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg==' // 从后端获取商品详情 const fetchProductDetail = async () => { @@ -133,18 +156,59 @@ const fetchProductDetail = async () => { product.value = response || {} await loadProductImages() + await checkWishlistStatus() } catch (error) { console.error('获取商品详情失败:', error) ElMessage.error('未登录,请先登录') } } +// 检查商品是否在收藏列表中 +const checkWishlistStatus = async () => { + if (product.value.id) { + const token = localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken') + if (!token) { + isFavorite.value = false + return + } + + try { + const status = await wishlistApi.checkWishlist(product.value.id) + isFavorite.value = status + } catch (error) { + console.error('检查收藏状态失败:', error) + isFavorite.value = false + } + } +} + // 加载商品图片 const loadProductImages = async () => { - // 由于ProductVO类型中没有imageFileIds属性,这里简化处理 - if (product.value.image) { - productImages.value = [product.value.image] - currentImageIndex.value = 0 + if (product.value.imageFileIds) { + const ids = product.value.imageFileIds.split(',') + const urls: string[] = [] + + for (const id of ids) { + if (id) { + try { + if (!imageIdCache.value[id]) { + const response = await fileApi.getSignedUrl(Number(id)) as any + imageIdCache.value[id] = response + } + urls.push(imageIdCache.value[id]) + } catch (error) { + console.error('获取签名链接失败:', error) + urls.push(DEFAULT_PRODUCT_IMAGE) + } + } + } + + if (urls.length > 0) { + productImages.value = urls + currentImageIndex.value = 0 + } + } else { + productImages.value = [DEFAULT_PRODUCT_IMAGE] } } @@ -158,10 +222,23 @@ const handleBackClick = () => { router.back() } -const handleFavoriteClick = () => { - isFavorite.value = !isFavorite.value - console.log('收藏状态:', isFavorite.value) - ElMessage.success(isFavorite.value ? '已收藏' : '已取消收藏') +const handleFavoriteClick = async () => { + if (!product.value.id) return + + try { + if (isFavorite.value) { + await wishlistApi.removeFromWishlist(product.value.id) + ElMessage.success('已取消收藏') + } else { + await wishlistApi.addToWishlist(product.value.id) + ElMessage.success('已收藏') + } + isFavorite.value = !isFavorite.value + console.log('收藏状态:', isFavorite.value) + } catch (error) { + console.error('操作收藏失败:', error) + ElMessage.error('操作失败,请重试') + } } const handleAddToCart = async () => { @@ -174,7 +251,7 @@ const handleAddToCart = async () => { console.log('调用cartApi.addToCart成功') // 实时更新购物车角标数字 await updateCartCount() - ElMessage.success(`已将 ${product.value.name} 添加到购物车`) + ElMessage.success(`已将 ${product.value.title || product.value.name || '商品'} 添加到购物车`) } catch (error) { console.error('添加到购物车失败:', error) ElMessage.error('添加到购物车失败,请重试') @@ -247,7 +324,12 @@ onMounted(() => { } .actions .active { - color: #ff4d4f; + color: #FFD700; + fill: #FFD700; +} + +.actions .active svg { + fill: #FFD700; } .product-image-container { diff --git a/Frontend/src/views/ProductListView.vue b/Frontend/src/views/ProductListView.vue index 11fb0c62..9d8de752 100644 --- a/Frontend/src/views/ProductListView.vue +++ b/Frontend/src/views/ProductListView.vue @@ -42,13 +42,13 @@
- {{ item.name ? item.name[0] : '商' }} + {{ (item.title || item.name) ? (item.title || item.name)[0] : '商' }}
-

{{ item.name }}

+

{{ item.title || item.name }}

{{ item.estimatedTime }} 分钟
@@ -69,7 +69,28 @@
-