points.tsx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import { PropType, defineComponent, reactive, watch, onMounted } from 'vue';
  2. import styles from './point.module.less';
  3. import iconMulv from '../image/icon-mulv.svg';
  4. // import iconZhibo from '../image/icon-load.gif';
  5. // import iconImage from '../image/icon-image.svg';
  6. // import iconImageActive from '../image/icon-image-active.svg';
  7. // import iconVideo from '../image/icon-video.svg';
  8. // import iconVideoActive from '../image/icon-video-active.svg';
  9. // import iconSong from '../image/icon-song.svg';
  10. // import iconSongActive from '../image/icon-song-active.svg';
  11. import chapterDown from '../image/chapter-down-arrow.svg';
  12. import chapterDefault from '../image/chapter-default-arrow.svg';
  13. // import chapterDefault2 from '../image/chapter-default-arrow2.svg';
  14. // import moreIcon from '../image/zy_toggle_icon.png';
  15. // import titleIcon from '../image/zy_title_icon.png';
  16. import songIcon from '../image/song_icon.png';
  17. import audioIcon from '../image/zy_audio_icon.png';
  18. import vedioIcon from '../image/zy_vedio_icon.png';
  19. import pptIcon from '../image/zy_ppt_icon.png';
  20. import imgIcon from '../image/zy_img_icon.png';
  21. import otherIcon from '../image/zy_more_icon.png';
  22. import iconPlayDefault from '../image/icon-play-default.png';
  23. import iconSingDefault from '../image/icon-sing-default.png';
  24. import { Collapse, CollapseItem } from 'vant';
  25. export default defineComponent({
  26. name: 'points',
  27. props: {
  28. kjId: {
  29. // 课件id
  30. type: String,
  31. default: ''
  32. },
  33. zsdId: {
  34. // 知识点id
  35. type: String,
  36. default: ''
  37. },
  38. currentCourse: {
  39. // 当前的课件
  40. type: Object,
  41. default: {}
  42. },
  43. popShow: {
  44. type: Boolean,
  45. default: false
  46. },
  47. itemActive: {
  48. type: String,
  49. default: ''
  50. },
  51. itemName: {
  52. // 章节名称
  53. type: String,
  54. default: ''
  55. }
  56. },
  57. emits: ['handleSelect'],
  58. setup(props, { emit }) {
  59. // const route = useRoute();
  60. // 类型(VIDEO,IMG,SONG,PPT,MUSIC,LISTEN:听音,RHYTHM:节奏,THEORY:乐理知识,MUSIC_WIKI:名曲鉴赏 INSTRUMENT:乐器 MUSICIAN:音乐家),可用值:VIDEO,MUSIC,IMG,SONG,PPT,LISTEN,RHYTHM,THEORY,MUSIC_WIKI,INSTRUMENT,MUSICIAN
  61. // const types: { [_: string]: string } = {
  62. // SONG: '音频',
  63. // VIDEO: '视频',
  64. // IMG: '图片',
  65. // MUSIC: '乐谱',
  66. // PPT: 'PPT',
  67. // LISTEN: '听音',
  68. // RHYTHM: '节奏',
  69. // THEORY: '乐理',
  70. // MUSIC_WIKI: '名曲',
  71. // INSTRUMENT: '乐器',
  72. // MUSICIAN: '音乐家'
  73. // };
  74. const imgTypes: { [_: string]: string } = {
  75. SONG: audioIcon,
  76. VIDEO: vedioIcon,
  77. IMG: imgIcon,
  78. MUSIC: songIcon,
  79. PPT: pptIcon,
  80. LISTEN: otherIcon,
  81. RHYTHM: otherIcon,
  82. THEORY: otherIcon,
  83. MUSIC_WIKI: otherIcon,
  84. INSTRUMENT: otherIcon,
  85. MUSICIAN: otherIcon
  86. };
  87. // 获取对应图片
  88. // const getImage = (item: any) => {
  89. // if (item.type === 'VIDEO') {
  90. // return props.itemActive == item.id ? iconVideoActive : iconVideo;
  91. // } else if (['IMAGE', 'IMG'].includes(item.type)) {
  92. // return props.itemActive == item.id ? iconImageActive : iconImage;
  93. // } else if (item.type === 'SONG') {
  94. // return props.itemActive == item.id ? iconSongActive : iconSong;
  95. // } else {
  96. // return props.itemActive == item.id ? iconVideoActive : iconVideo;
  97. // }
  98. // };
  99. const pointData = reactive({
  100. kjId: props.kjId, // 当前选中的课件id
  101. zsdId: props.zsdId, // 当前选中的知识点id
  102. currentCourse: props.currentCourse as any // 当前课件
  103. });
  104. watch(
  105. () => props.popShow,
  106. () => {
  107. pointData.currentCourse = props.currentCourse;
  108. pointData.kjId = props.kjId;
  109. pointData.zsdId = props.zsdId;
  110. }
  111. );
  112. return () => (
  113. <div class={styles.container}>
  114. <div class={styles.pointHead}>
  115. <img src={iconMulv} />
  116. {props.itemName}
  117. </div>
  118. <div class={styles.content}>
  119. <Collapse
  120. class={styles.collapse}
  121. modelValue={pointData.zsdId}
  122. onUpdate:modelValue={(val: any) => {
  123. pointData.zsdId = val;
  124. }}
  125. border={false}
  126. accordion>
  127. {pointData.currentCourse?.knowledgeList?.map((know: any) => (
  128. <CollapseItem
  129. center
  130. class={[
  131. styles.collapseItem,
  132. styles.collapseKnow,
  133. pointData.zsdId === know.id ? styles.activeItem2 : ''
  134. ]}
  135. border={false}
  136. isLink={false}
  137. title={know.name}
  138. titleClass={'van-ellipsis'}
  139. titleStyle={{ width: '80%' }}
  140. name={know.id}>
  141. {{
  142. default: () =>
  143. know.materialInfo.map((material: any, index: number) => {
  144. return (
  145. <div
  146. key={material.id}
  147. class={[
  148. styles.matItem,
  149. props.itemActive == material.id
  150. ? styles.itemActive
  151. : ''
  152. ]}
  153. onClick={() => {
  154. emit('handleSelect', {
  155. itemActive: material.id,
  156. zsdId: know.id,
  157. kjId: pointData.currentCourse
  158. ?.coursewareDetailKnowledgeId
  159. });
  160. }}>
  161. {material.paymentType === 'VIP' && (
  162. <span
  163. class={[
  164. styles.iconPayment,
  165. styles[material.paymentType]
  166. ]}>
  167. VIP
  168. </span>
  169. )}
  170. <div class={styles.cover}>
  171. <img src={material.url} />
  172. <div class={styles.audioPlayTypeSection}>
  173. {material.audioPlayTypesArray.includes(
  174. 'SING'
  175. ) && (
  176. <img
  177. src={iconSingDefault}
  178. class={styles.iconPlay}
  179. />
  180. )}
  181. {material.audioPlayTypesArray.includes(
  182. 'PLAY'
  183. ) && (
  184. <img
  185. src={iconPlayDefault}
  186. class={styles.iconPlay}
  187. />
  188. )}
  189. </div>
  190. </div>
  191. <div class={styles.title}>
  192. <img
  193. class={styles.typeImg}
  194. src={imgTypes[material.type]}
  195. />
  196. <div class={styles.tName}>{material.name}</div>
  197. </div>
  198. </div>
  199. );
  200. }),
  201. icon: () => (
  202. <img
  203. class={styles.arrow}
  204. src={
  205. pointData.zsdId === know.id
  206. ? chapterDown
  207. : chapterDefault
  208. }
  209. />
  210. )
  211. }}
  212. </CollapseItem>
  213. ))}
  214. </Collapse>
  215. </div>
  216. </div>
  217. );
  218. }
  219. });