page.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. import React from 'react';
  2. import { Link } from 'react-router-dom';
  3. import './index.less';
  4. import Page from '@src/containers/Page';
  5. import Assets from '@src/components/Assets';
  6. import { getMap, formatPercent, formatDate } from '@src/services/Tools';
  7. import Footer from '../../../components/Footer';
  8. import { FaqModal, CommentModal, FinishModal, CourseNoteModal, AskCourseModal } from '../../../components/OtherModal';
  9. import { Contact, AnswerCarousel, Comment } from '../../../components/Other';
  10. import Tabs from '../../../components/Tabs';
  11. import { Icon as GIcon } from '../../../components/Icon';
  12. import Button from '../../../components/Button';
  13. import IconButton from '../../../components/IconButton';
  14. import UserTable from '../../../components/UserTable';
  15. import ProgressText from '../../../components/ProgressText';
  16. import { OpenText } from '../../../components/Open';
  17. import Video from '../../../components/Video';
  18. import { Main } from '../../../stores/main';
  19. import { Course } from '../../../stores/course';
  20. import { User } from '../../../stores/user';
  21. import { Order } from '../../../stores/order';
  22. import { Question } from '../../../stores/question';
  23. import { My } from '../../../stores/my';
  24. import { QrCodeAssets } from '../../../../Constant';
  25. export default class extends Page {
  26. initState() {
  27. this.columns = [
  28. {
  29. title: '学习内容',
  30. key: 'title',
  31. render: (text, record) => {
  32. const { no } = this.state;
  33. if (no === record.no) {
  34. // 当前正在
  35. }
  36. return `课时 ${record.no}: ${text}`;
  37. },
  38. },
  39. {
  40. title: '预习作业',
  41. key: 'paper',
  42. render: (text, record) => {
  43. const { paper = {} } = record;
  44. const progress = paper.report ? formatPercent(paper.report.userNumber, paper.report.questionNumber) : 0;
  45. const times = paper.paper ? paper.paper.resetTimes : 0;
  46. return (
  47. <div>
  48. <div className="v-a-m d-i-b">
  49. <ProgressText width={50} size="small" times={times} progress={progress} unit="次" />
  50. </div>
  51. {!paper.report && (
  52. <IconButton
  53. className="m-l-2"
  54. type="start"
  55. tip="Start"
  56. onClick={() => {
  57. User.needLogin().then(() => {
  58. Question.startLink('preview', paper);
  59. });
  60. }}
  61. />
  62. )}
  63. {paper.report && !paper.report.isFinish && (
  64. <IconButton
  65. className="m-l-2"
  66. type="continue"
  67. tip="Continue"
  68. onClick={() => {
  69. User.needLogin().then(() => {
  70. Question.continueLink('preview', paper);
  71. });
  72. }}
  73. />
  74. )}
  75. {paper.report && (
  76. <IconButton
  77. className="m-l-2"
  78. type="restart"
  79. tip="Restart"
  80. onClick={() => {
  81. User.needLogin().then(() => {
  82. Question.restart(paper.paper.id)
  83. .then(() => {
  84. this.refreshPaper();
  85. });
  86. });
  87. }}
  88. />
  89. )}
  90. {paper.report && !!paper.report.isFinish && (
  91. <IconButton
  92. className="m-l-5"
  93. type="report"
  94. tip="Report"
  95. onClick={() => {
  96. User.needLogin().then(() => {
  97. Question.reportLink(paper);
  98. });
  99. }}
  100. />
  101. )}
  102. </div>
  103. );
  104. },
  105. },
  106. {
  107. title: '进度',
  108. key: 'progress',
  109. render: (text, record) => {
  110. const { progress } = record;
  111. return `${progress && progress.times > 0 ? `${progress.times}次+` : ''}${
  112. progress ? `${progress.progress}%` : '0%'}`;
  113. },
  114. },
  115. {
  116. title: '最近学习',
  117. key: 'lastTime',
  118. render: (text, rr) => {
  119. const { record } = rr;
  120. return record && formatDate(record.createTime, 'YYYY-MM-DD HH:mm:ss');
  121. },
  122. },
  123. {
  124. title: '笔记',
  125. key: 'note',
  126. render: (text, record) => {
  127. return <GIcon name="note" active={record.note} onClick={() => {
  128. this.setState({ showNote: true, note: this.noteMap ? this.noteMap[record.id] || { courseNoId: record.id } : { courseNoId: record.id } });
  129. }} />;
  130. },
  131. },
  132. {
  133. title: '问答',
  134. key: 'ask',
  135. render: (text, record) => {
  136. return (
  137. <Link to={`/course/answer/${record.courseId}?tab=my&courseNoId=${record.id}`}>{`${record.answerNumber ||
  138. 0}/${record.askNumber || 0}`}</Link>
  139. );
  140. },
  141. },
  142. ];
  143. return {
  144. tab: '1',
  145. rightTab: '1',
  146. key: '1',
  147. add: false,
  148. list: [{ key: '1' }, { key: '2' }, { key: '3' }],
  149. data: {},
  150. position: 0,
  151. };
  152. }
  153. init() {
  154. this.time = 0;
  155. Main.dataStruct().then(result => {
  156. const dataStructSelect = result.map(row => {
  157. return {
  158. title: `${row.titleZh}${row.titleEn}`,
  159. key: row.id,
  160. };
  161. });
  162. const dataStructMap = getMap(dataStructSelect, 'key');
  163. this.setState({ dataStructSelect, dataStructMap });
  164. });
  165. Main.getBase().then(result => {
  166. this.setState({ base: result });
  167. });
  168. }
  169. outPage() {
  170. const { item } = this.state;
  171. this.updateProgress(item.id, this.lastSecond, item.time);
  172. }
  173. formatRecord(row) {
  174. row.paperMap = {};
  175. if (row.papers) {
  176. row.papers.forEach(paper => {
  177. if (paper.courseNo) row.paperMap[paper.courseNo] = paper;
  178. });
  179. }
  180. row.progressMap = {};
  181. if (row.progress) {
  182. row.progress.forEach(progress => {
  183. row.progressMap[progress.courseNoId] = progress;
  184. });
  185. }
  186. row.recordMap = {};
  187. if (row.records) {
  188. row.records.forEach(record => {
  189. row.recordMap[record.courseNoId] = record;
  190. });
  191. }
  192. row.courseNoMap = {};
  193. row.courseTime = 0;
  194. if (row.courseNos) {
  195. row.courseNos.forEach(no => {
  196. row.courseNoMap[no.id] = no;
  197. row.courseTime += no.time;
  198. no.paper = row.paperMap[no.no];
  199. no.progress = row.progressMap[no.id];
  200. no.record = row.recordMap[no.id];
  201. });
  202. }
  203. if (row.currentNo) {
  204. row.currentCourseNo = row.courseNoMap[row.currentNo];
  205. } else {
  206. row.currentNo = 0;
  207. }
  208. return row;
  209. }
  210. initData() {
  211. const { id } = this.params;
  212. Course.detail(id).then(result => {
  213. result = this.formatRecord(result);
  214. // result.have = true;
  215. // result.waters = ['高*', '152****4895'];
  216. this.setState({ data: result });
  217. // 选择课时
  218. if (this.state.search.no) {
  219. this.onChangeItem(Number(this.state.search.no));
  220. } else {
  221. this.onChangeItem(1);
  222. }
  223. if (!result.have) {
  224. Course.trailView(id);
  225. }
  226. this.refreshNote();
  227. });
  228. Main.listComment({ page: 1, size: 100, channel: 'course-video', position: id }).then(result => {
  229. this.comments = result.list;
  230. this.setState({ comments: result.list });
  231. });
  232. Main.listFaq({ page: 1, size: 100, channel: 'course-video', position: id }).then(result => {
  233. this.faqs = result.list;
  234. this.setState({ faqs: result.list });
  235. });
  236. }
  237. refreshAsk(position) {
  238. const { id } = this.params;
  239. const { item = {} } = this.state;
  240. Course.listAsk(Object.assign({ page: 1, size: 1000, courseId: id, courseNoId: item.id, position })).then(result => {
  241. this.setState({ asks: result.list });
  242. });
  243. }
  244. refreshNote() {
  245. const { id } = this.params;
  246. const { data } = this.state;
  247. if (!data.have) return;
  248. My.listCourseNote({ courseId: id, page: 1, size: data.courseNos.length })
  249. .then((result) => {
  250. this.noteMap = getMap(result.list, 'courseNoId');
  251. data.courseNos.forEach((row) => {
  252. const note = this.noteMap[row.id];
  253. if (note) row.note = true;
  254. });
  255. this.setState({ data });
  256. });
  257. }
  258. refreshPaper() {
  259. const { id } = this.params;
  260. const { data } = this.state;
  261. if (!data.have) return;
  262. My.listCoursePaper({ courseId: id, page: 1, size: data.courseNos.length })
  263. .then((result) => {
  264. data.papers = result.list;
  265. this.formatRecord(data);
  266. this.setState({ data });
  267. });
  268. }
  269. onChangeRightTab(rightTab) {
  270. this.setState({ rightTab });
  271. }
  272. onChangeTab(tab) {
  273. this.setState({ tab });
  274. }
  275. onChangeItem(key) {
  276. key = Number(key);
  277. this.changeQuery({ no: key });
  278. this.setState({ no: key });
  279. const { data, item } = this.state;
  280. const index = key - 1;
  281. const timelineSelect = [];
  282. const current = data.courseNos[index];
  283. if (current) {
  284. const max = current.time / 60;
  285. let start = 0;
  286. let end = start + 5;
  287. while (start < max) {
  288. timelineSelect.push({
  289. title: `${start} - ${end}min`,
  290. key: `${start}`,
  291. });
  292. start += 5;
  293. end = start + 5;
  294. // end = Math.min(start + 5, max);
  295. }
  296. }
  297. // 切换播放,记录进度
  298. if (item) {
  299. this.updateProgress(item.id, this.lastSecond, item.time, true);
  300. }
  301. this.setState({ item: current, timelineSelect });
  302. }
  303. onTimeUpdate(second) {
  304. const { position, item = {}, data } = this.state;
  305. if (!data.have) {
  306. // 如果是试用,则按秒数增加
  307. second += (item.startTrail || 0) * 60;
  308. }
  309. const minute = parseInt(second / 60, 10);
  310. const nowPosition = parseInt(minute / 5, 10) * 5;
  311. if (nowPosition !== position) {
  312. this.refreshAsk(position);
  313. this.setState({ position: nowPosition });
  314. // 定时更新进度
  315. this.updateProgress(item.id, second, item.time);
  316. }
  317. this.lastSecond = second;
  318. this.showWater(second);
  319. }
  320. playVideo(second) {
  321. // 开始计时
  322. this.lastTime = new Date();
  323. this.showWater(second);
  324. }
  325. pauseVideo(second) {
  326. const { item } = this.state;
  327. this.updateProgress(item.id, second, item.time);
  328. // 停止计时
  329. this.lastTime = null;
  330. this.showWater(second);
  331. }
  332. showWater(second, extend) {
  333. const { data, water = {} } = this.state;
  334. let { waters = [] } = data;
  335. waters = waters || [];
  336. if (!this.lastTime && water.show) {
  337. water.show = false;
  338. second -= 1;
  339. water.transition = '';
  340. } else if (!water.show) {
  341. water.show = true;
  342. water.transition = 'transform 1s linear 0s';
  343. }
  344. if (water.show) {
  345. water.opacity = 1;
  346. } else {
  347. water.opacity = 0;
  348. }
  349. if (extend) {
  350. Object.assign(water, extend);
  351. }
  352. const time = 15;
  353. const stop = 0;
  354. const times = (second / (time + stop));
  355. const index = parseInt(times % waters.length, 10);
  356. const current = (second % (time + stop));
  357. water.style = [2, 0, 2, 1][parseInt((times % 4), 10)] + 1;
  358. water.text = waters[[0, 1][index]];
  359. // console.log(water.show, current, current / 4, (current / 4) % 2);
  360. if (water.show) {
  361. water.opacity = (current / 4) % 2 > 1 ? 0 : 1;
  362. }
  363. // if (water.style % 2) {
  364. // water.transform = `translateX(${current * 100 / time}%)`;
  365. // } else {
  366. water.transform = `translateX(${100 - ((current - stop / 2) * 100 / time)}%)`;
  367. // }
  368. this.setState({ water });
  369. }
  370. onChangeProgress(second) {
  371. this.showWater(second - 1, this.lastTime ? { transition: '', opacity: 0 } : { transition: '', opacity: 0 });
  372. setTimeout(() => {
  373. this.showWater(second, this.lastTime ? { transition: 'transform 1s linear 0s', opacity: 1 } : { transition: '', opacity: 0 });
  374. }, 1);
  375. }
  376. next() {
  377. const { data, item } = this.state;
  378. if (data.courseNos.length === item.no) {
  379. return;
  380. }
  381. this.onChangeItem(item.no + 1);
  382. }
  383. onVideoAction(key) {
  384. const { rightTab, showTab, showAsk, showNote, item = {}, position } = this.state;
  385. switch (key) {
  386. case 'ask':
  387. return this.setState({ showAsk: !showAsk, ask: { position: `${position}` } });
  388. case 'note':
  389. return this.setState({ showNote: !showNote, note: this.noteMap ? this.noteMap[item.id] || { courseNoId: item.id } : { courseNoId: item.id } });
  390. case 'answer':
  391. return this.setState({ showTab: rightTab === '1' ? !showTab : true, rightTab: '1' });
  392. case 'list':
  393. return this.setState({ showTab: rightTab === '2' ? !showTab : true, rightTab: '2' });
  394. default:
  395. return '';
  396. }
  397. }
  398. updateProgress(courseNoId, currentTime, totalTime, record) {
  399. if (!this.lastTime) return;
  400. const { id } = this.params;
  401. const now = new Date();
  402. this.time += (now.getTime() - this.lastTime.getTime()) / 1000;
  403. this.lastTime = now;
  404. const progress = formatPercent(currentTime, totalTime);
  405. if (record || this.time > 300 || progress === 100) {
  406. // 最长5分钟记录一次
  407. Course.noProgress(id, courseNoId, progress, this.time, courseNoId);
  408. this.time = 0;
  409. } else {
  410. Course.noProgress(id, courseNoId, progress, null, null);
  411. }
  412. }
  413. buy() {
  414. const { data } = this.state;
  415. User.needLogin().then(() => {
  416. Order.speedPay({ productType: 'course', productId: data.id }).then(result => {
  417. User.needPay(result).then(() => {
  418. this.refresh();
  419. });
  420. });
  421. });
  422. }
  423. add() {
  424. const { data } = this.state;
  425. User.needLogin().then(() => {
  426. Order.addCheckout({ productType: 'course', productId: data.id }).then(() => {
  427. this.setState({ add: true });
  428. });
  429. });
  430. }
  431. viewAsk(id) {
  432. Course.askView(id);
  433. }
  434. setVideo(video) {
  435. this.video = video;
  436. }
  437. renderView() {
  438. const { base = {}, data = {}, item = {}, add, rightTab, showTab, showAsk, showNote, dataStructMap = {}, showComment, comment = {}, showFaq, faq = {}, showFinish, note = {}, ask = {}, timelineSelect = [], water = {} } = this.state;
  439. const { courseNos = [] } = data;
  440. const { paper = {} } = item;
  441. return (
  442. <div>
  443. <div className="top content t-8">
  444. <Link to="/course">千行课堂</Link> > <Link to="/course/online?tab=single">全部课程</Link> > {data.parentStructId > 0 ? <Link to={`/course/online?tab=single&parentStructId=${(dataStructMap[data.parentStructId] || {}).key}`}>{(dataStructMap[data.parentStructId] || {}).title}</Link> : null}{data.parentStructId > 0 ? '> ' : ''}
  445. <Link to={`/course/online?tab=single&parentStructId=${(dataStructMap[data.parentStructId] || {}).key}&structId=${(dataStructMap[data.structId] || {}).key}`}>{(dataStructMap[data.structId] || {}).title}</Link> > <Link to={`/course/detail/${data.id}`}>{data.title}</Link> > <span className="t-1">课程详情</span>
  446. </div>
  447. <div className="center content">
  448. <div className="t-1 t-s-20">
  449. {data.title}
  450. <div className="action f-r">
  451. {!data.have && <Button className="m-r-1" radius size="lager" onClick={() => this.buy()}>
  452. 立即购买
  453. </Button>}
  454. {!data.have && <Button theme="default" radius size="lager" disabled={data.add || add} onClick={() => this.add()}>
  455. <Assets name={data.add || add ? 'add_disabled' : 'add'} />
  456. </Button>}
  457. {data.have && <Button className="m-r-1" radius size="lager" onClick={() => linkTo('/my/course')}>
  458. 我的课程
  459. </Button>}
  460. </div>
  461. </div>
  462. <div className="t-2 m-b-1">授课老师:{data.teacher}</div>
  463. <div className={'detail'}>
  464. <div className="left">
  465. {data.have && paper.id && <div hidden={(paper.paper && paper.paper.finishTimes > 0)} className="left-top">
  466. <span className="d-i-b m-r-1">预习作业</span>
  467. <span className="d-i-b m-r-2">
  468. <ProgressText width={480} size="small" progress={paper.report ? formatPercent(paper.report.userNumber, paper.report.questionNumber) : 0} />
  469. </span>
  470. <Button className="f-r" radius onClick={() => (paper.report ? Question.continueLink('preview', paper) : Question.startLink('preview', paper))}>
  471. 做题
  472. </Button>
  473. </div>}
  474. <div className="video-layout">
  475. {item.resource && <Video
  476. key={item.id}
  477. src={item.resource}
  478. width={750}
  479. height={467}
  480. ref={ref => this.setVideo(ref)}
  481. water={<div key={water.style} className={`video-water style-${water.style}`} style={{ ...water }}>{water.text}</div>}
  482. btnList={[
  483. { title: '提问', key: 'ask', show: data.have, active: showAsk, pause: true },
  484. {
  485. key: 'answer',
  486. render(active) {
  487. return <Assets name={active ? 'question_on' : 'question_off'} />;
  488. },
  489. full: true,
  490. show: true,
  491. active: showTab && rightTab === '1',
  492. },
  493. { title: '笔记', key: 'note', show: data.have, active: showNote, pause: true },
  494. { title: '课表', key: 'list', show: true, full: true, active: showTab && rightTab === '2' },
  495. ]}
  496. onPlay={(second) => this.playVideo(second)}
  497. onPause={(second) => this.pauseVideo(second)}
  498. onChangeProgress={(second) => this.onChangeProgress(second)}
  499. onNext={() => this.next()}
  500. onAction={key => this.onVideoAction(key)}
  501. onTimeUpdate={time => this.onTimeUpdate(time)}
  502. onFullChange={() => this.setState({ showTab: true, rightTab: '1' })}
  503. >
  504. <div hidden={!showTab} className="video-fixed tab-warpper">
  505. <Tabs
  506. type="division"
  507. theme="gray"
  508. space={2.5}
  509. active={rightTab}
  510. tabs={[{ title: '精选问答', key: '1' }, { title: '课时列表', key: '2' }]}
  511. onChange={key => this.onChangeRightTab(key)}
  512. />
  513. <div className="tab-body">{this[`renderRightTab${rightTab}`]()}</div>
  514. </div>
  515. </Video>}
  516. </div>
  517. </div>
  518. <div className={`detail-right ${data.have && !(item.paper && item.paper.finishTimes > 0) ? 'have' : ''} tab-warpper`}>
  519. <Tabs
  520. type="division"
  521. theme="gray"
  522. space={2.5}
  523. active={rightTab}
  524. tabs={[{ title: '精选问答', key: '1' }, { title: '课时列表', key: '2' }]}
  525. onChange={key => this.onChangeRightTab(key)}
  526. />
  527. <div className="tab-body">{this[`renderRightTab${rightTab}`]()}</div>
  528. </div>
  529. </div>
  530. {data.have && <UserTable columns={this.columns} data={courseNos} />}
  531. </div>
  532. <div hidden={data.have} className="bottom">
  533. <div className="content">{this.renderTab()}</div>
  534. </div>
  535. <Contact data={base.contact} />
  536. <Footer />
  537. <AskCourseModal getContainer={() => (showTab ? document.getElementById(this.video.state.id) : document.body)} show={showAsk} defaultData={ask} course={data} courseNo={item} selectList={timelineSelect} onConfirm={() => this.setState({ showAsk: false })} onCancel={() => this.setState({ showAsk: false })} />
  538. <CourseNoteModal getContainer={() => (showTab ? document.getElementById(this.video.state.id) : document.body)} show={showNote} defaultData={note} course={data} courseNos={courseNos} noteMap={this.noteMap} onConfirm={() => {
  539. this.setState({ showNote: false });
  540. this.refreshNote();
  541. }} onCancel={() => this.setState({ showNote: false })} />
  542. <CommentModal
  543. show={showComment}
  544. defaultData={comment}
  545. onConfirm={() => this.setState({ showComment: false, commnet: {}, showFinish: true })}
  546. onCancel={() => this.setState({ showComment: false, commnet: {} })}
  547. onClose={() => this.setState({ showComment: false, commnet: {} })}
  548. />
  549. <FaqModal show={showFaq} defaultData={faq} onCancel={() => this.setState({ showFaq: false, faq: {} })} onConfirm={() => this.setState({ showFaq: false, faq: {}, showFinish: true })} />
  550. <FinishModal
  551. getContainer={() => document.getElementById(this.video.state.id)}
  552. show={showFinish}
  553. onConfirm={() => this.setState({ showFinish: false })}
  554. />
  555. </div >
  556. );
  557. }
  558. renderRightTab1() {
  559. const { asks = [], data = {}, position } = this.state;
  560. return [
  561. <div className="all-answer">
  562. <span className="d-i-b b m-r-5" />
  563. <span className="d-i-b t-6">{position}:00~{position + 5}:00</span>
  564. <a className="f-r d-i-b t-4 c-p" href={`/course/answer/${data.id}`} target="_blank">全部问答 ></a>
  565. </div>,
  566. <div className="answer-layout">
  567. {asks.map(item => {
  568. return (
  569. <div className="answer-item">
  570. <div>
  571. <div className="small-tag">提问</div>
  572. </div>
  573. <div className="desc">
  574. <OpenText>{item.content}</OpenText>
  575. </div>
  576. {item.answerStatus > 0 && (
  577. <div>
  578. <div className="small-tag">回答</div>
  579. </div>
  580. )}
  581. {item.answerStatus > 0 && (
  582. <div className="desc">
  583. <OpenText onOpen={() => this.viewAsk(item.id)}>{item.answer}</OpenText>
  584. </div>
  585. )}
  586. </div>
  587. );
  588. })}
  589. </div>,
  590. ];
  591. }
  592. renderRightTab2() {
  593. const { data = {}, no } = this.state;
  594. const { courseNos = [] } = data;
  595. return (
  596. <div className="item-layout">
  597. {courseNos.map(item => {
  598. return (
  599. <div className={`item ${item.no === no ? 'active' : ''}`} onClick={() => this.onChangeItem(item.no)}>
  600. <span className="t-1">课时{item.no}</span>
  601. <span className="t-2 p-l-1">{item.title}</span>
  602. </div>
  603. );
  604. })}
  605. </div>
  606. );
  607. }
  608. renderTab() {
  609. const { tab } = this.state;
  610. return [
  611. <div className="bottom">
  612. <div className="content">
  613. <Tabs
  614. type="full"
  615. border
  616. active={tab}
  617. tabs={[
  618. { title: '课程介绍', key: '1' },
  619. { title: '授课大纲', key: '2' },
  620. { title: '小助手', key: '3' },
  621. { title: 'FAQs', key: '4' },
  622. { title: '优惠信息', key: '5' },
  623. { title: '学员评价', key: '6' },
  624. ]}
  625. onChange={key => this.onChangeTab(key)}
  626. />
  627. {this[`renderTab${tab}`]()}
  628. </div>
  629. </div>,
  630. ];
  631. }
  632. renderTab1() {
  633. const { data = {} } = this.state;
  634. return (
  635. <div className="tab-layout">
  636. <div className="tab-title">老师资历</div>
  637. <div className="tab-desc" dangerouslySetInnerHTML={{ __html: data.teacherContent }} />
  638. <div className="tab-title">基本参数</div>
  639. <div className="tab-desc" dangerouslySetInnerHTML={{ __html: data.baseContent }} />
  640. <div className="tab-title">授课重点</div>
  641. <div className="tab-desc" dangerouslySetInnerHTML={{ __html: data.pointContent }} />
  642. <div className="tab-title">适合人群</div>
  643. <div className="tab-desc" dangerouslySetInnerHTML={{ __html: data.crowdContent }} />
  644. </div>
  645. );
  646. }
  647. renderTab2() {
  648. const { data } = this.state;
  649. return (
  650. <div className="tab-layout">
  651. <div className="tab-desc" dangerouslySetInnerHTML={{ __html: data.syllabusContent }} />
  652. </div>
  653. );
  654. }
  655. renderTab3() {
  656. return (
  657. <div className="tab-layout">
  658. <div className="qr-layout">
  659. <Assets name={QrCodeAssets} className="m-r-2 v-a-t" />
  660. <div className="p-l-1 d-i-b t-l">
  661. <div className="t-1">千行小助手:</div>
  662. <div className="t-1 m-b-2">1232104-310431</div>
  663. <div className="t-2 t-s-12">微信扫码添加千行小助手为好友,</div>
  664. <div className="t-2 t-s-12">咨询课程,了解更多信息</div>
  665. </div>
  666. </div>
  667. </div>
  668. );
  669. }
  670. renderTab4() {
  671. const { faqs, data = {} } = this.state;
  672. return (
  673. <div className="tab-layout">
  674. <AnswerCarousel
  675. hideBtn
  676. list={faqs}
  677. onFaq={() => User.needLogin().then(() => this.setState({ showFaq: true, faq: { channel: 'course-video', position: data.id } }))}
  678. />
  679. </div>
  680. );
  681. }
  682. renderTab5() {
  683. const { data = {} } = this.state;
  684. return (
  685. <div className="tab-layout">
  686. <div className="tab-desc" dangerouslySetInnerHTML={{ __html: data.promoteContent }} />
  687. </div>
  688. );
  689. }
  690. renderTab6() {
  691. const { data = {}, comments = [] } = this.state;
  692. return (
  693. <div className="tab-layout">
  694. {data.have && <div className="m-b-1 t-r">
  695. <Button width={100} radius onClick={() => User.needLogin().then(() => this.setState({ showComment: true, comment: { channel: 'course-video', position: data.id } }))}>
  696. 写评论
  697. </Button>
  698. </div>}
  699. {(comments || []).map(item => {
  700. return <Comment data={item} />;
  701. })}
  702. </div>
  703. );
  704. }
  705. }