index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. /**
  8. * @description: 视频详情
  9. * @param {type} headUrl 头像
  10. * @param {type} username 姓名
  11. * @param {type} startTime 开始时间
  12. * @param {type} buyNum 购买用户数
  13. * @param {type} lessonPrice 价格
  14. * @param {type} lessonCoverUrl 视频封面
  15. * @param {type} lessonDesc 课程描述
  16. * @param {type} lessonNum 课程数
  17. * @param {type} lessonName 课程名称
  18. */
  19. interface UserType {
  20. headUrl: string
  21. username: string
  22. startTime?: string
  23. id?: number
  24. buyNum?: number
  25. lessonPrice: number
  26. lessonNum?: number
  27. lessonDesc?: string
  28. lessonCoverUrl: string
  29. lessonName: string
  30. auditVersion: number
  31. }
  32. export default defineComponent({
  33. name: 'user-detail',
  34. props: {
  35. userInfo: {
  36. type: Object as PropType<UserType>,
  37. required: true
  38. },
  39. showType: {
  40. type: String as PropType<'BUY' | 'TIME'>,
  41. default: 'BUY'
  42. },
  43. showBuy: {
  44. type: Boolean,
  45. default: true
  46. },
  47. border: {
  48. type: Boolean,
  49. default: false
  50. }
  51. },
  52. render() {
  53. return (
  54. <div class={styles.userDetail}>
  55. <Image
  56. class={[styles.banner]}
  57. src={this.userInfo.lessonCoverUrl}
  58. fit="cover"
  59. />
  60. <CellGroup class={styles.userInfo} border={this.border}>
  61. <Cell
  62. title={this.userInfo.lessonName}
  63. titleClass={styles.userTitle}
  64. v-slots={{
  65. label: () =>
  66. this.userInfo.startTime && (
  67. <span
  68. style={{
  69. display: 'flex',
  70. alignItems: 'center',
  71. fontSize: '13px',
  72. paddingTop: 'var(--van-cell-label-margin-top)'
  73. }}
  74. >
  75. <Icon
  76. name={iconTimer}
  77. size="16"
  78. style={{ marginRight: '5px' }}
  79. />
  80. 开课时间:
  81. {this.userInfo.startTime}
  82. </span>
  83. )
  84. }}
  85. />
  86. <Cell
  87. v-slots={{
  88. icon: () => (
  89. <Image
  90. class={styles.avatar}
  91. src={this.userInfo.headUrl || defaultIcon}
  92. fit="cover"
  93. />
  94. ),
  95. title: () => (
  96. <div class={styles.name}>
  97. <div class={styles.username}>
  98. {this.userInfo.username || `游客${this.userInfo.id || ''}`}
  99. </div>
  100. {this.showType === 'TIME' ? (
  101. <Tag
  102. style={{ marginLeft: '8px' }}
  103. color="#FFF1DE"
  104. textColor="#FF9300"
  105. >
  106. {this.userInfo.lessonNum}课时
  107. </Tag>
  108. ) : (
  109. this.showBuy && (
  110. <div class={styles.buyNum}>
  111. {this.userInfo.buyNum}人已购买
  112. </div>
  113. )
  114. )}
  115. </div>
  116. ),
  117. value: () =>
  118. this.showType === 'TIME' ? (
  119. <div class={styles.buyNumInfo}>
  120. <Icon name={iconUserNum} size={14} class={styles.iconBuy} />{' '}
  121. 已购 {this.userInfo.buyNum} 人
  122. </div>
  123. ) : (
  124. <div class={styles.info}>
  125. {/* 0元不显示,为了处理ios审核问题 */}
  126. {this.userInfo.lessonPrice > 0 && (
  127. <>¥{this.userInfo.lessonPrice}/</>
  128. )}
  129. {this.userInfo.lessonPrice <= 0 &&
  130. this.userInfo.auditVersion && <>¥{0}/</>}
  131. {this.userInfo.lessonPrice <= 0 &&
  132. !this.userInfo.auditVersion && <>免费/</>}
  133. {this.userInfo.lessonNum}课时
  134. </div>
  135. )
  136. }}
  137. ></Cell>
  138. </CellGroup>
  139. </div>
  140. )
  141. }
  142. })