import React, { Component } from 'react';
import '../content.less';
import LeftTab from './leftTab';

class Content extends Component {
    constructor() {
        super();
        this.state = {
            loading: false,
            component: 'div'
        };
    }
    componentWillMount () {
        if (window.location.hash) {
            this.getKey(window.location.hash.substr(1));
        } else {
            this.getKey("normal");
        };
    }
    getKey (key) {
        switch (key) {
            case 'normal':
                require.ensure([], () => {
                    // $("body").css("zoom", "0.8");
                    // document.body.style.zoom = "0.8"
                    const Normal = require('./normal').default;
                    this.setState({
                        component: Normal
                    });
                });
                break;
            case 'collection':
                require.ensure([], () => {
                    const Collection = require('./collection').default;
                    this.setState({
                        component: Collection
                    });
                });
                break;
            case 'techList':
                require.ensure([], () => {
                    const TechList = require('./techList').default;
                    this.setState({
                        component: TechList
                    });
                });
                break;
            case 'serviceList':
                require.ensure([], () => {
                    const ServiceList = require('./serviceList').default;
                    this.setState({
                        component: ServiceList
                    });
                });
                break;
            case 'consultList':
                require.ensure([], () => {
                    const ConsultList = require('./consultList').default;
                    this.setState({
                        component: ConsultList
                    });
                });
                break;
        };
        window.location.hash = key;
    }
    render () {
        return (
            <div className="acc-content">
                <LeftTab handlekey={this.getKey.bind(this)} />
                <div className="content-right">
                    <this.state.component />
                </div>
            </div>
        )
    }
}

export default Content;
