points.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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 { Icon, Collapse, CollapseItem } from 'vant';
  23. import { useRoute } from 'vue-router';
  24. export default defineComponent({
  25. name: 'points',
  26. props: {
  27. allList: {
  28. type: Array as any,
  29. default: () => []
  30. },
  31. kjId: {
  32. // 课件id
  33. type: String,
  34. default: ''
  35. },
  36. zsdId: {
  37. // 知识点id
  38. type: String,
  39. default: ''
  40. },
  41. currentCourse: {
  42. // 当前的课件
  43. type: Object,
  44. default: {}
  45. },
  46. popShow: {
  47. type: Boolean,
  48. default: false
  49. },
  50. data: {
  51. type: Array as PropType<any[]>,
  52. default: () => []
  53. },
  54. itemActive: {
  55. type: String,
  56. default: ''
  57. },
  58. itemName: {
  59. // 章节名称
  60. type: String,
  61. default: ''
  62. }
  63. },
  64. emits: ['handleSelect', 'courseSelect'],
  65. setup(props, { emit }) {
  66. const route = useRoute();
  67. // 类型(VIDEO,IMG,SONG,PPT,MUSIC,LISTEN:听音,RHYTHM:节奏,THEORY:乐理知识,MUSIC_WIKI:名曲鉴赏 INSTRUMENT:乐器 MUSICIAN:音乐家),可用值:VIDEO,MUSIC,IMG,SONG,PPT,LISTEN,RHYTHM,THEORY,MUSIC_WIKI,INSTRUMENT,MUSICIAN
  68. const types: { [_: string]: string } = {
  69. SONG: '音频',
  70. VIDEO: '视频',
  71. IMG: '图片',
  72. MUSIC: '乐谱',
  73. PPT: 'PPT',
  74. LISTEN: '听音',
  75. RHYTHM: '节奏',
  76. THEORY: '乐理',
  77. MUSIC_WIKI: '名曲',
  78. INSTRUMENT: '乐器',
  79. MUSICIAN: '音乐家'
  80. };
  81. const imgTypes: { [_: string]: string } = {
  82. SONG: audioIcon,
  83. VIDEO: vedioIcon,
  84. IMG: imgIcon,
  85. MUSIC: songIcon,
  86. PPT: pptIcon,
  87. LISTEN: otherIcon,
  88. RHYTHM: otherIcon,
  89. THEORY: otherIcon,
  90. MUSIC_WIKI: otherIcon,
  91. INSTRUMENT: otherIcon,
  92. MUSICIAN: otherIcon
  93. };
  94. // 获取对应图片
  95. const getImage = (item: any) => {
  96. if (item.type === 'VIDEO') {
  97. return props.itemActive == item.id ? iconVideoActive : iconVideo;
  98. } else if (['IMAGE', 'IMG'].includes(item.type)) {
  99. return props.itemActive == item.id ? iconImageActive : iconImage;
  100. } else if (item.type === 'SONG') {
  101. return props.itemActive == item.id ? iconSongActive : iconSong;
  102. } else {
  103. return props.itemActive == item.id ? iconVideoActive : iconVideo;
  104. }
  105. };
  106. const pointData = reactive({
  107. allList: props.allList, // 章节下的所有课件
  108. kjId: props.kjId, // 当前选中的课件id
  109. zsdId: props.zsdId, // 当前选中的知识点id
  110. currentCourse: props.currentCourse as any // 当前课件
  111. });
  112. watch(
  113. () => props.allList,
  114. () => {
  115. pointData.kjId = props.kjId;
  116. pointData.zsdId = props.zsdId;
  117. }
  118. );
  119. watch(
  120. () => props.popShow,
  121. () => {
  122. console.log('刷新123', props.allList, props.currentCourse);
  123. pointData.currentCourse = props.currentCourse;
  124. pointData.kjId = props.kjId;
  125. pointData.zsdId = props.zsdId;
  126. pointData.allList = props.allList;
  127. }
  128. );
  129. return () => (
  130. <div class={styles.container}>
  131. <div class={styles.pointHead}>
  132. <img src={iconMulv} />
  133. {props.itemName}
  134. </div>
  135. <div class={styles.kjColumn}>
  136. <div class={styles.kjLeft}>
  137. <img src={titleIcon} />
  138. <span>{pointData.currentCourse?.name}</span>
  139. </div>
  140. {pointData.allList?.length > 1 && (
  141. <img
  142. class={styles.kjRight}
  143. src={moreIcon}
  144. onClick={() => {
  145. console.log(pointData.allList);
  146. emit('courseSelect');
  147. }}
  148. />
  149. )}
  150. </div>
  151. <div class={styles.content}>
  152. <Collapse
  153. class={styles.collapse}
  154. modelValue={pointData.zsdId}
  155. onUpdate:modelValue={(val: any) => {
  156. pointData.zsdId = val;
  157. }}
  158. border={false}
  159. accordion>
  160. {pointData.currentCourse?.knowledgeList?.map((know: any) => (
  161. <CollapseItem
  162. center
  163. class={[
  164. styles.collapseItem,
  165. styles.collapseKnow,
  166. pointData.zsdId === know.id ? styles.activeItem2 : ''
  167. ]}
  168. border={false}
  169. isLink={false}
  170. title={know.name}
  171. titleClass={'van-ellipsis'}
  172. titleStyle={{ width: '80%' }}
  173. name={know.id}>
  174. {{
  175. default: () => (
  176. <>
  177. {know.materialInfo.map((material: any, index: number) => {
  178. return (
  179. <div
  180. class={[
  181. styles.matItem,
  182. props.itemActive == material.id
  183. ? styles.itemActive
  184. : ''
  185. ]}
  186. onClick={() => {
  187. console.log(pointData.allList);
  188. emit('handleSelect', {
  189. itemActive: material.id,
  190. zsdId: know.id,
  191. kjId: pointData.currentCourse?.id
  192. });
  193. }}>
  194. {material.paymentType === 'VIP' && (
  195. <span
  196. class={[
  197. styles.iconPayment,
  198. styles[material.paymentType]
  199. ]}>
  200. VIP
  201. </span>
  202. )}
  203. <div class={styles.cover}>
  204. <img src={material.url} />
  205. </div>
  206. <div class={styles.title}>
  207. {/* <div class={styles.tag}>{types[material.type]}</div> */}
  208. <img
  209. class={styles.typeImg}
  210. src={imgTypes[material.type]}
  211. />
  212. <div class={styles.tName}>{material.name}</div>
  213. </div>
  214. </div>
  215. );
  216. })}
  217. </>
  218. ),
  219. icon: () => (
  220. <img
  221. class={styles.arrow}
  222. src={
  223. pointData.zsdId === know.id
  224. ? chapterDown
  225. : chapterDefault
  226. }
  227. />
  228. )
  229. }}
  230. </CollapseItem>
  231. ))}
  232. </Collapse>
  233. {/* {props.allList.length &&
  234. <Collapse
  235. class={styles.collapse}
  236. modelValue={pointData.kjId}
  237. onUpdate:modelValue={(val: any) => {
  238. pointData.kjId = val;
  239. }}
  240. border={false}
  241. accordion>
  242. {props.allList.map((item: any) => (
  243. <CollapseItem
  244. class={[
  245. styles.collapseItem,
  246. pointData.kjId === item.id ? styles.activeItem : ''
  247. ]}
  248. border={false}
  249. isLink={false}
  250. title={item.name}
  251. titleStyle={{ width: '80%' }}
  252. name={item.id}>
  253. {{
  254. default: () => (
  255. <>
  256. <Collapse
  257. class={styles.collapse}
  258. modelValue={pointData.zsdId}
  259. onUpdate:modelValue={(val: any) => {
  260. pointData.zsdId = val;
  261. }}
  262. border={false}
  263. accordion>
  264. {item.knowledgeList.map((know: any) => (
  265. <CollapseItem
  266. center
  267. class={[
  268. styles.collapseItem,
  269. styles.collapseKnow,
  270. pointData.zsdId === know.id ? styles.activeItem2 : ''
  271. ]}
  272. border={false}
  273. isLink={false}
  274. title={know.name}
  275. titleClass={'van-ellipsis'}
  276. titleStyle={{ width: '80%' }}
  277. name={know.id}>
  278. {{
  279. default: () => (
  280. <>
  281. {know.materialInfo.map((material: any, index: number) => {
  282. return (
  283. <div
  284. class={[
  285. styles.matItem,
  286. props.itemActive == material.id ? styles.itemActive : ''
  287. ]}
  288. onClick={() => {
  289. console.log(pointData.allList)
  290. emit('handleSelect', {
  291. itemActive: material.id,
  292. zsdId: know.id,
  293. kjId: item.id
  294. });
  295. }}>
  296. <div class={styles.cover}>
  297. <img src={material.url} />
  298. </div>
  299. <div class={styles.title}>
  300. <div class={styles.tag}>{types[material.type]}</div>
  301. <div class={styles.tName}>{material.name}</div>
  302. </div>
  303. </div>
  304. );
  305. })}
  306. </>
  307. ),
  308. icon: () => (
  309. <img
  310. class={styles.arrow}
  311. src={
  312. pointData.zsdId === know.id
  313. ? chapterDown
  314. : chapterDefault2
  315. }
  316. />
  317. )
  318. }}
  319. </CollapseItem>
  320. ))}
  321. </Collapse>
  322. </>
  323. ),
  324. icon: () => (
  325. <img
  326. class={[styles.arrow, styles.firstArrow]}
  327. src={
  328. pointData.kjId === item.id
  329. ? chapterDown
  330. : chapterDefault
  331. }
  332. />
  333. )
  334. }}
  335. </CollapseItem>
  336. ))}
  337. </Collapse>
  338. } */}
  339. {/* {props.data.map((item, index: number) => {
  340. return (
  341. <div
  342. class={[
  343. styles.item,
  344. props.itemActive == item.id ? styles.itemActive : ''
  345. ]}
  346. onClick={() => {
  347. emit('handleSelect', {
  348. itemActive: item.id
  349. });
  350. }}>
  351. <div class={styles.cover}>
  352. <img src={item.url} />
  353. </div>
  354. <div class={styles.title}>
  355. <div class={styles.tag}>{types[item.type]}</div>
  356. <div>{item.name}</div>
  357. </div>
  358. </div>
  359. );
  360. })} */}
  361. </div>
  362. </div>
  363. );
  364. }
  365. });