teacher-header.tsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import { Button, Cell, Icon, Image, Popup, Rate, Toast } from 'vant'
  2. import { defineComponent } from 'vue'
  3. import styles from './teacher-header.module.less'
  4. import { postMessage } from '@/helpers/native-message'
  5. import iconTeacher from '@common/images/icon_teacher.png'
  6. import IconXueli from '@common/images/icon-xueli.png'
  7. import IconJiaozi from '@common/images/icon-jiaozi.png'
  8. export const getAssetsHomeFile = (fileName: string) => {
  9. const path = `../images/${fileName}`
  10. const modules = import.meta.globEager('../images/*')
  11. return modules[path].default
  12. }
  13. export default defineComponent({
  14. name: 'teacher-header',
  15. props: {
  16. userInfo: {
  17. type: Object,
  18. default: {}
  19. },
  20. teacherId: {
  21. type: String || Number,
  22. default: ''
  23. }
  24. },
  25. data() {
  26. return {
  27. iconShow: false
  28. }
  29. },
  30. computed: {
  31. subjectNameList() {
  32. const userInfo: any = this.userInfo
  33. const subjectName = userInfo.subjectName
  34. return subjectName ? subjectName.split(',') : []
  35. },
  36. starGrade() {
  37. const { starGrade } = this.userInfo as any
  38. return Number(starGrade) || 0
  39. }
  40. },
  41. methods: {
  42. // 检验是否有对应徽章
  43. checkBadge(type: string) {
  44. // tag : 老师点亮图标
  45. // STYLE:个人风采
  46. // VIDEO:视频课
  47. // LIVE:直播课,
  48. // MUSIC:曲目 逗号隔开
  49. let status = false
  50. const { userInfo } = this
  51. switch (type) {
  52. case 'STYLE':
  53. case 'VIDEO':
  54. case 'LIVE':
  55. case 'MUSIC':
  56. if (userInfo.tag) {
  57. status = userInfo.tag.indexOf(type) > -1
  58. }
  59. break
  60. case 'VIP':
  61. status = userInfo.userVip?.vipType === 'VIP'
  62. break
  63. case 'SVIP':
  64. status =
  65. userInfo.userVip?.vipType === 'SVIP' ||
  66. userInfo.userVip?.vipType === 'PERMANENT_SVIP'
  67. break
  68. default:
  69. status = false
  70. break
  71. }
  72. return status
  73. },
  74. openTeacherIcon() {
  75. this.iconShow = true
  76. }
  77. },
  78. render() {
  79. const iconList = [
  80. {
  81. icon: 'cert_active.png',
  82. title: '演奏Mlog老师',
  83. des: '个人风采中上传老师风采视频并通过审核'
  84. },
  85. {
  86. icon: 'video_active.png',
  87. title: '教学视频老师',
  88. des: '发布您制作的教学视频课程并通过审核'
  89. },
  90. {
  91. icon: 'live_active.png',
  92. title: '直播up老师',
  93. des: '达到开通直播权限标准并开通直播功能'
  94. },
  95. {
  96. icon: 'music_active.png',
  97. title: '乐谱歌单老师',
  98. des: '上传您制作的乐谱并通过审核'
  99. }
  100. ]
  101. return (
  102. <>
  103. <div class={styles.headerContent}>
  104. <div class={styles.headerCount}>
  105. <div class={styles.teacherContent}>
  106. <div
  107. class={styles.teacherIcon}
  108. onClick={() => {
  109. // 判断是否在直播中
  110. if (this.userInfo.liveing === 1) {
  111. postMessage({
  112. api: 'joinLiveRoom',
  113. content: {
  114. roomId: this.userInfo.roomUid,
  115. teacherId: this.userInfo.userId
  116. }
  117. })
  118. }
  119. }}
  120. >
  121. {/* iy */}
  122. <Image
  123. class={[
  124. styles.avatar,
  125. (this.checkBadge('SVIP') || this.checkBadge('VIP')) &&
  126. styles.avatarActive
  127. ]}
  128. round
  129. src={this.userInfo.heardUrl || iconTeacher}
  130. fit="cover"
  131. />
  132. {this.userInfo.liveing === 1 && (
  133. <p class={styles.liveTag}>直播中</p>
  134. )}
  135. {(this.checkBadge('SVIP') || this.checkBadge('VIP')) && (
  136. <Image
  137. class={styles.teacherIconVip}
  138. src={
  139. this.checkBadge('SVIP')
  140. ? getAssetsHomeFile('svip_active.png')
  141. : this.checkBadge('VIP')
  142. ? getAssetsHomeFile('vip_active.png')
  143. : ''
  144. }
  145. />
  146. )}
  147. </div>
  148. <div class={styles.teacherInfo}>
  149. <div class={styles.teacherInfoName}>
  150. {this.userInfo.username ||
  151. `游客${this.userInfo.userId || ''}`}
  152. </div>
  153. {/* {this.userInfo.degreeFlag ? <img src={IconXueli} /> : null}
  154. {this.userInfo.teacherFlag ? <img src={IconJiaozi} /> : null} */}
  155. </div>
  156. </div>
  157. <div class={styles.teacherHonor}>
  158. <div>勋章:</div>
  159. <div class={styles.teacherIcons} onClick={this.openTeacherIcon}>
  160. <Image
  161. class={styles.iconOther}
  162. src={
  163. this.checkBadge('STYLE')
  164. ? getAssetsHomeFile('cert_active.png')
  165. : getAssetsHomeFile('cert_default.png')
  166. }
  167. />
  168. <Image
  169. class={styles.iconOther}
  170. src={
  171. this.checkBadge('VIDEO')
  172. ? getAssetsHomeFile('video_active.png')
  173. : getAssetsHomeFile('video_default.png')
  174. }
  175. />
  176. <Image
  177. class={styles.iconOther}
  178. src={
  179. this.checkBadge('LIVE')
  180. ? getAssetsHomeFile('live_active.png')
  181. : getAssetsHomeFile('live_default.png')
  182. }
  183. />
  184. <Image
  185. class={styles.iconOther}
  186. src={
  187. this.checkBadge('MUSIC')
  188. ? getAssetsHomeFile('music_active.png')
  189. : getAssetsHomeFile('music_default.png')
  190. }
  191. />
  192. </div>
  193. {/* <div class={styles.score}>评分:</div>
  194. <div class={styles.level}>
  195. {this.starGrade ? (
  196. <Rate
  197. readonly
  198. modelValue={this.starGrade}
  199. iconPrefix="iconfont"
  200. color="#FFC459"
  201. void-icon="star_default"
  202. icon="star_active"
  203. size={15}
  204. />
  205. ) : (
  206. <span style={{ fontSize: '12px', color: '#999999' }}>
  207. 暂无评分
  208. </span>
  209. )}
  210. </div> */}
  211. </div>
  212. <div class={styles.piNameSubject}>
  213. <Image
  214. class={styles.subjectSection}
  215. src={getAssetsHomeFile('icon_subject.png')}
  216. fit="contain"
  217. />
  218. <div class={styles.subjectList}>
  219. {this.subjectNameList.map((item: any) => (
  220. <span class={styles.subject}>{item}</span>
  221. ))}
  222. </div>
  223. </div>
  224. <div class={styles['teacher-bottom']}>
  225. <div class={styles['teacher-data']}>
  226. <div class={styles['teacher-data_item']}>
  227. 粉丝 <span>{this.userInfo.fansNum || 0}</span>
  228. </div>
  229. <div class={styles['teacher-data_item']}>
  230. 已上课时 <span>{this.userInfo.expTime || 0}</span>
  231. </div>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. <Popup class={styles['teaherPopup']} v-model:show={this.iconShow}>
  237. <Image src={getAssetsHomeFile('teacher-icon.png')} />
  238. <div class={styles.teacherIconWrap}>
  239. {iconList.map(n => {
  240. return (
  241. <div class={styles.teacherIconItem}>
  242. <div class={styles.teacherIconItemTop}>
  243. <Image src={getAssetsHomeFile(n.icon)} />
  244. <div class={styles.teacherIconTitle}>{n.title}</div>
  245. </div>
  246. <div class={styles.teacherIconDes}>{n.des}</div>
  247. </div>
  248. )
  249. })}
  250. </div>
  251. <Image
  252. onClick={() => (this.iconShow = false)}
  253. class={styles.closeIcon}
  254. src={getAssetsHomeFile('icon-close.png')}
  255. />
  256. </Popup>
  257. </>
  258. )
  259. }
  260. })