commit
fc5e37dd21
|
@ -50,31 +50,7 @@ import * as UserApi from '@/api/member/user'
|
||||||
import * as WalletApi from '@/api/pay/wallet/balance'
|
import * as WalletApi from '@/api/pay/wallet/balance'
|
||||||
import { UserTypeEnum } from '@/utils/constants'
|
import { UserTypeEnum } from '@/utils/constants'
|
||||||
import { fenToYuan } from '@/utils'
|
import { fenToYuan } from '@/utils'
|
||||||
|
const props = defineProps<{ user: UserApi.UserVO; wallet: WalletApi.WalletVO }>() // 用户信息
|
||||||
const props = defineProps<{ user: UserApi.UserVO }>() // 用户信息
|
|
||||||
const WALLET_INIT_DATA = {
|
|
||||||
balance: 0,
|
|
||||||
totalExpense: 0,
|
|
||||||
totalRecharge: 0
|
|
||||||
} as WalletApi.WalletVO // 钱包初始化数据
|
|
||||||
const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
|
|
||||||
|
|
||||||
/** 查询用户钱包信息 */
|
|
||||||
const getUserWallet = async () => {
|
|
||||||
if (!props.user.id) {
|
|
||||||
wallet.value = WALLET_INIT_DATA
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const params = { userId: props.user.id }
|
|
||||||
wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 监听用户编号变化 */
|
|
||||||
watch(
|
|
||||||
() => props.user.id,
|
|
||||||
() => getUserWallet(),
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.cell-item {
|
.cell-item {
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="钱包编号" align="center" prop="walletId" />
|
||||||
|
<el-table-column label="关联业务标题" align="center" prop="title" />
|
||||||
|
<el-table-column label="交易金额" align="center" prop="price">
|
||||||
|
<template #default="{ row }"> {{ fenToYuan(row.price) }} 元</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="钱包余额" align="center" prop="balance">
|
||||||
|
<template #default="{ row }"> {{ fenToYuan(row.balance) }} 元</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="交易时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import * as WalletTransactionApi from '@/api/pay/wallet/transaction'
|
||||||
|
import { fenToYuan } from '@/utils'
|
||||||
|
defineOptions({ name: 'UserBalanceList' })
|
||||||
|
const { walletId }: { walletId: number } = defineProps({
|
||||||
|
walletId: {
|
||||||
|
type: Number,
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
walletId: null
|
||||||
|
})
|
||||||
|
const list = ref([]) // 列表的数据
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
queryParams.walletId = walletId
|
||||||
|
const data = await WalletTransactionApi.getWalletTransactionPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<style scoped lang="scss"></style>
|
|
@ -20,7 +20,7 @@
|
||||||
<template #header>
|
<template #header>
|
||||||
<CardTitle title="账户信息" />
|
<CardTitle title="账户信息" />
|
||||||
</template>
|
</template>
|
||||||
<UserAccountInfo :user="user" />
|
<UserAccountInfo :user="user" :wallet="wallet"/>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- 下边:账户明细 -->
|
<!-- 下边:账户明细 -->
|
||||||
|
@ -40,7 +40,9 @@
|
||||||
<UserExperienceRecordList :user-id="id" />
|
<UserExperienceRecordList :user-id="id" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<!-- TODO @jason:增加一个余额变化; -->
|
<!-- TODO @jason:增加一个余额变化; -->
|
||||||
<el-tab-pane label="余额" lazy>余额(WIP)</el-tab-pane>
|
<el-tab-pane label="余额" lazy>
|
||||||
|
<UserBalanceList :wallet-id="wallet.id" />
|
||||||
|
</el-tab-pane>
|
||||||
<el-tab-pane label="收货地址" lazy>
|
<el-tab-pane label="收货地址" lazy>
|
||||||
<UserAddressList :user-id="id" />
|
<UserAddressList :user-id="id" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
@ -68,6 +70,7 @@
|
||||||
<UserForm ref="formRef" @success="getUserData(id)" />
|
<UserForm ref="formRef" @success="getUserData(id)" />
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import * as WalletApi from '@/api/pay/wallet/balance'
|
||||||
import * as UserApi from '@/api/member/user'
|
import * as UserApi from '@/api/member/user'
|
||||||
import { useTagsViewStore } from '@/store/modules/tagsView'
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
||||||
import UserForm from '@/views/member/user/UserForm.vue'
|
import UserForm from '@/views/member/user/UserForm.vue'
|
||||||
|
@ -111,6 +114,24 @@ const { currentRoute } = useRouter() // 路由
|
||||||
const { delView } = useTagsViewStore() // 视图操作
|
const { delView } = useTagsViewStore() // 视图操作
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const id = Number(route.params.id)
|
const id = Number(route.params.id)
|
||||||
|
/* 用户钱包相关信息 */
|
||||||
|
const WALLET_INIT_DATA = {
|
||||||
|
balance: 0,
|
||||||
|
totalExpense: 0,
|
||||||
|
totalRecharge: 0
|
||||||
|
} as WalletApi.WalletVO // 钱包初始化数据
|
||||||
|
const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
|
||||||
|
|
||||||
|
/** 查询用户钱包信息 */
|
||||||
|
const getUserWallet = async () => {
|
||||||
|
if (!id) {
|
||||||
|
wallet.value = WALLET_INIT_DATA
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const params = { userId: id }
|
||||||
|
wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
ElMessage.warning('参数错误,会员编号不能为空!')
|
ElMessage.warning('参数错误,会员编号不能为空!')
|
||||||
|
@ -118,6 +139,7 @@ onMounted(() => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
getUserData(id)
|
getUserData(id)
|
||||||
|
getUserWallet()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="css">
|
<style scoped lang="css">
|
||||||
|
|
Loading…
Reference in New Issue