content.jsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 'membership':
  34. require.ensure([], () => {
  35. const Membership = require('./memberOrderList').default;
  36. this.setState({
  37. component: <Membership />
  38. });
  39. });
  40. break;
  41. case 'consult':
  42. require.ensure([], () => {
  43. const Consult = require('./consultOrderList').default;
  44. this.setState({
  45. component: <Consult />
  46. });
  47. });
  48. break;
  49. case 'userAchievementOrder':
  50. require.ensure([], () => {
  51. const AchievementOrder = require('../achievement/achievementOrder').default;
  52. this.setState({
  53. component: <AchievementOrder
  54. data-listApiUrl='/api/admin/portal/order/userAchievementOrderList'
  55. data-detailApiUrl='/api/admin/achievement/userDetail' />
  56. });
  57. });
  58. break;
  59. case 'orgAchievementOrder':
  60. require.ensure([], () => {
  61. const AchievementOrder = require('../achievement/achievementOrder').default;
  62. this.setState({
  63. component: <AchievementOrder
  64. data-listApiUrl='/api/admin/portal/order/orgAchievementOrderList'
  65. data-detailApiUrl='/api/admin/achievement/orgDetail' />
  66. });
  67. });
  68. break;
  69. //订单新增空白
  70. default:
  71. require.ensure([], () => {
  72. const Module = require('../module').default;
  73. this.setState({
  74. component:<Module />
  75. });
  76. });
  77. };
  78. window.location.hash = key;
  79. }
  80. render () {
  81. return (
  82. <div className="manage-content">
  83. <LeftTab handlekey={this.getKey.bind(this)} />
  84. <div className="content-right">
  85. {this.state.component}
  86. </div>
  87. </div>
  88. )
  89. }
  90. }
  91. export default Content;