page.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import React from 'react';
  2. import './index.less';
  3. import Page from '@src/containers/Page';
  4. import { getMap } from '@src/services/Tools';
  5. import Money from '../../../components/Money';
  6. import Button from '../../../components/Button';
  7. import Tag from '../../../components/Tag';
  8. // import Avatar from '../../../components/Avatar';
  9. import { Course } from '../../../stores/course';
  10. import { Order } from '../../../stores/order';
  11. import { ServiceKey, ServiceParamMap } from '../../../../Constant';
  12. export default class extends Page {
  13. init() { }
  14. initData() {
  15. const { id } = this.params;
  16. Course.getPackage(id).then(result => {
  17. result.originPrice = result.courses.reduce((x, y) => x + y, 0);
  18. this.setState({ data: result });
  19. });
  20. }
  21. buy() {
  22. Order.speedPay({ productType: 'course_package', productId: this.params.id })
  23. .then((result) => {
  24. linkTo(`/pay/${result.id}`);
  25. });
  26. }
  27. renderView() {
  28. const { data = {} } = this.state;
  29. return (
  30. <div>
  31. <div className="title">{data.title}</div>
  32. <div className="tags">{data.isNovice > 0 && <Tag size="small">适合新手</Tag>}</div>
  33. <div className="detail-title">授课老师</div>
  34. <div className="name">
  35. {/* <Avatar name="scan1" /> */}
  36. {(data.courses || []).map(row => {
  37. return <span>{row.teacher}</span>;
  38. })}
  39. </div>
  40. <div className="detail-title">课程介绍</div>
  41. <div className="desc">{data.description}</div>
  42. <div className="detail-title">包含课程</div>
  43. <div className="detail-tags">
  44. {(data.courses || []).map(row => {
  45. return (
  46. <Tag theme="border">
  47. {row.title}({row.noNumber}课时)
  48. </Tag>
  49. );
  50. })}
  51. </div>
  52. <div className="detail-title">配套服务</div>
  53. <div className="detail-tags">
  54. <Tag theme="border">预习作业</Tag>
  55. <Tag theme="border">课后答疑</Tag>
  56. </div>
  57. <div className="detail-title">赠送服务</div>
  58. <div className="detail-tags">
  59. {data.gift &&
  60. ServiceKey.map(row => {
  61. if (!data.gift[row.value]) return null;
  62. const list = ServiceParamMap[row.value];
  63. if (list) {
  64. const map = getMap(list, 'value', 'label');
  65. return (
  66. <Tag theme="border">
  67. {row.label}×{map[data.gift[row.value]]}
  68. </Tag>
  69. );
  70. }
  71. return (
  72. <Tag theme="border">
  73. {row.label}×{data.gift[row.value]}
  74. </Tag>
  75. );
  76. })}
  77. </div>
  78. <div className="fixed">
  79. <div className="fee">
  80. <div className="o-m">
  81. 原价: <Money value={data.originPrice} disabled />
  82. </div>
  83. <div className="t-m">
  84. 套餐价: <Money value={data.price} size="lager" />
  85. </div>
  86. </div>
  87. <Button
  88. width={110}
  89. className="f-r"
  90. radius
  91. onClick={() => {
  92. this.buy();
  93. }}
  94. >
  95. 立即购买
  96. </Button>
  97. </div>
  98. </div>
  99. );
  100. }
  101. }