code review:用户详情

This commit is contained in:
YunaiV 2023-08-23 01:41:25 +08:00
parent 746bf864d9
commit 55772cbba0
12 changed files with 126 additions and 79 deletions

View File

@ -8,20 +8,9 @@ export interface RecordVO {
description: string description: string
point: number point: number
totalPoint: number totalPoint: number
status: number
userId: number userId: number
freezingTime: Date
thawingTime: Date
createDate: Date createDate: Date
} }
export interface RecordQueryVO {
bizType: string | null | undefined
title: string | null | undefined
pageNo: number
pageSize: number
userId: number | null | undefined
createDate: string[]
}
// 查询用户积分记录列表 // 查询用户积分记录列表
export const getRecordPage = async (params) => { export const getRecordPage = async (params) => {

View File

@ -6,15 +6,6 @@ export interface SignInRecordVO {
day: number day: number
point: number point: number
} }
export interface SignInRecordQueryVO {
pageNo: number
pageSize: number
userId?: number
nickname: number | undefined | null
day?: number | null | undefined
point?: number | null | undefined
createTime: string[] | null | undefined
}
// 查询用户签到积分列表 // 查询用户签到积分列表
export const getSignInRecordPage = async (params) => { export const getSignInRecordPage = async (params) => {

View File

@ -17,6 +17,8 @@ export interface UserVO {
mark: string mark: string
createTime: Date createTime: Date
} }
// TODO @梦:和 UserVO 搞成一个把。
export interface UserBaseInfoVO { export interface UserBaseInfoVO {
id: number | undefined | null id: number | undefined | null
mobile: string mobile: string
@ -34,6 +36,7 @@ export interface UserBaseInfoVO {
mark: string | null | undefined mark: string | null | undefined
createTime: Date | null | undefined createTime: Date | null | undefined
} }
// 查询会员用户列表 // 查询会员用户列表
export const getUserPage = async (params) => { export const getUserPage = async (params) => {
return await request.get({ url: `/member/user/page`, params }) return await request.get({ url: `/member/user/page`, params })

View File

@ -347,7 +347,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
] ]
}, },
{ {
path: '/property', path: '/property', // TODO @puhui999这里的 path 有问题,应该是 /product/property
component: Layout, component: Layout,
name: 'Property', name: 'Property',
meta: { meta: {
@ -427,6 +427,24 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
] ]
}, },
{
path: '/member',
component: Layout,
name: 'member',
meta: { hidden: true },
children: [
{
path: 'user/detail',
name: 'MemberUserDetail',
meta: {
title: '会员详情',
noCache: true,
hidden: true
},
component: () => import('@/views/member/user/detail/index.vue')
}
]
},
{ {
path: '/pay', path: '/pay',
component: Layout, component: Layout,

View File

@ -1,20 +1,10 @@
<template> <template>
<el-descriptions :column="2"> <el-descriptions :column="2">
<!-- TODO @要不 icon 也给加下 -->
<!-- TODO @积分成长值等级已经可以读取了可以看下 -->
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
<div class="cell-item"> 储值余额 </div> <div class="cell-item"> 等级 </div>
</template>
{{ 0 }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 现金余额 </div>
</template>
{{ 0 }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 积分 </div>
</template> </template>
{{ 0 }} {{ 0 }}
</el-descriptions-item> </el-descriptions-item>
@ -24,11 +14,39 @@
</template> </template>
{{ 0 }} {{ 0 }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 当前积分 </div>
</template>
{{ 0 }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 总积分 </div>
</template>
{{ 0 }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 当前余额 </div>
</template>
{{ 0 }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 支出金额 </div>
</template>
{{ 0 }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item"> 充值金额 </div>
</template>
{{ 0 }}
</el-descriptions-item>
</el-descriptions> </el-descriptions>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { defineComponent } from 'vue'
defineComponent({ defineComponent({
name: 'AccountInfo' name: 'AccountInfo'
}) })

View File

@ -6,6 +6,7 @@ export default defineComponent({
}) })
</script> </script>
<!-- TODO @可以读 address -->
<template> <template>
<div>收货地址列表</div> <div>收货地址列表</div>
</template> </template>

View File

@ -6,6 +6,7 @@ export default defineComponent({
}) })
</script> </script>
<!-- TODO @芋艿未来实现等周建的 -->
<template> <template>
<div>余额列表</div> <div>余额列表</div>
</template> </template>

View File

@ -1,8 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { defineComponent } from 'vue'
defineComponent({ defineComponent({
name: 'CardTitle' name: 'CardTitle'
}) })
const { title } = defineProps({ const { title } = defineProps({
title: { title: {
type: String, type: String,

View File

@ -6,6 +6,7 @@ export default defineComponent({
}) })
</script> </script>
<!-- TODO @可以读取 member_experience_log -->
<template> <template>
<div>成长值列表</div> <div>成长值列表</div>
</template> </template>

View File

@ -100,13 +100,13 @@
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as RecordApi from '@/api//member/point/record' import * as RecordApi from '@/api//member/point/record'
import { RecordQueryVO } from '@/api//member/point/record'
defineOptions({ name: 'PointList' }) defineOptions({ name: 'PointList' })
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive<RecordQueryVO>({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
bizType: undefined, bizType: undefined,
@ -139,12 +139,15 @@ const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
handleQuery() handleQuery()
} }
// TODO @: userId
const { memberId } = defineProps({ const { memberId } = defineProps({
memberId: { memberId: {
type: Number, type: Number,
required: true required: true
} }
}) })
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
queryParams.userId = memberId queryParams.userId = memberId

View File

@ -83,14 +83,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as SignInRecordApi from '@/api/member/signin/record' import * as SignInRecordApi from '@/api/member/signin/record'
import { SignInRecordQueryVO } from '@/api/member/signin/record'
defineOptions({ name: 'SignList' }) defineOptions({ name: 'SignList' })
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive<SignInRecordQueryVO>({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
nickname: null, nickname: null,
@ -122,12 +121,15 @@ const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
handleQuery() handleQuery()
} }
// TODO @: userId
const { memberId } = defineProps({ const { memberId } = defineProps({
memberId: { memberId: {
type: Number, type: Number,
required: true required: true
} }
}) })
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
queryParams.userId = memberId queryParams.userId = memberId

View File

@ -1,23 +1,27 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<el-row :gutter="10" class="detail-info-warp"> <el-row :gutter="10" class="detail-info-warp">
<!-- 左上角基本信息 -->
<el-col :span="14" class="detail-info-item"> <el-col :span="14" class="detail-info-item">
<el-card shadow="never"> <el-card shadow="never">
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<!-- TODO @如果不要小蓝线是不是直接用 el-card 自带的 title 即可 -->
<CardTitle title="基本信息" /> <CardTitle title="基本信息" />
<el-button <el-button
v-if="userInfo.id" v-if="user.id"
type="primary" type="primary"
size="small"
text text
@click="openForm('update', userInfo.id)" @click="openForm('update', user.id)"
>编辑</el-button
> >
编辑
</el-button>
</div> </div>
</template> </template>
<el-row> <el-row>
<el-col :span="4"> <el-col :span="4">
<ElAvatar shape="square" :size="140" :src="userInfo.avatar || undefined" /> <ElAvatar shape="square" :size="140" :src="user.avatar || undefined" />
</el-col> </el-col>
<el-col :span="20"> <el-col :span="20">
<el-descriptions :column="2"> <el-descriptions :column="2">
@ -28,7 +32,7 @@
用户名 用户名
</div> </div>
</template> </template>
{{ userInfo.name || '空' }} {{ user.name || '空' }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -37,8 +41,8 @@
昵称 昵称
</div> </div>
</template> </template>
{{ userInfo.nickname }}</el-descriptions-item {{ user.nickname }}
> </el-descriptions-item>
<el-descriptions-item label="手机号"> <el-descriptions-item label="手机号">
<template #label> <template #label>
<div class="cell-item"> <div class="cell-item">
@ -46,8 +50,8 @@
手机号 手机号
</div> </div>
</template> </template>
{{ userInfo.mobile }}</el-descriptions-item {{ user.mobile }}
> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
<div class="cell-item"> <div class="cell-item">
@ -55,7 +59,7 @@
性别 性别
</div> </div>
</template> </template>
<dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="userInfo.sex" /> <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="user.sex" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -64,16 +68,17 @@
所在地 所在地
</div> </div>
</template> </template>
{{ userInfo.areaId }} <!-- TODO @这里后端返回的时候要返回 areaName -->
{{ user.areaId }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
<div class="cell-item"> <div class="cell-item">
<Icon icon="ep:position" /> <Icon icon="ep:position" />
注册IP 注册 IP
</div> </div>
</template> </template>
{{ userInfo.registerIp }} {{ user.registerIp }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -82,7 +87,7 @@
生日 生日
</div> </div>
</template> </template>
{{ userInfo.birthday ? formatDate(userInfo.birthday) : '空' }} {{ user.birthday ? formatDate(user.birthday) : '空' }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -91,7 +96,7 @@
注册时间 注册时间
</div> </div>
</template> </template>
{{ userInfo.createTime ? formatDate(userInfo.createTime) : '空' }} {{ user.createTime ? formatDate(user.createTime) : '空' }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -100,31 +105,36 @@
最后登录时间 最后登录时间
</div> </div>
</template> </template>
{{ userInfo.loginDate ? formatDate(userInfo.loginDate) : '空' }} {{ user.loginDate ? formatDate(user.loginDate) : '空' }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
</el-col> </el-col>
<!-- 右上角账户信息 -->
<el-col :span="10" class="detail-info-item"> <el-col :span="10" class="detail-info-item">
<el-card shadow="never"> <el-card shadow="never">
<template #header> <template #header>
<CardTitle title="账户信息(WIP)" /> <CardTitle title="账户信息" />
</template> </template>
<AccountInfo /> <AccountInfo />
</el-card> </el-card>
</el-col> </el-col>
<!-- 下边账户明细 -->
<!-- TODO 芋艿收货地址订单管理售后管理收藏记录优惠劵 -->
<el-card header="账户明细" style="width: 100%; margin-top: 20px" shadow="never"> <el-card header="账户明细" style="width: 100%; margin-top: 20px" shadow="never">
<template #header> <template #header>
<CardTitle title="账户明细" /> <CardTitle title="账户明细" />
</template> </template>
<el-tabs v-model="activeName" class="demo-tabs"> <el-tabs v-model="activeName">
<el-tab-pane label="积分" name="point"> <el-tab-pane label="积分" name="point">
<PointList v-if="userInfo.id" :member-id="userInfo.id" /> <PointList v-if="user.id" :member-id="user.id" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="签到" name="sign"> <el-tab-pane label="签到" name="sign">
<SignList v-if="userInfo.id" :member-id="userInfo.id" /> <SignList v-if="user.id" :member-id="user.id" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="成长值" name="third">成长值(WIP)</el-tab-pane> <el-tab-pane label="成长值" name="third">成长值(WIP)</el-tab-pane>
<el-tab-pane label="余额" name="fourth">余额(WIP)</el-tab-pane> <el-tab-pane label="余额" name="fourth">余额(WIP)</el-tab-pane>
@ -132,30 +142,28 @@
</el-card> </el-card>
</el-row> </el-row>
</div> </div>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<UserForm ref="formRef" @success="getUserData(userInfo.id)" /> <UserForm ref="formRef" @success="getUserData(user.id)" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' // TODO @ vue
import PointList from '@/views/member/user/components/point-list.vue' import PointList from '@/views/member/user/components/point-list.vue'
import SignList from '@/views/member/user/components/sign-list.vue' import SignList from '@/views/member/user/components/sign-list.vue'
import CardTitle from '@/views/member/user/components/card-title.vue' import CardTitle from '@/views/member/user/components/card-title.vue'
import { ElMessage } from 'element-plus' // TODO @UserApi
import { getUser, UserBaseInfoVO } from '@/api/member/user' import { getUser, UserBaseInfoVO } from '@/api/member/user'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import UserForm from '@/views/member/user/UserForm.vue' import UserForm from '@/views/member/user/UserForm.vue'
// TODO @ AccountInfo
import AccountInfo from '@/views/member/user/components/account-info.vue' import AccountInfo from '@/views/member/user/components/account-info.vue'
defineOptions({ name: 'MemberDetail' }) defineOptions({ name: 'MemberDetail' })
const activeName = ref('point') const activeName = ref('point') // tabs
const loading = ref(true) const loading = ref(true) //
/** 添加/修改操作 */ let user = ref<UserBaseInfoVO>({
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
let userInfo = ref<UserBaseInfoVO>({
areaId: undefined, areaId: undefined,
avatar: undefined, avatar: undefined,
birthday: undefined, birthday: undefined,
@ -173,29 +181,40 @@ let userInfo = ref<UserBaseInfoVO>({
status: 0 status: 0
}) })
const getUserData = async (id: any) => { /** 获得用户 */
const getUserData = async (id: number) => {
loading.value = true loading.value = true
try { try {
// userInfo.value = Object.assign(userInfo, await getUser(parseInt(id as string))) user.value = await getUser(id)
userInfo.value = await getUser(parseInt(id as string))
} finally { } finally {
loading.value = false loading.value = false
} }
} }
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 初始化 */
const route = useRoute() const route = useRoute()
let router = useRouter() const router = useRouter()
const { member_id } = route.query // TODO @ id query
// TODO @
const member_id = route.query.member_id as number
onMounted(() => { onMounted(() => {
if (!member_id) { if (!member_id) {
ElMessage.warning('会员id 未携带!') // TODO
ElMessage.warning('参数错误,会员编号不能为空!')
router.back() router.back()
return return
} }
getUserData(member_id) getUserData(member_id)
}) })
</script> </script>
<style scoped lang="css"> <style scoped lang="css">
/** TODO 这 3 个 css 貌似没用? */
.detail-info-item:first-child { .detail-info-item:first-child {
padding-left: 0 !important; padding-left: 0 !important;
} }
@ -211,6 +230,7 @@ onMounted(() => {
.cell-item { .cell-item {
display: inline; display: inline;
} }
/** TODO 下面 css 貌似没啥用? */
.cell-item::after { .cell-item::after {
content: ':'; content: ':';
} }