page.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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).then(result => {
  17. result.package = (result.package || []).map((row, index) => {
  18. row.label = row.title;
  19. row.value = index;
  20. return row;
  21. });
  22. this.setState({ data: result });
  23. });
  24. }
  25. buy() {
  26. const { data, index } = this.state;
  27. const item = data.package[index] || {};
  28. console.log(item);
  29. }
  30. // expire_info: '',
  31. renderView() {
  32. const { data = {}, index } = this.state;
  33. const item = data.package[index] || {};
  34. return (
  35. <div>
  36. <div className="b-g" style={{ backgroundImage: `url(${data.image})` }}>
  37. <div className="title">{item.title}</div>
  38. </div>
  39. <div className="detail">
  40. {data.package.length > 1 && <div className="title">可选套餐</div>}
  41. {data.package.length > 1 && (
  42. <SpecialRadioGroup
  43. theme="theme"
  44. list={data.package}
  45. value={index}
  46. onChange={value => this.setState({ index: value })}
  47. />
  48. )}
  49. {data.package.length > 1 && <div className="division" />}
  50. <div className="title">服务介绍</div>
  51. <h2>服务</h2>
  52. <p>
  53. {item.description} {item.expire_info}
  54. </p>
  55. <h2>退款政策</h2>
  56. <p>{item.refund_policy}</p>
  57. <h2>版权说明</h2>
  58. <p>{item.copyright_nnotes}</p>
  59. </div>
  60. <div className="fixed">
  61. <div className="fee">
  62. 总额: <Money value={item.price} size="lager" />
  63. </div>
  64. <Button
  65. width={110}
  66. className="f-r"
  67. radius
  68. onClick={() => {
  69. this.buy();
  70. }}
  71. >
  72. 立即购买
  73. </Button>
  74. </div>
  75. </div>
  76. );
  77. }
  78. }