index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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
  11. v-if="user.id"
  12. type="primary"
  13. size="small"
  14. text
  15. @click="openForm('update', user.id)"
  16. >
  17. 编辑
  18. </el-button>
  19. </div>
  20. </template>
  21. </UserBasicInfo>
  22. </el-col>
  23. <!-- 右上角:账户信息 -->
  24. <el-col :span="10" class="detail-info-item">
  25. <el-card shadow="never">
  26. <template #header>
  27. <CardTitle title="账户信息" />
  28. </template>
  29. <AccountInfo />
  30. </el-card>
  31. </el-col>
  32. <!-- 下边:账户明细 -->
  33. <!-- TODO 芋艿:【收货地址】【订单管理】【售后管理】【收藏记录】【优惠劵】 -->
  34. <el-card header="账户明细" style="width: 100%; margin-top: 20px" shadow="never">
  35. <template #header>
  36. <CardTitle title="账户明细" />
  37. </template>
  38. <el-tabs v-model="activeName">
  39. <el-tab-pane label="积分" name="point">
  40. <PointList v-if="user.id" :user-id="user.id" />
  41. </el-tab-pane>
  42. <el-tab-pane label="签到" name="sign">
  43. <SignList v-if="user.id" :user-id="user.id" />
  44. </el-tab-pane>
  45. <el-tab-pane label="成长值" name="third">成长值(WIP)</el-tab-pane>
  46. <el-tab-pane label="余额" name="fourth">余额(WIP)</el-tab-pane>
  47. <el-tab-pane label="收货地址" name="address">
  48. <AddressList v-if="user.id" :user-id="user.id" />
  49. </el-tab-pane>
  50. <el-tab-pane label="订单管理" name="fourth">订单管理(WIP)</el-tab-pane>
  51. <el-tab-pane label="售后管理" name="fourth">售后管理(WIP)</el-tab-pane>
  52. <el-tab-pane label="收藏记录" name="fourth">收藏记录(WIP)</el-tab-pane>
  53. <el-tab-pane label="优惠劵" name="fourth">优惠劵(WIP)</el-tab-pane>
  54. </el-tabs>
  55. </el-card>
  56. </el-row>
  57. </div>
  58. <!-- 表单弹窗:添加/修改 -->
  59. <UserForm ref="formRef" v-if="user.id" @success="getUserData(user.id)" />
  60. </template>
  61. <script setup lang="ts">
  62. import PointList from '@/views/member/user/components/PointList.vue'
  63. import SignList from '@/views/member/user/components/SignList.vue'
  64. import CardTitle from '@/views/member/user/components/CardTitle.vue'
  65. import * as UserApi from '@/api/member/user'
  66. import UserForm from '@/views/member/user/UserForm.vue'
  67. import AccountInfo from '@/views/member/user/components/AccountInfo.vue'
  68. import UserBasicInfo from '@/views/member/user/components/UserBasicInfo.vue'
  69. import AddressList from '@/views/member/user/components/AddressList.vue'
  70. defineOptions({ name: 'MemberDetail' })
  71. const activeName = ref('point') // 账户明细 选中的 tabs
  72. const loading = ref(true) // 加载中
  73. let user = ref<UserApi.UserVO>({
  74. areaId: undefined,
  75. avatar: undefined,
  76. birthday: undefined,
  77. createTime: undefined,
  78. id: NaN,
  79. loginDate: undefined,
  80. loginIp: '',
  81. mark: '',
  82. mobile: '',
  83. name: '',
  84. nickname: '',
  85. registerIp: '',
  86. sex: 0,
  87. status: 0,
  88. areaName: ''
  89. })
  90. /** 添加/修改操作 */
  91. const formRef = ref()
  92. const openForm = (type: string, id?: number) => {
  93. formRef.value.open(type, id)
  94. }
  95. /** 获得用户 */
  96. const getUserData = async (id: number) => {
  97. loading.value = true
  98. try {
  99. user.value = await UserApi.getUser(id)
  100. } finally {
  101. loading.value = false
  102. }
  103. }
  104. /** 初始化 */
  105. const route = useRoute()
  106. const router = useRouter()
  107. const member_id = Number(route.params.userId as string)
  108. onMounted(() => {
  109. if (!member_id) {
  110. // TODO
  111. ElMessage.warning('参数错误,会员编号不能为空!')
  112. router.back()
  113. return
  114. }
  115. getUserData(member_id)
  116. })
  117. </script>
  118. <style scoped lang="css">
  119. /** TODO 这 3 个 css 貌似没用? */
  120. .detail-info-item:first-child {
  121. padding-left: 0 !important;
  122. }
  123. /* first-child 不生效有没有大佬给看下q.q */
  124. .detail-info-item:nth-child(2) {
  125. padding-right: 0 !important;
  126. }
  127. .card-header {
  128. display: flex;
  129. justify-content: space-between;
  130. align-items: center;
  131. }
  132. </style>