content.jsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React, { Component } from "react";
  2. import "../content.less";
  3. import "./content.less";
  4. import LeftTab from "../leftTab";
  5. import { getMenu } from "../publicMenu.js";
  6. class Content extends Component {
  7. constructor() {
  8. super();
  9. this.state = {
  10. loading: false,
  11. component: <div></div>,
  12. };
  13. }
  14. componentWillMount() {
  15. var ids = window.location.href.indexOf("rid=");
  16. var idk = window.location.href.substr(ids + 4);
  17. var rid = idk.split("#");
  18. let menu = getMenu(rid);
  19. let curry;
  20. if (menu[0].subMenus.length > 0) {
  21. curry = menu[0].subMenus[0].url.split("#");
  22. } else {
  23. curry = menu[0].url.split("#");
  24. }
  25. if (window.location.hash) {
  26. this.getKey(window.location.hash.substr(1));
  27. } else {
  28. this.getKey(curry[1]);
  29. }
  30. }
  31. getKey(key) {
  32. switch (key) {
  33. // 资金池
  34. case "fundpool":
  35. require.ensure([], () => {
  36. const Fundpool = require("./amibapage").default;
  37. this.setState({
  38. component: <Fundpool />,
  39. });
  40. });
  41. break;
  42. //我的投资
  43. case "myinvestment":
  44. require.ensure([], () => {
  45. let MyInvestment = require("../financialManage/amiba/investment").default;
  46. this.setState({
  47. component: <MyInvestment type="my" />,
  48. });
  49. });
  50. break;
  51. // 资金管理
  52. case "fundmanagement":
  53. require.ensure([], () => {
  54. const FundManagement = require("./amibapage/fundmanagement").default;
  55. this.setState({
  56. component: <FundManagement />,
  57. });
  58. });
  59. break;
  60. //空白
  61. default:
  62. require.ensure([], () => {
  63. const Module = require("../module").default;
  64. this.setState({
  65. component: <Module />,
  66. });
  67. });
  68. }
  69. window.location.hash = key;
  70. }
  71. render() {
  72. return (
  73. <div className="manage-content">
  74. <LeftTab handlekey={this.getKey.bind(this)} />
  75. <div className="content-right">{this.state.component}</div>
  76. </div>
  77. );
  78. }
  79. }
  80. export default Content;