index.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. },
  56. render() {
  57. return (
  58. <div class={styles.userDetail}>
  59. <Image
  60. class={[styles.banner]}
  61. src={this.userInfo.lessonCoverUrl}
  62. fit="cover"
  63. />
  64. <CellGroup class={styles.userInfo} border={this.border}>
  65. <Cell
  66. title={this.userInfo.lessonName}
  67. titleClass={styles.userTitle}
  68. v-slots={{
  69. label: () =>
  70. this.userInfo.startTime && (
  71. <span
  72. style={{
  73. display: 'flex',
  74. alignItems: 'center',
  75. fontSize: '13px',
  76. paddingTop: 'var(--van-cell-label-margin-top)'
  77. }}
  78. >
  79. <Icon
  80. name={iconTimer}
  81. size="16"
  82. style={{ marginRight: '5px' }}
  83. />
  84. 开课时间:
  85. {this.userInfo.startTime}
  86. </span>
  87. )
  88. }}
  89. />
  90. <Cell
  91. v-slots={{
  92. icon: () => (
  93. <Image
  94. class={styles.avatar}
  95. src={this.userInfo.headUrl || defaultIcon}
  96. fit="cover"
  97. />
  98. ),
  99. title: () => (
  100. <div class={styles.name}>
  101. <div class={styles.username}>
  102. {this.userInfo.username || `游客${this.userInfo.id || ''}`}
  103. <div>
  104. {(this.userInfo as any).isDegree && (
  105. <img class={styles.iconTeacher} src={IconXueli} />
  106. )}
  107. {(this.userInfo as any).isTeacher && (
  108. <img class={styles.iconTeacher} src={IconJiaozi} />
  109. )}
  110. </div>
  111. </div>
  112. </div>
  113. ),
  114. value: () => (
  115. <div class={styles.info}>
  116. {/* 0元不显示,为了处理ios审核问题 */}
  117. {this.userInfo.lessonPrice > 0 && (
  118. <>¥{this.userInfo.lessonPrice}</>
  119. )}
  120. {this.userInfo.lessonPrice <= 0 &&
  121. this.userInfo.auditVersion !== 0 && <>¥{0}</>}
  122. {this.userInfo.lessonPrice <= 0 &&
  123. this.userInfo.auditVersion === 0 && <>免费</>}
  124. <span
  125. style={{ color: '#999', fontSize: '14px', fontWeight: 400 }}
  126. >
  127. /{this.userInfo.lessonNum}课时
  128. </span>
  129. {this.showBuy && (
  130. <div class={styles.buyNum}>
  131. {this.userInfo.buyNum}人已
  132. {this.userInfo.lessonPrice <= 0 &&
  133. this.userInfo.auditVersion === 0
  134. ? '领取'
  135. : '购买'}
  136. </div>
  137. )}
  138. </div>
  139. )
  140. }}
  141. ></Cell>
  142. {this.userInfo.relationType === 'GIFT' && (
  143. <Cell
  144. class={styles.buyTips}
  145. value={'注:购买本课程即可购买相关曲目或专辑终生使用权限~'}
  146. ></Cell>
  147. )}
  148. </CellGroup>
  149. </div>
  150. )
  151. }
  152. })