index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div v-loading="loading">
  3. <el-row :gutter="10">
  4. <!-- 左上角:基本信息 -->
  5. <el-col :span="14" class="detail-info-item">
  6. <UserBasicInfo :user="user">
  7. <template #header>
  8. <div class="card-header">
  9. <CardTitle title="基本信息" />
  10. <el-button size="small" text type="primary" @click="openForm('update')">
  11. 编辑
  12. </el-button>
  13. </div>
  14. </template>
  15. </UserBasicInfo>
  16. </el-col>
  17. <!-- 右上角:账户信息 -->
  18. <el-col :span="10" class="detail-info-item">
  19. <el-card class="h-full" shadow="never">
  20. <template #header>
  21. <CardTitle title="账户信息" />
  22. </template>
  23. <UserAccountInfo :user="user" :wallet="wallet" />
  24. </el-card>
  25. </el-col>
  26. <!-- 下边:账户明细 -->
  27. <!-- TODO 芋艿:【订单管理】【售后管理】【收藏记录】-->
  28. <el-card header="账户明细" shadow="never" style="width: 100%; margin-top: 20px">
  29. <template #header>
  30. <CardTitle title="账户明细" />
  31. </template>
  32. <el-tabs>
  33. <el-tab-pane label="积分">
  34. <UserPointList :user-id="id" />
  35. </el-tab-pane>
  36. <el-tab-pane label="签到" lazy>
  37. <UserSignList :user-id="id" />
  38. </el-tab-pane>
  39. <el-tab-pane label="成长值" lazy>
  40. <UserExperienceRecordList :user-id="id" />
  41. </el-tab-pane>
  42. <el-tab-pane label="余额" lazy>
  43. <UserBalanceList :wallet-id="wallet.id" />
  44. </el-tab-pane>
  45. <el-tab-pane label="收货地址" lazy>
  46. <UserAddressList :user-id="id" />
  47. </el-tab-pane>
  48. <el-tab-pane label="订单管理" lazy>
  49. <UserOrderList :user-id="id" />
  50. </el-tab-pane>
  51. <el-tab-pane label="售后管理" lazy>
  52. <UserAfterSaleList :user-id="id" />
  53. </el-tab-pane>
  54. <el-tab-pane label="收藏记录" lazy>
  55. <UserFavoriteList :user-id="id" />
  56. </el-tab-pane>
  57. <el-tab-pane label="优惠劵" lazy>
  58. <UserCouponList :user-id="id" />
  59. </el-tab-pane>
  60. <el-tab-pane label="推广用户" lazy>
  61. <UserBrokerageList :bind-user-id="id" />
  62. </el-tab-pane>
  63. </el-tabs>
  64. </el-card>
  65. </el-row>
  66. </div>
  67. <!-- 表单弹窗:添加/修改 -->
  68. <UserForm ref="formRef" @success="getUserData(id)" />
  69. </template>
  70. <script lang="ts" setup>
  71. import * as WalletApi from '@/api/pay/wallet/balance'
  72. import * as UserApi from '@/api/member/user'
  73. import { useTagsViewStore } from '@/store/modules/tagsView'
  74. import UserForm from '@/views/member/user/UserForm.vue'
  75. import UserAccountInfo from './UserAccountInfo.vue'
  76. import UserAddressList from './UserAddressList.vue'
  77. import UserBasicInfo from './UserBasicInfo.vue'
  78. import UserBrokerageList from './UserBrokerageList.vue'
  79. import UserCouponList from './UserCouponList.vue'
  80. import UserExperienceRecordList from './UserExperienceRecordList.vue'
  81. import UserOrderList from './UserOrderList.vue'
  82. import UserPointList from './UserPointList.vue'
  83. import UserSignList from './UserSignList.vue'
  84. import UserFavoriteList from './UserFavoriteList.vue'
  85. import UserAfterSaleList from './UserAftersaleList.vue'
  86. import UserBalanceList from './UserBalanceList.vue'
  87. import { CardTitle } from '@/components/Card/index'
  88. import { ElMessage } from 'element-plus'
  89. defineOptions({ name: 'MemberDetail' })
  90. const loading = ref(true) // 加载中
  91. const user = ref<UserApi.UserVO>({} as UserApi.UserVO)
  92. /** 添加/修改操作 */
  93. const formRef = ref()
  94. const openForm = (type: string) => {
  95. formRef.value.open(type, id)
  96. }
  97. /** 获得用户 */
  98. const getUserData = async (id: number) => {
  99. loading.value = true
  100. try {
  101. user.value = await UserApi.getUser(id)
  102. } finally {
  103. loading.value = false
  104. }
  105. }
  106. /** 初始化 */
  107. const { currentRoute } = useRouter() // 路由
  108. const { delView } = useTagsViewStore() // 视图操作
  109. const route = useRoute()
  110. const id = Number(route.params.id)
  111. /* 用户钱包相关信息 */
  112. const WALLET_INIT_DATA = {
  113. balance: 0,
  114. totalExpense: 0,
  115. totalRecharge: 0
  116. } as WalletApi.WalletVO // 钱包初始化数据
  117. const wallet = ref<WalletApi.WalletVO>(WALLET_INIT_DATA) // 钱包信息
  118. /** 查询用户钱包信息 */
  119. const getUserWallet = async () => {
  120. if (!id) {
  121. wallet.value = WALLET_INIT_DATA
  122. return
  123. }
  124. const params = { userId: id }
  125. wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA
  126. }
  127. onMounted(() => {
  128. if (!id) {
  129. ElMessage.warning('参数错误,会员编号不能为空!')
  130. delView(unref(currentRoute))
  131. return
  132. }
  133. getUserData(id)
  134. getUserWallet()
  135. })
  136. </script>
  137. <style lang="css" scoped>
  138. .detail-info-item:first-child {
  139. padding-left: 0 !important;
  140. }
  141. /* first-child 不生效有没有大佬给看下q.q */
  142. .detail-info-item:nth-child(2) {
  143. padding-right: 0 !important;
  144. }
  145. .card-header {
  146. display: flex;
  147. justify-content: space-between;
  148. align-items: center;
  149. }
  150. </style>