index.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import { defineComponent } from 'vue'
  2. import iconTeacher from '@/common/images/icon_teacher.png'
  3. import { ElButton, ElDialog, ElTag } from 'element-plus'
  4. import { state } from '@/state'
  5. import { getUserType } from '@/helpers/utils'
  6. import styles from './index.module.less'
  7. import OpenMember from '@/views/user-info/components/open-member'
  8. export const getAssetsHomeFile = (fileName: string) => {
  9. const path = `../../../user-info/images/${fileName}`
  10. const modules = import.meta.globEager('../../../user-info/images/*')
  11. return modules[path].default
  12. }
  13. export default defineComponent({
  14. name: 'users',
  15. computed: {
  16. userInfo() {
  17. return state.user.data
  18. }
  19. },
  20. data() {
  21. return {
  22. memberStatus: false
  23. }
  24. },
  25. methods: {
  26. // 检验是否有对应徽章
  27. checkBadge(type: string) {
  28. // tag : 老师点亮图标
  29. // STYLE:个人风采
  30. // VIDEO:视频课
  31. // LIVE:直播课,
  32. // MUSIC:曲目 逗号隔开
  33. let status = false
  34. const { userInfo } = this
  35. console.log(userInfo, 'userInfo')
  36. switch (type) {
  37. case 'STYLE':
  38. case 'VIDEO':
  39. case 'LIVE':
  40. case 'MUSIC':
  41. if (userInfo.tag) {
  42. status = userInfo.tag.indexOf(type) > -1
  43. }
  44. break
  45. case 'VIP':
  46. status = userInfo.userVip?.vipType === 'VIP'
  47. break
  48. case 'SVIP':
  49. status =
  50. userInfo.userVip?.vipType === 'SVIP' ||
  51. userInfo.userVip?.vipType === 'PERMANENT_SVIP'
  52. break
  53. default:
  54. status = false
  55. break
  56. }
  57. return status
  58. }
  59. },
  60. render() {
  61. return (
  62. <div class={['text-center pb-8 relative overflow-hidden', styles.users]}>
  63. <div class="bg-[#FFE7CF] absolute left-6 top-0 text-[#AB5400] text-xs py-0.5 px-2 rounded-[10px]">
  64. 学生
  65. </div>
  66. <img
  67. src={this.userInfo.heardUrl || iconTeacher}
  68. class="w-[68px] h-[68px] rounded-full border-2 border-[#2DC7AA] border-solid mt-6 mx-auto object-cover"
  69. />
  70. <p class="text-[#333] text-lg font-semibold pt-4 flex items-center justify-center">
  71. {this.userInfo.username}
  72. {(this.checkBadge('SVIP') || this.checkBadge('VIP')) && (
  73. <img
  74. src={
  75. this.checkBadge('SVIP')
  76. ? getAssetsHomeFile('icon_svip.png')
  77. : this.checkBadge('VIP')
  78. ? getAssetsHomeFile('icon_vip.png')
  79. : ''
  80. }
  81. class="w-[42px] ml-1"
  82. />
  83. )}
  84. {/* <img
  85. src={
  86. this.userInfo.isVip
  87. ? getAssetsHomeFile('icon_vip.png')
  88. : getAssetsHomeFile('icon_vip_default.png')
  89. }
  90. class="h-[26px]"
  91. /> */}
  92. </p>
  93. <div class={this.userInfo.isVip !== 1 ? 'mt-5' : ''}>
  94. {this.userInfo.isVip !== 1 && (
  95. <ElButton
  96. round
  97. type="primary"
  98. size="large"
  99. class="!px-4"
  100. onClick={() => {
  101. this.memberStatus = true
  102. }}
  103. >
  104. 开通会员
  105. </ElButton>
  106. )}
  107. </div>
  108. <div class="text-base text-[#999] mx-[25px] mt-9 flex items-center justify-center pt-10 border-t border-solid border-[#E7E6E6]">
  109. <span
  110. class="flex items-center justify-center flex-col leading-6 cursor-pointer flex-1"
  111. onClick={() => {
  112. this.$router.push('/studentInfo/myFollow')
  113. }}
  114. >
  115. <b class="text-[#333333] text-[28px] pl-1 pb-1">
  116. {this.userInfo.starTeacherNum || 0}
  117. </b>
  118. 关注
  119. </span>
  120. </div>
  121. <ElDialog
  122. modelValue={this.memberStatus}
  123. onUpdate:modelValue={val => (this.memberStatus = val)}
  124. closeOnClickModal={false}
  125. closeOnPressEscape={false}
  126. >
  127. <OpenMember />
  128. </ElDialog>
  129. </div>
  130. )
  131. }
  132. })