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


class Content extends Component {
    constructor() {
        super();
        this.state = {
            loading: false,
            component: <div></div>,
        };
    }
    componentWillMount () {
        if (window.location.hash) {
            this.getKey(window.location.hash.substr(1));
        } else {
            this.getKey("myService");
        };
    }
    getKey (key) {
        switch (key) {
            case 'membership':
                require.ensure([], () => {
                    const Membership = require('./memberOrderList').default;
                    this.setState({
                        component: <Membership />
                    });
                });
                break;
            case 'consult':
                require.ensure([], () => {
                    const Consult = require('./consultOrderList').default;
                    this.setState({
                        component: <Consult />
                    });
                });
                break;
            case 'userAchievementOrder':
                require.ensure([], () => {
                    const AchievementOrder = require('../achievement/achievementOrder').default;
                    this.setState({
                        component: <AchievementOrder
                            data-listApiUrl='/api/admin/portal/order/userAchievementOrderList'
                            data-detailApiUrl='/api/admin/achievement/userDetail' />
                    });
                });
                break;
            case 'orgAchievementOrder':
                require.ensure([], () => {
                    const AchievementOrder = require('../achievement/achievementOrder').default;
                    this.setState({
                        component: <AchievementOrder
                            data-listApiUrl='/api/admin/portal/order/orgAchievementOrderList'
                            data-detailApiUrl='/api/admin/achievement/orgDetail' />
                    });
                });
                break;
            //订单新增空白
            //我的订单
            case 'myService': //科技服务订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'myActivity': //活动报名订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'myMember': //会员服务订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'myAchievement': //科技成果交易订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'myDemand': //科技需求交易订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'myExpert': //科技专家约见订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break; 
            //订单管理
            case 'serviceManage': //科技服务订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'activityManage': //活动报名订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'memberManage': //会员服务订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'achievementManage': //科技成果交易订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'demandManage': //科技需求交易订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'expertManage': //科技专家约见订单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break; 
            //合同单管理    
            case 'myContract': //我的合同单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'contractQuery': //合同单查询
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'contractManage': //合同单管理
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            //项目单管理
            case 'myProject': //我的项目单
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'projectQuery': //项目单查询
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'projectManage': //项目单管理
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            //结算订单管理
            case 'mySettlement': //我的结算订单	 
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'settlementQuery': //结算订单查询
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'settlementManage': //结算订单管理
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            //结算流水管理
            case 'myBill': //我的结算流水	 
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'BillQuery': //结算流水查询
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
                break;
            case 'BillManage': //结算流水管理
                require.ensure([], () => {
                    const Module = require('../module').default;
                    this.setState({
                        component: <Module />,
                    });
                });
            	break;
        };
        window.location.hash = key;
    }
    render () {
        return (
            <div className="manage-content">
                <LeftTab handlekey={this.getKey.bind(this)} />
                <div className="content-right">
                    {this.state.component}
                </div>
            </div>
        )
    }
}

export default Content;
