page.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import React from 'react';
  2. import './index.less';
  3. import Page from '@src/containers/Page';
  4. import Money from '../../../components/Money';
  5. import Button from '../../../components/Button';
  6. import { SpecialRadioGroup } from '../../../components/Radio';
  7. import { Main } from '../../../stores/main';
  8. export default class extends Page {
  9. initState() {
  10. return {
  11. index: 0,
  12. };
  13. }
  14. initData() {
  15. const { service } = this.params;
  16. Main.getService(service)
  17. .then(result => {
  18. result.package = (result.package || []).map((row, index) => {
  19. row.label = `¥${row.price}/${row.title}`;
  20. row.value = index;
  21. return row;
  22. });
  23. this.setState({ data: result });
  24. });
  25. }
  26. buy() {
  27. const { data, index } = this.state;
  28. const item = data.package[index] || {};
  29. console.log(item);
  30. }
  31. // expire_info: '',
  32. renderView() {
  33. const { data = {}, index } = this.state;
  34. data.package = data.package || [];
  35. const item = data.package[index] || {};
  36. return (
  37. <div>
  38. <div className="b-g" style={{ backgroundImage: `url(${data.image})` }}>
  39. <div className="title">{item.title}</div>
  40. </div>
  41. <div className="detail">
  42. {data.package.length > 1 && <div className="title">可选套餐</div>}
  43. {data.package.length > 1 && <SpecialRadioGroup list={data.package} value={index} onChange={(value) => this.setState({ index: value })} />}
  44. {data.package.length > 1 && <div className="division" />}
  45. <div className="title">服务介绍</div>
  46. <h3>服务</h3>
  47. <p>{item.description} {item.expire_info}</p>
  48. <h3>退款政策</h3>
  49. <p>{item.refund_policy}</p>
  50. <h3>版权说明</h3>
  51. <p>{item.copyright_nnotes}</p>
  52. </div>
  53. <div className="fixed">
  54. <div className="fee">
  55. 总额: <Money value={item.price} size="lager" />
  56. </div>
  57. <Button width={110} className="f-r" radius onClick={() => {
  58. this.buy();
  59. }}>
  60. 立即购买
  61. </Button>
  62. </div>
  63. </div>
  64. );
  65. }
  66. }