Skip to content

Commit fc5e37d

Browse files
authored
Merge pull request #78 from GoldenZqqq/Feature_MemberDetail
会员详情-余额tab页面开发
2 parents e2754b3 + 687c96b commit fc5e37d

File tree

3 files changed

+93
-27
lines changed

3 files changed

+93
-27
lines changed

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,7 @@ import * as UserApi from '@/api/member/user'
5050
import * as WalletApi from '@/api/pay/wallet/balance'
5151
import { UserTypeEnum } from '@/utils/constants'
5252
import { fenToYuan } from '@/utils'
53-
54-
const props = defineProps<{ user: UserApi.UserVO }>() // 用户信息
55-
const WALLET_INIT_DATA = {
56-
balance: 0,
57-
totalExpense: 0,
58-
totalRecharge: 0
59-
} as WalletApi.WalletVO // 钱包初始化数据
60-
const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
61-
62-
/** 查询用户钱包信息 */
63-
const getUserWallet = async () => {
64-
if (!props.user.id) {
65-
wallet.value = WALLET_INIT_DATA
66-
return
67-
}
68-
const params = { userId: props.user.id }
69-
wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA
70-
}
71-
72-
/** 监听用户编号变化 */
73-
watch(
74-
() => props.user.id,
75-
() => getUserWallet(),
76-
{ immediate: true }
77-
)
53+
const props = defineProps<{ user: UserApi.UserVO; wallet: WalletApi.WalletVO }>() // 用户信息
7854
</script>
7955
<style scoped lang="scss">
8056
.cell-item {
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<ContentWrap>
3+
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
4+
<el-table-column label="编号" align="center" prop="id" />
5+
<el-table-column label="钱包编号" align="center" prop="walletId" />
6+
<el-table-column label="关联业务标题" align="center" prop="title" />
7+
<el-table-column label="交易金额" align="center" prop="price">
8+
<template #default="{ row }"> {{ fenToYuan(row.price) }} 元</template>
9+
</el-table-column>
10+
<el-table-column label="钱包余额" align="center" prop="balance">
11+
<template #default="{ row }"> {{ fenToYuan(row.balance) }} 元</template>
12+
</el-table-column>
13+
<el-table-column
14+
label="交易时间"
15+
align="center"
16+
prop="createTime"
17+
:formatter="dateFormatter"
18+
width="180px"
19+
/>
20+
</el-table>
21+
<!-- 分页 -->
22+
<Pagination
23+
:total="total"
24+
v-model:page="queryParams.pageNo"
25+
v-model:limit="queryParams.pageSize"
26+
@pagination="getList"
27+
/>
28+
</ContentWrap>
29+
</template>
30+
31+
<script lang="ts" setup>
32+
import { dateFormatter } from '@/utils/formatTime'
33+
import * as WalletTransactionApi from '@/api/pay/wallet/transaction'
34+
import { fenToYuan } from '@/utils'
35+
defineOptions({ name: 'UserBalanceList' })
36+
const { walletId }: { walletId: number } = defineProps({
37+
walletId: {
38+
type: Number,
39+
required: false
40+
}
41+
})
42+
43+
const loading = ref(true) // 列表的加载中
44+
const total = ref(0) // 列表的总页数
45+
const queryParams = reactive({
46+
pageNo: 1,
47+
pageSize: 10,
48+
walletId: null
49+
})
50+
const list = ref([]) // 列表的数据
51+
/** 查询列表 */
52+
const getList = async () => {
53+
loading.value = true
54+
try {
55+
queryParams.walletId = walletId
56+
const data = await WalletTransactionApi.getWalletTransactionPage(queryParams)
57+
list.value = data.list
58+
total.value = data.total
59+
} finally {
60+
loading.value = false
61+
}
62+
}
63+
/** 初始化 **/
64+
onMounted(() => {
65+
getList()
66+
})
67+
</script>
68+
<style scoped lang="scss"></style>

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<template #header>
2121
<CardTitle title="账户信息" />
2222
</template>
23-
<UserAccountInfo :user="user" />
23+
<UserAccountInfo :user="user" :wallet="wallet"/>
2424
</el-card>
2525
</el-col>
2626
<!-- 下边:账户明细 -->
@@ -40,7 +40,9 @@
4040
<UserExperienceRecordList :user-id="id" />
4141
</el-tab-pane>
4242
<!-- TODO @jason:增加一个余额变化; -->
43-
<el-tab-pane label="余额" lazy>余额(WIP)</el-tab-pane>
43+
<el-tab-pane label="余额" lazy>
44+
<UserBalanceList :wallet-id="wallet.id" />
45+
</el-tab-pane>
4446
<el-tab-pane label="收货地址" lazy>
4547
<UserAddressList :user-id="id" />
4648
</el-tab-pane>
@@ -68,6 +70,7 @@
6870
<UserForm ref="formRef" @success="getUserData(id)" />
6971
</template>
7072
<script setup lang="ts">
73+
import * as WalletApi from '@/api/pay/wallet/balance'
7174
import * as UserApi from '@/api/member/user'
7275
import { useTagsViewStore } from '@/store/modules/tagsView'
7376
import UserForm from '@/views/member/user/UserForm.vue'
@@ -111,13 +114,32 @@ const { currentRoute } = useRouter() // 路由
111114
const { delView } = useTagsViewStore() // 视图操作
112115
const route = useRoute()
113116
const id = Number(route.params.id)
117+
/* 用户钱包相关信息 */
118+
const WALLET_INIT_DATA = {
119+
balance: 0,
120+
totalExpense: 0,
121+
totalRecharge: 0
122+
} as WalletApi.WalletVO // 钱包初始化数据
123+
const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
124+
125+
/** 查询用户钱包信息 */
126+
const getUserWallet = async () => {
127+
if (!id) {
128+
wallet.value = WALLET_INIT_DATA
129+
return
130+
}
131+
const params = { userId: id }
132+
wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA
133+
}
134+
114135
onMounted(() => {
115136
if (!id) {
116137
ElMessage.warning('参数错误,会员编号不能为空!')
117138
delView(unref(currentRoute))
118139
return
119140
}
120141
getUserData(id)
142+
getUserWallet()
121143
})
122144
</script>
123145
<style scoped lang="css">

0 commit comments

Comments
 (0)