page.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.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. const item = data.package[index] || {};
  35. return (
  36. <div>
  37. <div className="b-g" style={{ backgroundImage: `url(${data.image})` }}>
  38. <div className="title">{item.title}</div>
  39. </div>
  40. <div className="detail">
  41. {data.package.length > 1 && <div className="title">可选套餐</div>}
  42. {data.package.length > 1 && <SpecialRadioGroup list={data.package} value={index} onChange={(value) => this.setState({ index: value })} />}
  43. {data.package.length > 1 && <div className="division" />}
  44. <div className="title">服务介绍</div>
  45. <h2>服务</h2>
  46. <p>{item.description} {item.expire_info}</p>
  47. <h2>退款政策</h2>
  48. <p>{item.refund_policy}</p>
  49. <h2>版权说明</h2>
  50. <p>{item.copyright_nnotes}</p>
  51. </div>
  52. <div className="fixed">
  53. <div className="fee">
  54. 总额: <Money value={item.price} size="lager" />
  55. </div>
  56. <Button width={110} className="f-r" radius onClick={() => {
  57. this.buy();
  58. }}>
  59. 立即购买
  60. </Button>
  61. </div>
  62. </div>
  63. );
  64. }
  65. }