index.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import { Cell, CellGroup, Icon, Image, Tag } from 'vant'
  2. import { defineComponent, PropType } from 'vue'
  3. import styles from './index.module.less'
  4. import iconUserNum from '@common/images/icon_user_num.png'
  5. import defaultIcon from '@common/images/icon_teacher.png'
  6. import iconTimer from '@common/images/icon_timer2.png'
  7. import IconXueli from '@common/images/icon-xueli.png'
  8. import IconJiaozi from '@common/images/icon-jiaozi.png'
  9. /**
  10. * @description: 视频详情
  11. * @param {type} headUrl 头像
  12. * @param {type} username 姓名
  13. * @param {type} startTime 开始时间
  14. * @param {type} buyNum 购买用户数
  15. * @param {type} lessonPrice 价格
  16. * @param {type} lessonCoverUrl 视频封面
  17. * @param {type} lessonDesc 课程描述
  18. * @param {type} lessonNum 课程数
  19. * @param {type} lessonName 课程名称
  20. * @param {type} relationType 赠送类型
  21. */
  22. interface UserType {
  23. headUrl: string
  24. username: string
  25. startTime?: string
  26. id?: number
  27. buyNum?: number
  28. lessonPrice: number
  29. lessonNum?: number
  30. lessonDesc?: string
  31. lessonCoverUrl: string
  32. lessonName: string
  33. auditVersion: number
  34. relationType?: string
  35. }
  36. export default defineComponent({
  37. name: 'user-detail',
  38. props: {
  39. userInfo: {
  40. type: Object as PropType<UserType>,
  41. required: true
  42. },
  43. showType: {
  44. type: String as PropType<'BUY' | 'TIME'>,
  45. default: 'BUY'
  46. },
  47. showBuy: {
  48. type: Boolean,
  49. default: true
  50. },
  51. border: {
  52. type: Boolean,
  53. default: false
  54. },
  55. onUserDetail: {
  56. // 点击用户头像等信息
  57. type: Function,
  58. default: (item: any) => {}
  59. }
  60. },
  61. render() {
  62. return (
  63. <div class={styles.userDetail}>
  64. <Image
  65. class={[styles.banner]}
  66. src={this.userInfo.lessonCoverUrl}
  67. fit="cover"
  68. />
  69. <CellGroup class={styles.userInfo} border={this.border}>
  70. <Cell
  71. title={this.userInfo.lessonName}
  72. titleClass={styles.userTitle}
  73. v-slots={{
  74. label: () =>
  75. this.userInfo.startTime && (
  76. <span
  77. style={{
  78. display: 'flex',
  79. alignItems: 'center',
  80. fontSize: '13px',
  81. paddingTop: 'var(--van-cell-label-margin-top)'
  82. }}
  83. >
  84. <Icon
  85. name={iconTimer}
  86. size="16"
  87. style={{ marginRight: '5px' }}
  88. />
  89. 开课时间:
  90. {this.userInfo.startTime}
  91. </span>
  92. )
  93. }}
  94. />
  95. <Cell
  96. v-slots={{
  97. icon: () => (
  98. <Image
  99. class={styles.avatar}
  100. src={this.userInfo.headUrl || defaultIcon}
  101. fit="cover"
  102. />
  103. ),
  104. title: () => (
  105. <div
  106. class={styles.name}
  107. onClick={() => {
  108. this.onUserDetail(this.userInfo)
  109. }}
  110. >
  111. <div class={styles.username}>
  112. {this.userInfo.username || `游客${this.userInfo.id || ''}`}
  113. <div>
  114. {(this.userInfo as any).isDegree && (
  115. <img class={styles.iconTeacher} src={IconXueli} />
  116. )}
  117. {(this.userInfo as any).isTeacher && (
  118. <img class={styles.iconTeacher} src={IconJiaozi} />
  119. )}
  120. </div>
  121. </div>
  122. </div>
  123. ),
  124. value: () => (
  125. <div class={styles.info}>
  126. {/* 0元不显示,为了处理ios审核问题 */}
  127. {this.userInfo.lessonPrice > 0 && (
  128. <>¥{this.userInfo.lessonPrice}</>
  129. )}
  130. {this.userInfo.lessonPrice <= 0 &&
  131. this.userInfo.auditVersion !== 0 && <>¥{0}</>}
  132. {this.userInfo.lessonPrice <= 0 &&
  133. this.userInfo.auditVersion === 0 && <>免费</>}
  134. <span
  135. style={{ color: '#999', fontSize: '14px', fontWeight: 400 }}
  136. >
  137. /{this.userInfo.lessonNum}课时
  138. </span>
  139. {this.showBuy && (
  140. <div class={styles.buyNum}>
  141. {this.userInfo.buyNum}人已
  142. {this.userInfo.lessonPrice <= 0 &&
  143. this.userInfo.auditVersion === 0
  144. ? '领取'
  145. : '购买'}
  146. </div>
  147. )}
  148. </div>
  149. )
  150. }}
  151. ></Cell>
  152. {this.userInfo.relationType === 'GIFT' && (
  153. <Cell
  154. class={styles.buyTips}
  155. value={'注:购买本课程即可赠送相关曲目或专辑终生使用权限~'}
  156. ></Cell>
  157. )}
  158. </CellGroup>
  159. </div>
  160. )
  161. }
  162. })