Skip to content

Commit 675f3df

Browse files
committed
会员详情,查询钱包信息
1 parent 6475f81 commit 675f3df

File tree

3 files changed

+83
-23
lines changed

3 files changed

+83
-23
lines changed

src/api/pay/wallet/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import request from '@/config/axios'
2+
3+
/** 用户钱包查询参数 */
4+
export interface PayWalletUserReqVO {
5+
userId: number
6+
userType: number
7+
}
8+
/** 钱包 VO */
9+
export interface WalletVO {
10+
id: number
11+
userId: number
12+
userType: number
13+
balance: number
14+
totalExpense: number
15+
totalRecharge: number
16+
freezePrice: number
17+
}
18+
19+
/** 查询用户钱包详情 */
20+
export const getUserWallet = async (params: PayWalletUserReqVO) => {
21+
return await request.get<WalletVO>({ url: `/pay/wallet/user-wallet`, params })
22+
}

src/utils/constants.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
* 枚举类
55
*/
66

7+
// ========== COMMON 模块 ==========
78
// 全局通用状态枚举
89
export const CommonStatusEnum = {
910
ENABLE: 0, // 开启
1011
DISABLE: 1 // 禁用
1112
}
1213

14+
// 全局用户类型枚举
15+
export const UserTypeEnum = {
16+
MEMBER: 1, // 会员
17+
ADMIN: 2 // 管理员
18+
}
19+
20+
// ========== SYSTEM 模块 ==========
1321
/**
1422
* 菜单的类型枚举
1523
*/
@@ -38,6 +46,25 @@ export const SystemDataScopeEnum = {
3846
DEPT_SELF: 5 // 仅本人数据权限
3947
}
4048

49+
/**
50+
* 用户的社交平台的类型枚举
51+
*/
52+
export const SystemUserSocialTypeEnum = {
53+
DINGTALK: {
54+
title: '钉钉',
55+
type: 20,
56+
source: 'dingtalk',
57+
img: 'https://s1.ax1x.com/2022/05/22/OzMDRs.png'
58+
},
59+
WECHAT_ENTERPRISE: {
60+
title: '企业微信',
61+
type: 30,
62+
source: 'wechat_enterprise',
63+
img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png'
64+
}
65+
}
66+
67+
// ========== INFRA 模块 ==========
4168
/**
4269
* 代码生成模板类型
4370
*/
@@ -65,24 +92,7 @@ export const InfraApiErrorLogProcessStatusEnum = {
6592
IGNORE: 2 // 已忽略
6693
}
6794

68-
/**
69-
* 用户的社交平台的类型枚举
70-
*/
71-
export const SystemUserSocialTypeEnum = {
72-
DINGTALK: {
73-
title: '钉钉',
74-
type: 20,
75-
source: 'dingtalk',
76-
img: 'https://s1.ax1x.com/2022/05/22/OzMDRs.png'
77-
},
78-
WECHAT_ENTERPRISE: {
79-
title: '企业微信',
80-
type: 30,
81-
source: 'wechat_enterprise',
82-
img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png'
83-
}
84-
}
85-
95+
// ========== PAY 模块 ==========
8696
/**
8797
* 支付渠道枚举
8898
*/
@@ -177,6 +187,7 @@ export const PayOrderStatusEnum = {
177187
}
178188
}
179189

190+
// ========== MALL - 商品模块 ==========
180191
/**
181192
* 商品 SPU 状态
182193
*/
@@ -195,6 +206,7 @@ export const ProductSpuStatusEnum = {
195206
}
196207
}
197208

209+
// ========== MALL - 营销模块 ==========
198210
/**
199211
* 优惠劵模板的有限期类型的枚举
200212
*/
@@ -273,6 +285,7 @@ export const PromotionDiscountTypeEnum = {
273285
}
274286
}
275287

288+
// ========== MALL - 交易模块 ==========
276289
/**
277290
* 分销关系绑定模式枚举
278291
*/

src/views/member/user/detail/UserAccountInfo.vue

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,56 @@
2424
</template>
2525
{{ user.totalPoint || 0 }}
2626
</el-descriptions-item>
27-
<!-- TODO @疯狂:从 wallet 读取下对应字段 -->
2827
<el-descriptions-item>
2928
<template #label>
3029
<descriptions-item-label label=" 当前余额 " icon="svg-icon:member_balance" />
3130
</template>
32-
{{ 0 }}
31+
{{ wallet.balance || 0 }}
3332
</el-descriptions-item>
3433
<el-descriptions-item>
3534
<template #label>
3635
<descriptions-item-label label=" 支出金额 " icon="svg-icon:member_expenditure_balance" />
3736
</template>
38-
{{ 0 }}
37+
{{ wallet.totalExpense || 0 }}
3938
</el-descriptions-item>
4039
<el-descriptions-item>
4140
<template #label>
4241
<descriptions-item-label label=" 充值金额 " icon="svg-icon:member_recharge_balance" />
4342
</template>
44-
{{ 0 }}
43+
{{ wallet.totalRecharge || 0 }}
4544
</el-descriptions-item>
4645
</el-descriptions>
4746
</template>
4847
<script setup lang="ts">
4948
import { DescriptionsItemLabel } from '@/components/Descriptions'
5049
import * as UserApi from '@/api/member/user'
51-
const { user } = defineProps<{ user: UserApi.UserVO }>()
50+
import * as WalletApi from '@/api/pay/wallet'
51+
import { UserTypeEnum } from '@/utils/constants'
52+
53+
const props = defineProps<{ user: UserApi.UserVO }>() // 用户信息
54+
const WALLET_INIT_DATA = {
55+
balance: 0,
56+
totalExpense: 0,
57+
totalRecharge: 0
58+
} as WalletApi.WalletVO // 钱包初始化数据
59+
const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
60+
61+
/** 查询用户钱包信息 */
62+
const getUserWallet = async () => {
63+
if (!props.user.id) {
64+
wallet.value = WALLET_INIT_DATA
65+
return
66+
}
67+
const params = { userId: props.user.id, userType: UserTypeEnum.MEMBER }
68+
wallet.value = (await WalletApi.getUserWallet(params)) || WALLET_INIT_DATA
69+
}
70+
71+
/** 监听用户编号变化 */
72+
watch(
73+
() => props.user.id,
74+
() => getUserWallet(),
75+
{ immediate: true }
76+
)
5277
</script>
5378
<style scoped lang="scss">
5479
.cell-item {

0 commit comments

Comments
 (0)