content.jsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. case "recommendMessage":
  34. require.ensure([], () => {
  35. const JitaoMessage = require("./messagePush/jitaoMessage")
  36. .default;
  37. this.setState({
  38. component: <JitaoMessage />,
  39. });
  40. });
  41. break;
  42. case "systemMessage":
  43. require.ensure([], () => {
  44. const SystemMessage = require("./messagePush/systemMessage")
  45. .default;
  46. this.setState({
  47. component: <SystemMessage />,
  48. });
  49. });
  50. break;
  51. //订单新增空白
  52. case "personnelAll":
  53. require.ensure([], () => {
  54. const PersonnelAll = require("./personnel/personnelAll").default;
  55. this.setState({
  56. component: <PersonnelAll ApiUrl={""} />,
  57. });
  58. });
  59. break;
  60. default:
  61. require.ensure([], () => {
  62. const Module = require("../module").default;
  63. this.setState({
  64. component: <Module />,
  65. });
  66. });
  67. };
  68. window.location.hash = key;
  69. }
  70. render () {
  71. return (
  72. <div className="manage-content">
  73. <LeftTab handlekey={this.getKey.bind(this)} />
  74. <div className="content-right">
  75. {this.state.component}
  76. </div>
  77. </div>
  78. )
  79. }
  80. }
  81. export default Content;