index.tsx 5.9 KB

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