UserAccountInfo.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <el-descriptions :column="2">
  3. <el-descriptions-item>
  4. <template #label>
  5. <descriptions-item-label label=" 等级 " icon="svg-icon:member_level" />
  6. </template>
  7. {{ user.levelName || '无' }}
  8. </el-descriptions-item>
  9. <el-descriptions-item>
  10. <template #label>
  11. <descriptions-item-label label=" 成长值 " icon="ep:suitcase" />
  12. </template>
  13. {{ user.experience || 0 }}
  14. </el-descriptions-item>
  15. <el-descriptions-item>
  16. <template #label>
  17. <descriptions-item-label label=" 当前积分 " icon="ep:coin" />
  18. </template>
  19. {{ user.point || 0 }}
  20. </el-descriptions-item>
  21. <el-descriptions-item>
  22. <template #label>
  23. <descriptions-item-label label=" 总积分 " icon="ep:coin" />
  24. </template>
  25. {{ user.totalPoint || 0 }}
  26. </el-descriptions-item>
  27. <el-descriptions-item>
  28. <template #label>
  29. <descriptions-item-label label=" 当前余额 " icon="svg-icon:member_balance" />
  30. </template>
  31. {{ wallet.balance || 0 }}
  32. </el-descriptions-item>
  33. <el-descriptions-item>
  34. <template #label>
  35. <descriptions-item-label label=" 支出金额 " icon="svg-icon:member_expenditure_balance" />
  36. </template>
  37. {{ wallet.totalExpense || 0 }}
  38. </el-descriptions-item>
  39. <el-descriptions-item>
  40. <template #label>
  41. <descriptions-item-label label=" 充值金额 " icon="svg-icon:member_recharge_balance" />
  42. </template>
  43. {{ wallet.totalRecharge || 0 }}
  44. </el-descriptions-item>
  45. </el-descriptions>
  46. </template>
  47. <script setup lang="ts">
  48. import { DescriptionsItemLabel } from '@/components/Descriptions'
  49. import * as UserApi from '@/api/member/user'
  50. import * as WalletApi from '@/api/pay/wallet'
  51. import { UserTypeEnum } from '@/utils/constants'
  52. const props = defineProps<{ user: UserApi.UserVO }>() // 用户信息
  53. const WALLET_INIT_DATA = {
  54. balance: 0,
  55. totalExpense: 0,
  56. totalRecharge: 0
  57. } as WalletApi.WalletVO // 钱包初始化数据
  58. const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
  59. /** 查询用户钱包信息 */
  60. const getUserWallet = async () => {
  61. if (!props.user.id) {
  62. wallet.value = WALLET_INIT_DATA
  63. return
  64. }
  65. const params = { userId: props.user.id, userType: UserTypeEnum.MEMBER }
  66. wallet.value = (await WalletApi.getUserWallet(params)) || WALLET_INIT_DATA
  67. }
  68. /** 监听用户编号变化 */
  69. watch(
  70. () => props.user.id,
  71. () => getUserWallet(),
  72. { immediate: true }
  73. )
  74. </script>
  75. <style scoped lang="scss">
  76. .cell-item {
  77. display: inline;
  78. }
  79. .cell-item::after {
  80. content: ':';
  81. }
  82. </style>