page.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import React from 'react';
  2. import './index.less';
  3. import { Anchor } from 'antd';
  4. import { Tabs } from 'antd-mobile';
  5. import Page from '@src/containers/Page';
  6. import Assets from '@src/components/Assets';
  7. import { getMap } from '@src/services/Tools';
  8. import Money from '../../../components/Money';
  9. import { LinkBlock, CourseBlock, DataBlock } from '../../../components/Block';
  10. import { Main } from '../../../stores/main';
  11. import { Course } from '../../../stores/course';
  12. import { ServiceKey, CourseVsType } from '../../../../Constant';
  13. export default class extends Page {
  14. init() {
  15. this.courseVsMap = {};
  16. }
  17. initData() {
  18. Promise.all(ServiceKey.map(service => {
  19. return Main.getService(service.value).then(result => {
  20. this.setState({ [service.value]: result });
  21. });
  22. }));
  23. Course.allVs().then(list => {
  24. this.courseVsMap = getMap(list, 'vsType');
  25. this.setState({ vsList: list });
  26. });
  27. Course.listVideo({ page: 1, size: 4, order: 'saleNumber', direction: 'desc' })
  28. .then(result => {
  29. this.setState({ courseTop: result.list });
  30. });
  31. Course.listData({ page: 1, size: 4, order: 'saleNumber', direction: 'desc' })
  32. .then((result) => {
  33. this.setState({ dataTop: result.list });
  34. });
  35. }
  36. renderView() {
  37. const { courseTop = [], dataTop = [] } = this.state;
  38. return [<Anchor>
  39. <Tabs
  40. tabs={[
  41. { title: '服务', key: 'service' },
  42. { title: '1V1私教', key: 'vs' },
  43. { title: '在线课程', key: 'video' },
  44. { title: '资料', key: 'data' },
  45. ]}
  46. renderTab={(tab) => {
  47. return <Anchor.Link href={`#${tab.key}`} title={tab.title} />;
  48. }}
  49. />
  50. </Anchor>, <div className="list">
  51. <div className="body">
  52. <a name="service" />
  53. <div className="title">服务</div>
  54. <div className="service">
  55. {ServiceKey.map(service => {
  56. const s = this.state[service.value] || {};
  57. const money = s.package ? s.package[0].price : 0;
  58. return <div className="service-item" onClick={() => {
  59. linkTo(`/product/service/${service.value}`);
  60. }}>
  61. <div className="service-item-t">{service.label}</div>
  62. <Money size="small" value={money} />
  63. <Assets name={service.value} />
  64. </div>;
  65. })}
  66. </div>
  67. <a name="vs" />
  68. <div className="title">1V1私教</div>
  69. <Assets name="banner" className="banner" />
  70. {CourseVsType.map((t, index) => {
  71. const course = this.courseVsMap[t.value] || {};
  72. return <LinkBlock title={course.title} sub={course.comment} theme={index % 2 > 0 ? 'not' : 'default'} onClick={() => {
  73. linkTo(`/product/course/vs/${course.id}`);
  74. }} />;
  75. })}
  76. {/* <LinkBlock title="新手辅导" sub="GMAT 全面了解,定制学习计划" />
  77. <LinkBlock title="诊断辅导" sub="复习效果不理想,制定突破计划" theme="not" />
  78. <LinkBlock title="系统授课" sub="全面知识体系讲解,提升实战能力" />
  79. <LinkBlock title="答疑课" sub="一对一解答疑问,破解所有疑团" theme="not" /> */}
  80. <a name="video" />
  81. <div className="title">在线课程</div>
  82. <Assets name="banner" className="banner" />
  83. {courseTop.map(row => {
  84. return <CourseBlock data={row} />;
  85. })}
  86. <div className="more t-r m-b-2" onClick={() => {
  87. linkTo('/product/course/video');
  88. }} >全部课程 ></div>
  89. <a name="data" />
  90. <div className="title">资料</div>
  91. <Assets name="banner" className="banner" />
  92. {dataTop.map(row => {
  93. return <DataBlock data={row} />;
  94. })}
  95. <div className="more t-r m-b-2" onClick={() => {
  96. linkTo('/product/data');
  97. }}>全部资料 ></div>
  98. </div>
  99. </div>,
  100. ];
  101. }
  102. }