index.tsx 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 styles from './index.module.less'
  6. import OpenMember from '../open-member'
  7. // import musicDefault from '../../images/music_default.png'
  8. // import musicActive from '../../images/music_active.png'
  9. // import entryDefault from '../../images/entry_default.png'
  10. // import entryActive from '../../images/entry_active.png'
  11. export const getAssetsHomeFile = (fileName: string) => {
  12. const path = `../../images/${fileName}`
  13. const modules = import.meta.globEager('../../images/*')
  14. return modules[path].default
  15. }
  16. export default defineComponent({
  17. name: 'users',
  18. computed: {
  19. userInfo() {
  20. return state.user.data
  21. }
  22. },
  23. data() {
  24. return {
  25. memberStatus: false
  26. }
  27. },
  28. methods: {
  29. onDetail(type: string) {
  30. if (type === 'entry') {
  31. this.$router.push({
  32. path: '/teacherAuth'
  33. })
  34. } else if (type === 'music') {
  35. this.$router.push({
  36. path: '/musicAuth'
  37. })
  38. }
  39. },
  40. // 检验是否有对应徽章
  41. checkBadge(type: string) {
  42. // tag : 老师点亮图标
  43. // STYLE:个人风采
  44. // VIDEO:视频课
  45. // LIVE:直播课,
  46. // MUSIC:曲目 逗号隔开
  47. let status = false
  48. const { userInfo } = this
  49. switch (type) {
  50. case 'STYLE':
  51. case 'VIDEO':
  52. case 'LIVE':
  53. case 'MUSIC':
  54. if (userInfo.tag) {
  55. status = userInfo.tag.indexOf(type) > -1
  56. }
  57. break
  58. case 'VIP':
  59. status = userInfo.isVip > 0
  60. break
  61. case 'SVIP':
  62. status =
  63. userInfo.userVip?.vipType === 'SVIP' ||
  64. userInfo.userVip?.vipType === 'PERMANENT_SVIP'
  65. break
  66. default:
  67. status = false
  68. break
  69. }
  70. return status
  71. }
  72. },
  73. render() {
  74. return (
  75. <div class={['text-center pb-8 relative overflow-hidden', styles.users]}>
  76. <div class="bg-[#CFF2FF] absolute left-6 top-0 text-[#0089B9] text-xs py-0.5 px-2 rounded-[10px]">
  77. 老师
  78. </div>
  79. <img
  80. src={this.userInfo.heardUrl || iconTeacher}
  81. class="w-[68px] h-[68px] rounded-full border-2 border-[#2DC7AA] border-solid mt-6 mx-auto object-cover"
  82. />
  83. <p class="text-[#333] text-lg font-semibold pt-4 flex items-center justify-center">
  84. {this.userInfo.username}
  85. {(this.checkBadge('SVIP') || this.checkBadge('VIP')) && (
  86. <img
  87. src={
  88. this.checkBadge('SVIP')
  89. ? getAssetsHomeFile('icon_svip.png')
  90. : this.checkBadge('VIP')
  91. ? getAssetsHomeFile('icon_vip.png')
  92. : ''
  93. }
  94. class="w-[42px] ml-1"
  95. />
  96. )}
  97. </p>
  98. <div class="flex items-center justify-center pt-2 pb-10">
  99. <span class="text-base text-[#999]">勋章</span>
  100. <img
  101. src={
  102. this.checkBadge('SVIP') || this.checkBadge('VIP')
  103. ? getAssetsHomeFile('icon_member.png')
  104. : getAssetsHomeFile('icon_member_default.png')
  105. }
  106. class="h-[26px] px-1"
  107. />
  108. <img
  109. src={
  110. this.checkBadge('STYLE')
  111. ? getAssetsHomeFile('icon_cert.png')
  112. : getAssetsHomeFile('icon_cert_default.png')
  113. }
  114. class="h-[26px] px-1"
  115. />
  116. <img
  117. src={
  118. this.checkBadge('VIDEO')
  119. ? getAssetsHomeFile('icon_video.png')
  120. : getAssetsHomeFile('icon_video_default.png')
  121. }
  122. class="h-[26px] px-1"
  123. />
  124. <img
  125. src={
  126. this.checkBadge('LIVE')
  127. ? getAssetsHomeFile('icon_live.png')
  128. : getAssetsHomeFile('icon_live_default.png')
  129. }
  130. class="h-[26px] px-1"
  131. />
  132. <img
  133. src={
  134. this.checkBadge('MUSIC')
  135. ? getAssetsHomeFile('icon_music.png')
  136. : getAssetsHomeFile('icon_music_default.png')
  137. }
  138. class="h-[26px] px-1"
  139. />
  140. </div>
  141. {/* <div class="pt-3 pb-6 flex">
  142. {this.userInfo.entryFlag === 1 ? (
  143. <img
  144. src={entryActive}
  145. class="h-[26px] cursor-pointer pr-2"
  146. onClick={() => {
  147. this.onDetail('entry')
  148. }}
  149. />
  150. ) : (
  151. <img
  152. src={entryDefault}
  153. class="h-[26px] cursor-pointer pr-2"
  154. onClick={() => {
  155. this.onDetail('entry')
  156. }}
  157. />
  158. )}
  159. {this.userInfo.musicianFlag === 1 ? (
  160. <img
  161. src={musicActive}
  162. class="h-[26px] cursor-pointer"
  163. onClick={() => {
  164. this.onDetail('music')
  165. }}
  166. />
  167. ) : (
  168. <img
  169. src={musicDefault}
  170. class="h-[26px] cursor-pointer"
  171. onClick={() => {
  172. this.onDetail('music')
  173. }}
  174. />
  175. )}
  176. </div> */}
  177. <div
  178. class={
  179. this.userInfo.entryFlag !== 1 || !this.checkBadge('VIP')
  180. ? 'mb-9'
  181. : ''
  182. }
  183. >
  184. {this.userInfo.entryFlag !== 1 && (
  185. <ElButton
  186. round
  187. type="primary"
  188. size="large"
  189. plain
  190. class="!px-4 !bg-white hover:!bg-[#2DC7AA]"
  191. onClick={() => {
  192. this.onDetail('entry')
  193. }}
  194. >
  195. 达人认证
  196. </ElButton>
  197. )}
  198. {!this.checkBadge('VIP') && (
  199. <ElButton
  200. round
  201. type="primary"
  202. size="large"
  203. class="!px-4"
  204. onClick={() => (this.memberStatus = true)}
  205. >
  206. 开通会员
  207. </ElButton>
  208. )}
  209. </div>
  210. <div class="text-base text-[#999] mx-[25px] flex items-center justify-center pt-10 border-t border-solid border-[#E7E6E6]">
  211. <span
  212. class="flex items-center justify-center flex-col leading-6 cursor-pointer flex-1 border-r border-solid border-[#E7E6E6]"
  213. onClick={() => {
  214. this.$router.push('/userInfo/myFans')
  215. }}
  216. >
  217. <b class="text-[#333333] text-[28px] pl-1 pb-1">
  218. {this.userInfo.fansNum || 0}
  219. </b>
  220. 粉丝
  221. </span>
  222. <span
  223. class="pl-3 flex items-center flex-col justify-center leading-6 cursor-pointer flex-1"
  224. onClick={() => {
  225. this.$router.push('/userInfo/musicClass')
  226. }}
  227. >
  228. <b class="text-[#333333] text-[28px] pl-1 pb-1">
  229. {this.userInfo.musicSheetNum || 0}
  230. </b>
  231. 乐谱
  232. </span>
  233. </div>
  234. <ElDialog
  235. modelValue={this.memberStatus}
  236. onUpdate:modelValue={val => (this.memberStatus = val)}
  237. closeOnClickModal={false}
  238. closeOnPressEscape={false}
  239. >
  240. <OpenMember />
  241. </ElDialog>
  242. </div>
  243. )
  244. }
  245. })