商城调整
This commit is contained in:
@@ -68,6 +68,15 @@
|
||||
<div class="balance-value">{{ Math.abs(accountInfo.balance) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-checkbox
|
||||
v-model="accountInfo.is_distribute"
|
||||
@change="handleDistributeChange"
|
||||
class="distribute-checkbox"
|
||||
:true-label="true"
|
||||
:false-label="false"
|
||||
>
|
||||
默认自动匹配
|
||||
</el-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user