content.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from './leftTab';
  4. class Content extends Component {
  5. constructor() {
  6. super();
  7. this.state = {
  8. loading: false,
  9. component: 'div'
  10. };
  11. }
  12. componentWillMount () {
  13. if (window.location.hash) {
  14. this.getKey(window.location.hash.substr(1));
  15. } else {
  16. this.getKey("normal");
  17. };
  18. }
  19. getKey (key) {
  20. switch (key) {
  21. case 'normal':
  22. require.ensure([], () => {
  23. // $("body").css("zoom", "0.8");
  24. // document.body.style.zoom = "0.8"
  25. const Normal = require('./normal').default;
  26. this.setState({
  27. component: Normal
  28. });
  29. });
  30. break;
  31. case 'collection':
  32. require.ensure([], () => {
  33. const Collection = require('./collection').default;
  34. this.setState({
  35. component: Collection
  36. });
  37. });
  38. break;
  39. case 'techList':
  40. require.ensure([], () => {
  41. const TechList = require('./techList').default;
  42. this.setState({
  43. component: TechList
  44. });
  45. });
  46. break;
  47. case 'serviceList':
  48. require.ensure([], () => {
  49. const ServiceList = require('./serviceList').default;
  50. this.setState({
  51. component: ServiceList
  52. });
  53. });
  54. break;
  55. case 'consultList':
  56. require.ensure([], () => {
  57. const ConsultList = require('./consultList').default;
  58. this.setState({
  59. component: ConsultList
  60. });
  61. });
  62. break;
  63. };
  64. window.location.hash = key;
  65. }
  66. render () {
  67. return (
  68. <div className="acc-content">
  69. <LeftTab handlekey={this.getKey.bind(this)} />
  70. <div className="content-right">
  71. <this.state.component />
  72. </div>
  73. </div>
  74. )
  75. }
  76. }
  77. export default Content;