From ed3116773e855f67c71c34acc696d7df58fa2fa9 Mon Sep 17 00:00:00 2001 From: dzl <786316265@qq.com> Date: Mon, 1 Sep 2025 13:39:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9F=8E=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/MyProfile.vue | 91 +++++++++++++++++++++- src/views/Orders.vue | 42 +++++----- src/views/Pay.vue | 167 +++++++++++++++++++++++----------------- 3 files changed, 208 insertions(+), 92 deletions(-) diff --git a/src/views/MyProfile.vue b/src/views/MyProfile.vue index b2b7fbb..eb10e07 100644 --- a/src/views/MyProfile.vue +++ b/src/views/MyProfile.vue @@ -68,6 +68,15 @@
{{ Math.abs(accountInfo.balance) }}
+ + 默认自动匹配 + @@ -136,7 +145,7 @@ export default { const avatarUrl = ref(''); const newAvatar = ref(''); const showAvatarUpload = ref(false); - const accountInfo = ref({ balance: '0.00' }); + const accountInfo = ref({ balance: '0.00', is_distribute: false }); const isLoading = ref(false); const settings = ref([ {text:'账号安全',path:'/editpasswordpage'}, @@ -160,7 +169,12 @@ export default { const response = await api.get(`/user/profile`); console.log(response.data); if (response.data.success) { - accountInfo.value = response.data.user || { balance: '0.00' }; + accountInfo.value = { + ...accountInfo.value, + ...response.data.user, + balance: response.data.user?.balance || '0.00', + is_distribute: response.data.user?.is_distribute || false + }; // 确保加载头像 if (response.data.user?.avatar) { avatarUrl.value = response.data.data.avatar; @@ -176,6 +190,44 @@ export default { } }; + // 处理默认自动匹配状态变化 + const handleDistributeChange = async (value) => { + try { + const action = value ? '开启' : '关闭'; + await ElMessageBox.confirm( + `确定要${action}默认自动匹配功能吗?`, + '确认操作', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + } + ); + + const response = await api.put(`/user/${userStore.user.id}/distribute`, { + is_distribute: value + }); + + if (response.data.success) { + ElMessage.success('默认自动匹配状态更新成功'); + } else { + // 如果更新失败,恢复原状态 + accountInfo.value.is_distribute = !value; + ElMessage.error(response.data.message || '默认自动匹配状态更新失败'); + } + } catch (error) { + if (error === 'cancel') { + // 用户取消操作,恢复原状态 + accountInfo.value.is_distribute = !value; + } else { + console.error('更新默认自动匹配状态失败:', error); + // 如果请求失败,恢复原状态 + accountInfo.value.is_distribute = !value; + ElMessage.error('默认自动匹配状态更新失败'); + } + } + }; + // 头像上传前的验证 const beforeAvatarUpload = (file) => { const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'; @@ -290,6 +342,7 @@ export default { uploadAvatar, confirmAvatarUpload, handleLogout, + handleDistributeChange, userStore }; } @@ -486,6 +539,7 @@ export default { display: flex; flex-direction: column; gap: 8px; + flex: 1; } .balance-label { @@ -495,6 +549,39 @@ export default { font-weight: 400; } +.distribute-checkbox { + color: white; +} + +.distribute-checkbox :deep(.el-checkbox__label) { + color: rgba(255, 255, 255, 0.9); + font-size: 12px; +} + +.distribute-checkbox :deep(.el-checkbox__input.is-checked .el-checkbox__inner) { + background-color: rgba(255, 255, 255, 0.9) !important; + border-color: rgba(255, 255, 255, 0.9) !important; +} + +.distribute-checkbox :deep(.el-checkbox__input.is-checked .el-checkbox__inner::after) { + border-color: #2f89ff !important; +} + +.distribute-checkbox :deep(.el-checkbox__inner) { + border-color: rgba(255, 255, 255, 0.6) !important; + background-color: transparent !important; +} + +.distribute-checkbox :deep(.el-checkbox__input.is-checked) { + .el-checkbox__inner { + background-color: rgba(255, 255, 255, 0.9) !important; + border-color: rgba(255, 255, 255, 0.9) !important; + } + .el-checkbox__inner::after { + border-color: #2f89ff !important; + } +} + .balance-value { font-size: 28px; font-weight: 600; diff --git a/src/views/Orders.vue b/src/views/Orders.vue index 1acc35a..320e4ed 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -47,7 +47,7 @@ -
+
@@ -78,11 +78,6 @@ {{ item.points }} - + - - 融豆 - {{ item.rongdouPrice }} -
x{{ item.quantity }}
@@ -100,10 +95,6 @@ {{ order.totalPoints }} - + - - 融豆{{ order.totalRongdou }} -
@@ -111,6 +102,14 @@
+ + 立即支付 +
{{ item.points }} - + - 融豆{{ item.rongdouPrice }}
x {{ item.quantity }}
@@ -279,8 +276,6 @@
{{ orderDetail.totalPoints }} - + - 融豆{{ orderDetail.totalRongdou }}
@@ -289,8 +284,6 @@
{{ orderDetail.totalPoints }} - + - 融豆{{ orderDetail.totalRongdou }}
@@ -333,7 +326,7 @@ const submittingReview = ref(false) // 状态标签 const statusTabs = ref([ { label: '全部', value: 'all', count: 0 }, - { label: '待发货', value: 'pending', count: 0 }, + { label: '待支付', value: 'pending', count: 0 }, { label: '已发货', value: 'shipped', count: 0 }, { label: '已完成', value: 'completed', count: 0 }, { label: '已取消', value: 'cancelled', count: 0 } @@ -355,7 +348,7 @@ const selectStatus = (status) => { const getEmptyText = () => { const textMap = { all: '暂无订单', - pending: '暂无待发货订单', + pending: '暂无待支付订单', shipped: '暂无已发货订单', completed: '暂无已完成订单', cancelled: '暂无已取消订单' @@ -386,7 +379,7 @@ const mapOrderStatus = (backendStatus) => { const getStatusText = (status) => { const textMap = { - pending: '待发货', + pending: '待支付', shipped: '已发货', completed: '已完成', cancelled: '已取消' @@ -411,6 +404,10 @@ const goToProduct = (productId) => { router.push(`/product/${productId}`) } +const goToPay = (orderId) => { + router.push(`/pay/${orderId}`) +} + const cancelOrder = async (orderId) => { try { await ElMessageBox.confirm('确定要取消这个订单吗?', '确认取消', { @@ -720,7 +717,12 @@ onMounted(() => { .orders-list { display: flex; flex-direction: column; - gap: 16px; +} + +.orders-container { + display: flex; + flex-direction: column; + gap: 10px; } .order-card { diff --git a/src/views/Pay.vue b/src/views/Pay.vue index ec15865..f22c1ec 100644 --- a/src/views/Pay.vue +++ b/src/views/Pay.vue @@ -69,8 +69,8 @@

支付

- -