content.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from '../leftTab';
  4. import {getMenu} from '../publicMenu.js'
  5. class Content extends Component {
  6. constructor() {
  7. super();
  8. this.state = {
  9. loading: false,
  10. component: <div></div>,
  11. };
  12. }
  13. componentWillMount() {
  14. var ids=window.location.href.indexOf('rid=');
  15. var idk=window.location.href.substr(ids+4);
  16. var rid=idk.split('#');
  17. let menu=getMenu(rid);
  18. let curry;
  19. if(menu[0].subMenus.length>0){
  20. curry=menu[0].subMenus[0].url.split('#');
  21. }else{
  22. curry=menu[0].url.split('#');
  23. };
  24. if (window.location.hash) {
  25. this.getKey(window.location.hash.substr(1));
  26. } else {
  27. this.getKey(curry[1]);
  28. };
  29. }
  30. getKey(key) {
  31. switch (key) {
  32. //客服订单查询
  33. case "order":
  34. require.ensure([], () => {
  35. const Order = require("./administration/order")
  36. .default;
  37. this.setState({
  38. component: <Order/>
  39. });
  40. });
  41. break;
  42. //客服订单详情查询
  43. case "followUp":
  44. require.ensure([], () => {
  45. const FollowUp = require("./administration/FollowUp")
  46. .default;
  47. this.setState({
  48. component: <FollowUp/>
  49. });
  50. });
  51. break;
  52. default:
  53. require.ensure([], () => {
  54. const Module = require("../module").default;
  55. this.setState({
  56. component: <Module ApiUrl={""} />
  57. });
  58. });
  59. };
  60. window.location.hash = key;
  61. }
  62. render() {
  63. return (
  64. <div className="manage-content">
  65. <LeftTab handlekey={this.getKey.bind(this)} />
  66. <div className="content-right">
  67. {this.state.component}
  68. </div>
  69. </div>
  70. )
  71. }
  72. }
  73. export default Content;