会员部分

This commit is contained in:
Flow 2025-06-13 17:04:18 +08:00
parent 6c361bc067
commit 0c7c2d89b2
2 changed files with 88 additions and 72 deletions

View File

@ -12,6 +12,8 @@ export interface PersonVO {
familyid: string // 家庭组号
familyrelation: number // 家庭关系1-主号2-兄弟3-父亲4-母亲5-子女6-其他
isvip: number // 是否会员0-否1-是
vipstarttime: string // VIP开通时间
vipendtime: string // VIP到期时间
idcard: string // 身份证号
createtime: string // 创建时间
updatetime: string // 更新时间

View File

@ -41,21 +41,27 @@
<el-table
v-loading="loading"
:data="memberList"
:show-overflow-tooltip="true"
>
<el-table-column label="姓名" align="center" prop="name" />
<el-table-column label="手机号" align="center" prop="phone" />
<el-table-column label="VIP状态" align="center" prop="vipStatus" >
<el-table-column label="编号" align="center" prop="id" width="100"/>
<el-table-column label="姓名" align="center" prop="name" width="100"/>
<el-table-column label="手机号" align="center" prop="phone" width="200"/>
<el-table-column label="VIP状态" align="center" prop="isvip" width="100" >
<template #default="scope">
<el-tag :type="scope.row.vipStatus ? 'success' : 'info'">
{{ scope.row.vipStatus ? '已开通' : '未开通' }}
<el-tag :type="scope.row.isvip === 1 ? 'success' : 'info'">
{{ scope.row.isvip === 1 ? '已开通' : '未开通' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="地址" align="center" prop="address" />
<el-table-column label="到期时间" align="center" prop="vipExpireDate" >
<el-table-column label="剩余天数" align="center" prop="vipendtime" width="100">
<template #default="scope">
<span v-if="scope.row.vipStatus" class="text-primary">{{ scope.row.vipExpireDate }}</span>
<span v-if="scope.row.isvip === 1" class="text-primary">{{ calculateRemainingDays(scope.row.vipendtime, scope.row.vipstarttime) }}</span>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="到期时间" align="center" prop="vipendtime" width="200">
<template #default="scope">
<span v-if="scope.row.isvip === 1" class="text-primary">{{ formatDate(scope.row.vipendtime) }}</span>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
@ -63,7 +69,7 @@
<template #default="scope">
<div class="flex items-center justify-center">
<el-button
v-if="!scope.row.vipStatus"
v-if="scope.row.isvip === 0"
type="primary"
link
size="small"
@ -71,24 +77,24 @@
>
<Icon icon="ep:video-play" />开通会员
</el-button>
<el-button
v-else
type="primary"
link
size="small"
@click="handleRecharge(scope.row)"
>
<Icon icon="ep:refresh" />续费
</el-button>
<el-button
v-if="scope.row.vipStatus"
type="danger"
link
size="small"
@click="handleCancel(scope.row)"
>
<Icon icon="ep:close" />取消会员
</el-button>
<template v-else>
<el-button
type="primary"
link
size="small"
@click="handleRecharge(scope.row)"
>
<Icon icon="ep:refresh" />续费
</el-button>
<el-button
type="danger"
link
size="small"
@click="handleCancel(scope.row)"
>
<Icon icon="ep:close" />取消会员
</el-button>
</template>
</div>
</template>
</el-table-column>
@ -122,19 +128,18 @@
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import RechargeDialog from './components/RechargeDialog.vue'
import PasswordVerifyDialog from './components/PasswordVerifyDialog.vue'
import { PersonApi } from '@/api/person'
import { getUserProfile } from '@/api/system/user/profile'
//
const memberList = ref([])
const loading = ref(false)
const total = ref(0)
const userProfile = ref()
//
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: undefined,
vipStatus: undefined
})
const queryFormRef = ref()
@ -146,52 +151,61 @@ const passwordVerifyVisible = ref(false)
//
const currentMember = ref(null)
//
const mockMembers = [
{
id: 1,
name: '张三',
phone: '13800138000',
vipStatus: true,
vipExpireDate: '2024-12-31'
},
{
id: 2,
name: '李四',
phone: '13800138001',
vipStatus: false,
vipExpireDate: ''
},
{
id: 3,
name: '王五',
phone: '13800138002',
vipStatus: true,
vipExpireDate: '2024-06-30'
}
]
//
const calculateRemainingDays = (endTime, startTime) => {
if (!endTime || !startTime) return '-'
const end = new Date(endTime)
const start = new Date(startTime)
const now = new Date()
//
const totalDays = Math.ceil((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))
//
const remainingDays = Math.ceil((end.getTime() - now.getTime()) / (1000 * 60 * 60 * 24))
return remainingDays > 0 ? `${remainingDays}` : '已过期'
}
//
const formatDate = (date) => {
if (!date) return '-'
return new Date(date).toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
})
}
//
const getList = () => {
const getList = async () => {
loading.value = true
setTimeout(() => {
//
let filteredList = [...mockMembers]
if (queryParams.name) {
filteredList = filteredList.filter(m => m.name.includes(queryParams.name))
try {
//
userProfile.value = await getUserProfile()
const res = await PersonApi.getPersonPage({
pageNo: queryParams.pageNo,
pageSize: queryParams.pageSize,
orgid: userProfile.value.dept.id
})
//
if (res) {
memberList.value = res.list
total.value = res.total
console.log(memberList.value)
} else {
memberList.value = []
total.value = 0
}
if (queryParams.vipStatus !== undefined) {
filteredList = filteredList.filter(m => m.vipStatus === queryParams.vipStatus)
}
//
const start = (queryParams.pageNo - 1) * queryParams.pageSize
const end = start + queryParams.pageSize
memberList.value = filteredList.slice(start, end)
total.value = filteredList.length
} catch (error) {
console.error('获取会员列表失败:', error)
ElMessage.error('获取会员列表失败')
memberList.value = []
total.value = 0
} finally {
loading.value = false
}, 500)
}
}
//