1
0

page.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React from 'react';
  2. import './index.less';
  3. import { Tabs } from 'antd-mobile';
  4. import Page from '@src/containers/Page';
  5. import Money from '../../../components/Money';
  6. import Button from '../../../components/Button';
  7. import { Course } from '../../../stores/course';
  8. import { Order } from '../../../stores/order';
  9. export default class extends Page {
  10. initState() {
  11. return { tab: 'serviceContent' };
  12. }
  13. initData() {
  14. const { id } = this.params;
  15. Course.get(id).then(result => {
  16. this.setState({ data: result });
  17. });
  18. }
  19. buy() {
  20. Order.speedPay({ productType: 'course', productId: this.params.id, number: 1 });
  21. }
  22. renderView() {
  23. const { data = {}, tab } = this.state;
  24. return (
  25. <div>
  26. <div className="b-g" style={{ backgroundImage: `url(${data.cover})` }}>
  27. <div className="title">{data.title}</div>
  28. </div>
  29. {/* <div className="tip">访问{UserUrl}/course/detail/{data.id},试听该课程</div> */}
  30. <div className="detail">
  31. <Tabs
  32. page={tab}
  33. tabs={[
  34. { title: '服务介绍', key: 'serviceContent' },
  35. { title: '适合人群呢', key: 'crowdContent' },
  36. { title: '授课流程', key: 'processContent' },
  37. { title: 'FAQs', key: 'faq' },
  38. { title: '用户评价', key: 'comment' },
  39. ]}
  40. onChange={(value) => {
  41. this.setState({ tab: value.key });
  42. }}
  43. />
  44. <div dangerouslySetInnerHTML={{ __html: data[tab] }} />
  45. </div>
  46. <div className="fixed">
  47. <div className="fee">
  48. 总额: <Money value={data.price} size="lager" />
  49. </div>
  50. <Button width={110} className="f-r" radius onClick={() => {
  51. this.buy();
  52. }}>
  53. 立即购买
  54. </Button>
  55. </div>
  56. </div>
  57. );
  58. }
  59. }