UserAccountInfo.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. {{ fenToYuan(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. {{ fenToYuan(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. {{ fenToYuan(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/balance'
  51. import { UserTypeEnum } from '@/utils/constants'
  52. import { fenToYuan } from '@/utils'
  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. const getUserWallet = async () => {
  62. if (!props.user.id) {
  63. wallet.value = WALLET_INIT_DATA
  64. return
  65. }
  66. const params = { userId: props.user.id, userType: UserTypeEnum.MEMBER }
  67. wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA
  68. }
  69. /** 监听用户编号变化 */
  70. watch(
  71. () => props.user.id,
  72. () => getUserWallet(),
  73. { immediate: true }
  74. )
  75. </script>
  76. <style scoped lang="scss">
  77. .cell-item {
  78. display: inline;
  79. }
  80. .cell-item::after {
  81. content: ':';
  82. }
  83. </style>