index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div v-loading="loading">
  3. <el-row :gutter="10" class="detail-info-warp">
  4. <!-- 左上角:基本信息 -->
  5. <el-col :span="14" class="detail-info-item">
  6. <el-card shadow="never">
  7. <template #header>
  8. <div class="card-header">
  9. <!-- TODO @梦:如果不要小蓝线,是不是直接用 el-card 自带的 title 即可? -->
  10. <CardTitle title="基本信息" />
  11. <el-button
  12. v-if="user.id"
  13. type="primary"
  14. size="small"
  15. text
  16. @click="openForm('update', user.id)"
  17. >
  18. 编辑
  19. </el-button>
  20. </div>
  21. </template>
  22. <el-row>
  23. <el-col :span="4">
  24. <ElAvatar shape="square" :size="140" :src="user.avatar || undefined" />
  25. </el-col>
  26. <el-col :span="20">
  27. <el-descriptions :column="2">
  28. <el-descriptions-item>
  29. <template #label>
  30. <div class="cell-item">
  31. <Icon icon="ep:user" />
  32. 用户名
  33. </div>
  34. </template>
  35. {{ user.name || '空' }}
  36. </el-descriptions-item>
  37. <el-descriptions-item>
  38. <template #label>
  39. <div class="cell-item">
  40. <Icon icon="ep:user" />
  41. 昵称
  42. </div>
  43. </template>
  44. {{ user.nickname }}
  45. </el-descriptions-item>
  46. <el-descriptions-item label="手机号">
  47. <template #label>
  48. <div class="cell-item">
  49. <Icon icon="ep:phone" />
  50. 手机号
  51. </div>
  52. </template>
  53. {{ user.mobile }}
  54. </el-descriptions-item>
  55. <el-descriptions-item>
  56. <template #label>
  57. <div class="cell-item">
  58. <Icon icon="fa:mars-double" />
  59. 性别
  60. </div>
  61. </template>
  62. <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="user.sex" />
  63. </el-descriptions-item>
  64. <el-descriptions-item>
  65. <template #label>
  66. <div class="cell-item">
  67. <Icon icon="ep:location" />
  68. 所在地
  69. </div>
  70. </template>
  71. <!-- TODO @梦:这里后端返回的时候,要返回 areaName -->
  72. {{ user.areaId }}
  73. </el-descriptions-item>
  74. <el-descriptions-item>
  75. <template #label>
  76. <div class="cell-item">
  77. <Icon icon="ep:position" />
  78. 注册 IP
  79. </div>
  80. </template>
  81. {{ user.registerIp }}
  82. </el-descriptions-item>
  83. <el-descriptions-item>
  84. <template #label>
  85. <div class="cell-item">
  86. <Icon icon="fa:birthday-cake" />
  87. 生日
  88. </div>
  89. </template>
  90. {{ user.birthday ? formatDate(user.birthday) : '空' }}
  91. </el-descriptions-item>
  92. <el-descriptions-item>
  93. <template #label>
  94. <div class="cell-item">
  95. <Icon icon="ep:calendar" />
  96. 注册时间
  97. </div>
  98. </template>
  99. {{ user.createTime ? formatDate(user.createTime) : '空' }}
  100. </el-descriptions-item>
  101. <el-descriptions-item>
  102. <template #label>
  103. <div class="cell-item">
  104. <Icon icon="ep:calendar" />
  105. 最后登录时间
  106. </div>
  107. </template>
  108. {{ user.loginDate ? formatDate(user.loginDate) : '空' }}
  109. </el-descriptions-item>
  110. </el-descriptions>
  111. </el-col>
  112. </el-row>
  113. </el-card>
  114. </el-col>
  115. <!-- 右上角:账户信息 -->
  116. <el-col :span="10" class="detail-info-item">
  117. <el-card shadow="never">
  118. <template #header>
  119. <CardTitle title="账户信息" />
  120. </template>
  121. <AccountInfo />
  122. </el-card>
  123. </el-col>
  124. <!-- 下边:账户明细 -->
  125. <!-- TODO 芋艿:【收货地址】【订单管理】【售后管理】【收藏记录】【优惠劵】 -->
  126. <el-card header="账户明细" style="width: 100%; margin-top: 20px" shadow="never">
  127. <template #header>
  128. <CardTitle title="账户明细" />
  129. </template>
  130. <el-tabs v-model="activeName">
  131. <el-tab-pane label="积分" name="point">
  132. <PointList v-if="user.id" :member-id="user.id" />
  133. </el-tab-pane>
  134. <el-tab-pane label="签到" name="sign">
  135. <SignList v-if="user.id" :member-id="user.id" />
  136. </el-tab-pane>
  137. <el-tab-pane label="成长值" name="third">成长值(WIP)</el-tab-pane>
  138. <el-tab-pane label="余额" name="fourth">余额(WIP)</el-tab-pane>
  139. </el-tabs>
  140. </el-card>
  141. </el-row>
  142. </div>
  143. <!-- 表单弹窗:添加/修改 -->
  144. <UserForm ref="formRef" @success="getUserData(user.id)" />
  145. </template>
  146. <script setup lang="ts">
  147. // TODO @梦:组件对应的 vue,都大写
  148. import PointList from '@/views/member/user/components/point-list.vue'
  149. import SignList from '@/views/member/user/components/sign-list.vue'
  150. import CardTitle from '@/views/member/user/components/card-title.vue'
  151. // TODO @梦:参考别的模块,UserApi 这样去引用
  152. import { getUser, UserBaseInfoVO } from '@/api/member/user'
  153. import { formatDate } from '@/utils/formatTime'
  154. import { DICT_TYPE } from '@/utils/dict'
  155. import UserForm from '@/views/member/user/UserForm.vue'
  156. // TODO @梦:把用户信息,也抽成一个组件,类似 AccountInfo
  157. import AccountInfo from '@/views/member/user/components/account-info.vue'
  158. defineOptions({ name: 'MemberDetail' })
  159. const activeName = ref('point') // 账户明细 选中的 tabs
  160. const loading = ref(true) // 加载中
  161. let user = ref<UserBaseInfoVO>({
  162. areaId: undefined,
  163. avatar: undefined,
  164. birthday: undefined,
  165. createTime: undefined,
  166. id: undefined,
  167. loginDate: undefined,
  168. loginIp: '',
  169. mark: '',
  170. mobile: '',
  171. name: '',
  172. nickname: '',
  173. password: null,
  174. registerIp: undefined,
  175. sex: 0,
  176. status: 0
  177. })
  178. /** 获得用户 */
  179. const getUserData = async (id: number) => {
  180. loading.value = true
  181. try {
  182. user.value = await getUser(id)
  183. } finally {
  184. loading.value = false
  185. }
  186. }
  187. /** 添加/修改操作 */
  188. const formRef = ref()
  189. const openForm = (type: string, id?: number) => {
  190. formRef.value.open(type, id)
  191. }
  192. /** 初始化 */
  193. const route = useRoute()
  194. const router = useRouter()
  195. // TODO @梦:改成 id 路径参数,而不是 query
  196. // TODO @梦:会员列表,把【详情】按钮加上哈
  197. const member_id = route.query.member_id as number
  198. onMounted(() => {
  199. if (!member_id) {
  200. // TODO
  201. ElMessage.warning('参数错误,会员编号不能为空!')
  202. router.back()
  203. return
  204. }
  205. getUserData(member_id)
  206. })
  207. </script>
  208. <style scoped lang="css">
  209. /** TODO 这 3 个 css 貌似没用? */
  210. .detail-info-item:first-child {
  211. padding-left: 0 !important;
  212. }
  213. /* first-child 不生效有没有大佬给看下q.q */
  214. .detail-info-item:nth-child(2) {
  215. padding-right: 0 !important;
  216. }
  217. .card-header {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. }
  222. .cell-item {
  223. display: inline;
  224. }
  225. /** TODO 下面 css 貌似没啥用? */
  226. .cell-item::after {
  227. content: ':';
  228. }
  229. </style>