From 96ca2facc340d663fd79756a31c85deca7102b86 Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Wed, 3 Sep 2025 02:26:50 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=96=B0=E5=A2=9Evip=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user/index.js | 9 ++++ src/view/user/user/index.vue | 93 +++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/src/api/user/index.js b/src/api/user/index.js index ebd6abb..891b0a9 100644 --- a/src/api/user/index.js +++ b/src/api/user/index.js @@ -66,3 +66,12 @@ export const reviewTeacherApply = (data) => { data }) } + +// 修改用户VIP +export const setVip = (data) => { + return service({ + url: '/app_user/setUserVip', + method: 'put', + data + }) +} diff --git a/src/view/user/user/index.vue b/src/view/user/user/index.vue index 88be97a..150d3af 100644 --- a/src/view/user/user/index.vue +++ b/src/view/user/user/index.vue @@ -64,6 +64,7 @@ @@ -103,6 +104,48 @@ + + + + + {{ currentUser.user_label === 1 ? '注册会员' : currentUser.user_label === 2 ? 'VIP' : 'SVIP' }} + + + + + + + + + + + + + + + import searchForm from '@/components/searchForm/index.vue' import Content from '@/components/content/index.vue' - import {list, status, getUserDetail, register, setBalance} from '@/api/user/index.js' + import {list, status, getUserDetail, register, setBalance, setVip} from '@/api/user/index.js' import { ref, onMounted } from 'vue' import {formatDate} from '@/utils/format' import { USER_SEARCH_CONFIG, USER_TABLE_CONFIG } from '@/config' @@ -330,6 +373,23 @@ ] } + const vipDialogVisible = ref(false) + const vipFormRef = ref(null) + const vipForm = ref({ + id: '', + user_label: 1, + vip_expire_time: '' + }) + + const vipRules = { + user_label: [ + { required: true, message: '请选择VIP类型', trigger: 'change' } + ], + vip_expire_time: [ + { required: true, message: '请选择到期时间', trigger: 'change' } + ] + } + function handleBalance(row) { currentUser.value = row balanceForm.value = { @@ -359,6 +419,37 @@ } }) } + + function handleVip(row) { + currentUser.value = row + vipForm.value = { + id: row.ID, + user_label: row.user_label, + vip_expire_time: row.vip_expire_time || '' + } + vipDialogVisible.value = true + } + + function handleVipClose() { + vipDialogVisible.value = false + vipFormRef.value?.resetFields() + } + + async function submitVip() { + if (!vipFormRef.value) return + await vipFormRef.value.validate(async (valid) => { + if (valid) { + const res = await setVip(vipForm.value) + if (res.code === 0) { + ElMessage.success('设置成功') + handleVipClose() + getList() + } else { + ElMessage.error(res.msg || '设置失败') + } + } + }) + }