diff --git a/.gitignore b/.gitignore index f134b1f9..8c82b52b 100644 --- a/.gitignore +++ b/.gitignore @@ -368,3 +368,6 @@ buildNumber.properties # JDT-specific (Eclipse Java Development Tools) .classpath +# Local Maven repository used for sandbox compile verification +m2repo/ + diff --git a/Frontend/src/api/auth.ts b/Frontend/src/api/auth.ts index 85394af7..38077756 100644 --- a/Frontend/src/api/auth.ts +++ b/Frontend/src/api/auth.ts @@ -1,5 +1,9 @@ import api from './index' +export interface SendVerificationCodeRequest { + phone: string +} + export interface LoginRequest { account: string password: string @@ -48,7 +52,17 @@ export interface RefreshTokenResponse { refreshToken: string } +export interface ResetPasswordRequest { + phone: string + verificationCode: string + newPassword: string +} + export const authApi = { + sendVerificationCode: (data: SendVerificationCodeRequest) => { + return api.post('/user/send-verification-code', data) + }, + login: (data: LoginRequest) => { return api.post('/user/login', data) }, @@ -75,5 +89,9 @@ export const authApi = { getUserInfo: () => { return api.get('/user/info') + }, + + resetPasswordByPhone: (data: ResetPasswordRequest) => { + return api.post('/user/reset-password-by-phone', data) } } \ No newline at end of file diff --git a/Frontend/src/api/cart.ts b/Frontend/src/api/cart.ts index 338b28d0..50e1e525 100644 --- a/Frontend/src/api/cart.ts +++ b/Frontend/src/api/cart.ts @@ -16,6 +16,11 @@ export const cartApi = { return api.delete(`/cart/remove/${productId}`) }, + // 批量从购物车移除作品 + batchRemoveFromCart: (cartItemIds: number[]) => { + return api.post('/cart/batch-remove', cartItemIds) + }, + // 更新购物车作品数量 updateCartQuantity: (item: CartItem) => { return api.put('/cart/update', item) diff --git a/Frontend/src/api/order.ts b/Frontend/src/api/order.ts index 3e26d287..3cc6586e 100644 --- a/Frontend/src/api/order.ts +++ b/Frontend/src/api/order.ts @@ -1,8 +1,14 @@ import api from './index' +interface OrderItem { + productId: number + quantity: number + artistId?: number +} + interface CreateOrderRequest { couponId?: number - artistId?: number + items: OrderItem[] } export const orderApi = { @@ -36,5 +42,10 @@ export const orderApi = { return api.put(`/order/admin/process/${orderId}`, {}, { params: { status } }) + }, + + // 美甲师查看自己的订单 + getArtistOrders: () => { + return api.get('/order/artist/list') } } diff --git a/Frontend/src/router/index.ts b/Frontend/src/router/index.ts index 7c9fe685..7da3cfa6 100644 --- a/Frontend/src/router/index.ts +++ b/Frontend/src/router/index.ts @@ -57,6 +57,12 @@ const router = createRouter({ component: () => import('../views/OrderView.vue'), meta: { requiresAuth: true, hideNav: true, isAdmin: false } }, + { + path: '/artist-orders', + name: 'artist-orders', + component: () => import('../views/ArtistOrderView.vue'), + meta: { requiresAuth: true, hideNav: true, isAdmin: false, permissionCode: 'order:artist:view' } + }, { path: '/settings', name: 'settings', diff --git a/Frontend/src/views/AccountSettingsView.vue b/Frontend/src/views/AccountSettingsView.vue index d3492d51..6bf173ce 100644 --- a/Frontend/src/views/AccountSettingsView.vue +++ b/Frontend/src/views/AccountSettingsView.vue @@ -340,6 +340,12 @@ const handleSendVerificationCode = async () => { return } + const phoneRegex = /^1[3-9]\d{9}$/ + if (!phoneRegex.test(bindPhoneForm.phone)) { + message.error('手机号格式不正确') + return + } + try { await userApi.sendVerificationCode({ phone: bindPhoneForm.phone }) message.success('验证码发送成功') @@ -357,6 +363,12 @@ const handleSendChangePhoneVerificationCode = async () => { return } + const phoneRegex = /^1[3-9]\d{9}$/ + if (!phoneRegex.test(changePhoneForm.newPhone)) { + message.error('手机号格式不正确') + return + } + try { await userApi.sendVerificationCode({ phone: changePhoneForm.newPhone }) message.success('验证码发送成功') @@ -374,6 +386,12 @@ const handleSendChangePasswordVerificationCode = async () => { return } + const phoneRegex = /^1[3-9]\d{9}$/ + if (!phoneRegex.test(userInfo.value.phone)) { + message.error('手机号格式不正确') + return + } + try { await userApi.sendVerificationCode({ phone: userInfo.value.phone }) message.success('验证码发送成功') diff --git a/Frontend/src/views/AuthView.vue b/Frontend/src/views/AuthView.vue index 495b6304..6ddb7f26 100644 --- a/Frontend/src/views/AuthView.vue +++ b/Frontend/src/views/AuthView.vue @@ -303,6 +303,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 重置密码 + + + + + + 取消 + + + + @@ -327,6 +406,16 @@ const accountStatus = ref(null) const phoneUserStatus = ref(null) const countdown = ref(0) +const forgotPasswordVisible = ref(false) +const forgotCountdown = ref(0) +const resettingPassword = ref(false) + +const forgotPasswordForm = reactive({ + phone: '', + verificationCode: '', + newPassword: '' +}) + const formData = reactive({ account: '', password: '', @@ -342,6 +431,14 @@ const validatePassword = async (_rule: any, value: string) => { if (value.length < 6) { return Promise.reject('密码长度不能少于6位') } + let count = 0 + if (/\d/.test(value)) count++ + if (/[a-z]/.test(value)) count++ + if (/[A-Z]/.test(value)) count++ + if (/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(value)) count++ + if (count < 3) { + return Promise.reject('密码必须包含数字、小写字母、大写字母和符号中的至少3种') + } return Promise.resolve() } @@ -357,9 +454,7 @@ const validateConfirmPassword = async (_rule: any, value: string) => { const rules: Record = { account: [ - { required: true, message: '请输入账号', trigger: 'blur' }, - { min: 3, max: 50, message: '账号长度在3到50个字符', trigger: 'blur' }, - { pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' } + { required: true, message: '请输入账号', trigger: 'blur' } ], phone: [ { required: true, message: '请输入手机号', trigger: 'blur' }, @@ -379,13 +474,28 @@ const rules: Record = { ], nickname: [ { required: true, message: '请输入昵称', trigger: 'blur' }, - { min: 2, max: 20, message: '昵称长度在2到20个字符', trigger: 'blur' } + { min: 2, max: 20, message: '昵称长度在2到20个字符', trigger: 'blur' }, + { pattern: /^[\u4e00-\u9fa5a-zA-Z0-9_]+$/, message: '昵称不能包含特殊符号', trigger: 'blur' } ], shopId: [ { required: true, message: '请选择店铺', trigger: 'change' } ] } +const forgotPasswordRules: Record = { + phone: [ + { required: true, message: '请输入手机号', trigger: 'blur' }, + { pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确', trigger: 'blur' } + ], + verificationCode: [ + { required: true, message: '请输入验证码', trigger: 'blur' }, + { pattern: /^\d{6}$/, message: '验证码必须是6位数字', trigger: 'blur' } + ], + newPassword: [ + { required: true, message: '请输入新密码', trigger: 'blur' } + ] +} + const fetchShops = async () => { loadingShops.value = true try { @@ -474,7 +584,55 @@ const handleSubmit = async () => { } const handleForgotPassword = () => { - message.info('忘记密码功能开发中') + forgotPasswordVisible.value = true +} + +const handleSendForgotCode = async () => { + if (!forgotPasswordForm.phone) { + message.error('请输入手机号') + return + } + + const phoneRegex = /^1[3-9]\d{9}$/ + if (!phoneRegex.test(forgotPasswordForm.phone)) { + message.error('手机号格式不正确') + return + } + + try { + await authApi.sendVerificationCode({ phone: forgotPasswordForm.phone }) + message.success('验证码已发送') + forgotCountdown.value = 60 + const timer = setInterval(() => { + forgotCountdown.value-- + if (forgotCountdown.value <= 0) { + clearInterval(timer) + } + }, 1000) + } catch (error: any) { + message.error(error.response?.data?.message || '发送验证码失败') + } +} + +const handleResetPassword = async () => { + resettingPassword.value = true + try { + await authApi.resetPasswordByPhone({ + phone: forgotPasswordForm.phone, + verificationCode: forgotPasswordForm.verificationCode, + newPassword: forgotPasswordForm.newPassword + }) + message.success('密码重置成功,请使用新密码登录') + forgotPasswordVisible.value = false + + forgotPasswordForm.phone = '' + forgotPasswordForm.verificationCode = '' + forgotPasswordForm.newPassword = '' + } catch (error: any) { + message.error(error.response?.data?.message || '重置密码失败') + } finally { + resettingPassword.value = false + } } const handleWeChatLogin = () => { @@ -542,6 +700,12 @@ const handleSendVerificationCode = async () => { return } + const phoneRegex = /^1[3-9]\d{9}$/ + if (!phoneRegex.test(formData.phone)) { + message.error('手机号格式不正确') + return + } + try { await userApi.sendVerificationCode({ phone: formData.phone }) message.success('验证码已发送') diff --git a/Frontend/src/views/CartView.vue b/Frontend/src/views/CartView.vue index f1da13bb..8b39c6d4 100644 --- a/Frontend/src/views/CartView.vue +++ b/Frontend/src/views/CartView.vue @@ -42,6 +42,18 @@

{{ item.productTitle }}

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

+ +
+ + + {{ item.artist.name }} + + + 选择美甲师 + + +
+
@@ -83,7 +95,7 @@
优惠券
- {{ selectedCoupon ? '已选择: ' + selectedCoupon.couponName : '请选择' }} + {{ selectedCoupon ? selectedCoupon.couponName : '使用优惠券' }}
@@ -122,14 +134,14 @@ block @click="handleCheckout" > - 结算 ({{ selectedCount }}) - ¥{{ totalAmount.toFixed(2) }} + 确认 {{ selectedCount }} 笔订单- 预计金额 ¥{{ totalAmount.toFixed(2) }}
@@ -206,8 +217,8 @@ v-for="artist in availableArtists" :key="artist.id" class="artist-item" - :class="{ 'selected': selectedArtist && selectedArtist.id === artist.id }" - @click="toggleArtistSelection(artist)" + :class="{ 'selected': currentEditingItem && currentEditingItem.artistId === artist.id }" + @click="selectArtist(artist)" >
@@ -238,7 +249,7 @@ {{ skill }}
-
+
@@ -283,6 +294,18 @@ interface CartItem { totalPrice: number tags: string selected: boolean + artistId?: number + artist?: { + id: number + name: string + avatar?: string + signature?: string + shopName?: string + status?: number + experience?: number + skills?: string + rating?: number + } } const router = useRouter() @@ -516,7 +539,7 @@ const cancelCouponSelection = () => { // 美甲师选择相关状态 const showArtistModal = ref(false) -const selectedArtist = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number} | null>(null) +const currentEditingItem = ref(null) const availableArtists = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number}[]>([]) // 标签列表 const tagList = ref([]) @@ -592,28 +615,30 @@ const handleCheckout = async () => { return } - // 加载可用美甲师 - await loadAvailableArtists() - - // 显示美甲师选择弹窗 - showArtistModal.value = true -} - -// 选择美甲师并创建订单 -const selectArtistAndCheckout = async () => { - if (!selectedArtist.value) { - message.warning('请选择美甲师') + // 检查所有选中的作品是否都选择了美甲师 + const itemsWithoutArtist = selectedItems.filter(item => !item.artistId) + if (itemsWithoutArtist.length > 0) { + message.warning(`请为"${itemsWithoutArtist.map(item => item.productTitle).join('、')}"选择美甲师`) return } + // 创建订单 try { await orderApi.createOrder({ couponId: selectedCoupon.value ? selectedCoupon.value.id : undefined, - artistId: selectedArtist.value.id + items: selectedItems.map(item => ({ + productId: item.productId, + quantity: item.quantity, + artistId: item.artistId + })) }) message.success('订单创建成功') - showArtistModal.value = false - // 更新购物车数量(因为订单创建后购物车会被清空) + // 从购物车中移除已购买的商品 + const selectedIds = selectedItems.map(item => item.id) + await cartApi.batchRemoveFromCart(selectedIds) + // 更新购物车数据 + await loadCartItems() + // 更新购物车数量 await updateCartCount() router.push('/profile') } catch (error) { @@ -621,10 +646,31 @@ const selectArtistAndCheckout = async () => { } } +// 显示美甲师选择弹窗 +const showArtistSelection = (item: CartItem) => { + currentEditingItem.value = item + loadAvailableArtists() + showArtistModal.value = true +} + +// 选择美甲师 +const selectArtist = (artist: any) => { + if (currentEditingItem.value) { + currentEditingItem.value.artistId = artist.id + currentEditingItem.value.artist = artist + } +} + +// 确认选择 +const confirmArtistSelection = () => { + showArtistModal.value = false + currentEditingItem.value = null +} + // 关闭美甲师选择弹窗 const closeArtistModal = () => { showArtistModal.value = false - selectedArtist.value = null + currentEditingItem.value = null } // 获取美甲师头像 @@ -670,17 +716,6 @@ const getArtistSkills = (artist: any) => { }) } -// 切换美甲师选择状态 -const toggleArtistSelection = (artist: any) => { - if (selectedArtist.value && selectedArtist.value.id === artist.id) { - // 取消选择 - selectedArtist.value = null - } else { - // 选择新的美甲师 - selectedArtist.value = artist - } -} - // 监听选中作品变化,重新加载可用优惠券 watch( () => cartItems.value.map(item => ({ id: item.id, selected: item.selected, quantity: item.quantity })), @@ -807,6 +842,55 @@ onMounted(() => { font-size: 16px; } +.artist-selector { + display: flex; + align-items: center; + justify-content: space-between; + padding: 8px 12px; + background: #f8f9ff; + border-radius: 8px; + margin-bottom: 10px; + cursor: pointer; + transition: all 0.3s ease; +} + +.artist-selector:hover { + background: #e6f7ff; +} + +.selected-artist { + display: flex; + align-items: center; + gap: 8px; + color: #1890ff; + font-weight: 500; +} + +.artist-avatar-small { + width: 24px; + height: 24px; + border-radius: 50%; + object-fit: cover; +} + +.select-artist { + color: #999; + font-size: 13px; + display: flex; + align-items: center; + gap: 4px; +} + +.arrow-icon { + color: #999; + font-size: 12px; + transition: transform 0.3s ease; +} + +.artist-selector:hover .arrow-icon { + transform: translateX(4px); +} + .item-duration { color: #666; font-size: 13px; @@ -907,7 +991,7 @@ onMounted(() => { display: flex; justify-content: space-between; align-items: center; - padding: 18px 20px; + padding: 12px 16px; cursor: pointer; background: linear-gradient(135deg, #f6f9ff 0%, #ffffff 100%); border-bottom: 1px solid #e6f7ff; @@ -918,29 +1002,29 @@ onMounted(() => { } .coupon-title { - font-size: 16px; + font-size: 14px; font-weight: 600; color: #333; display: flex; align-items: center; - gap: 8px; + gap: 6px; } .coupon-title::before { content: "🎁"; - font-size: 18px; + font-size: 14px; } .coupon-value { - font-size: 13px; + font-size: 12px; font-weight: 500; color: #1890ff; display: flex; align-items: center; - gap: 6px; - padding: 6px 12px; + gap: 4px; + padding: 4px 10px; background: rgba(24, 144, 255, 0.1); - border-radius: 20px; + border-radius: 16px; transition: all 0.3s ease; box-shadow: 0 1px 3px rgba(24, 144, 255, 0.2); } @@ -952,7 +1036,7 @@ onMounted(() => { } .coupon-discount { - padding: 14px 20px; + padding: 10px 16px; background-color: #f0f9ff; border-top: 1px solid #e6f7ff; display: flex; @@ -961,20 +1045,20 @@ onMounted(() => { } .discount-label { - font-size: 14px; + font-size: 12px; color: #666; display: flex; align-items: center; - gap: 6px; + gap: 4px; } .discount-label::before { content: "💰"; - font-size: 14px; + font-size: 12px; } .discount-amount { - font-size: 18px; + font-size: 16px; font-weight: 700; color: #1890ff; text-shadow: 0 1px 2px rgba(24, 144, 255, 0.3); @@ -1014,15 +1098,17 @@ onMounted(() => { .coupon-content { display: flex; align-items: center; - padding: 16px; - gap: 16px; + padding: 10px; + gap: 10px; } .coupon-value { - font-size: 24px; + font-size: 18px; font-weight: 600; color: #ff4d4f; flex-shrink: 0; + min-width: 50px; + text-align: center; } .coupon-info { @@ -1031,29 +1117,29 @@ onMounted(() => { } .coupon-name { - font-size: 15px; + font-size: 13px; font-weight: 600; color: #333; - margin-bottom: 4px; + margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .coupon-condition { - font-size: 13px; + font-size: 11px; color: #666; - margin-bottom: 4px; + margin-bottom: 2px; } .coupon-time { - font-size: 12px; + font-size: 10px; color: #999; } .coupon-select { color: #1890ff; - font-size: 20px; + font-size: 16px; flex-shrink: 0; } diff --git a/Frontend/src/views/OrderView.vue b/Frontend/src/views/OrderView.vue index a4ce74c3..50b88568 100644 --- a/Frontend/src/views/OrderView.vue +++ b/Frontend/src/views/OrderView.vue @@ -33,6 +33,10 @@
{{ item.productTitle }}
¥{{ item.price.toFixed(2) }} x {{ item.quantity }}
+
+ + 美甲师: {{ item.artistName }} +
@@ -299,6 +303,21 @@ onMounted(() => { color: #666; } +.item-artist { + display: flex; + align-items: center; + gap: 6px; + font-size: 12px; + color: #1890ff; +} + +.artist-avatar-small { + width: 20px; + height: 20px; + border-radius: 50%; + object-fit: cover; +} + .order-footer { display: flex; justify-content: space-between; diff --git a/Frontend/src/views/ProductDetailView.vue b/Frontend/src/views/ProductDetailView.vue index 18fb6e6e..38af75cf 100644 --- a/Frontend/src/views/ProductDetailView.vue +++ b/Frontend/src/views/ProductDetailView.vue @@ -8,7 +8,7 @@

{{ product.name || '作品详情' }}

- +
@@ -115,7 +115,7 @@