import React from 'react';
import './portal.less';
// import ajax from 'jquery/src/ajax/xhr.js';
// import $ from 'jquery/src/ajax';
import $ from 'jquery';
import logoImg from '../../../image/logo-2.png';

function navHover () {
    $('.header_nav_detail .nav_content>li').hover(function () {
        $(this).siblings('.active').addClass('hideSub');
    }, function () {
        $(this).siblings('.active').removeClass('hideSub');
    })
}

const LoginTop = React.createClass({
    logOut () {
        $.ajax({
            method: "get",
            dataType: "json",
            url: globalConfig.context + "/login",
        }).done(function (data) {
            if (window.userData.mobile) {
                window.location.href = globalConfig.context + "/user/login.html"
            } else if (window.adminData.mobile) {
                window.location.href = globalConfig.context + "/admin/login.html"
            };
        });
    },
    componentDidMount () {
        navHover();
    },
    render () {
        return (
            <div className="portal-header">
                <div className="portal-top">
                    <div className="clearfix">
                        <div className="top-welcomeText">欢迎您来到科技认知计算交易平台-公测版</div>
                        <div className="top-alink">
                            <a href={globalConfig.context + "/portal/index.html"}>返回首页</a>
                            {window.userData.mobile || window.adminData.mobile ?
                                <span>
                                    {(() => {
                                        if (window.userData.mobile) {
                                            return <a href={globalConfig.context + "/user/account/index"}>尊敬的 {userData.nickname || userData.number}</a>
                                        } else if (window.adminData.mobile) {
                                            return <a href={globalConfig.context + "/admin/index"}>尊敬的 {adminData.name || adminData.mobile}</a>
                                        }
                                    })()}
                                    <a onClick={() => { this.logOut() }}>退出</a>
                                </span>
                                : <span>
                                    <a href={globalConfig.context + "/user/login.html"}>登录</a>
                                    <a href={globalConfig.context + "/user/signIn.html"}>注册</a>
                                </span>}
                            <a href="./index.html">帮助中心</a>
                        </div>
                    </div>
                </div>
                <div className="header_nav_detail">
                    <div className="container clearfix">
                        <div className="col-md-3 logo">
                            <a href={globalConfig.context + '/portal/index.html'}>
                                <img src={logoImg} alt="" />
                            </a>
                        </div>
                        <div className="col-md-9">
                            <ul className="nav_content">
                                <li className="home"><a href={globalConfig.context + "/portal/index.html"}>首页</a> </li>
                                <li className="active">
                                    <a href={globalConfig.context + '/portal/search/achievement.html'}>技术交易</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (4 * 75) + 'px', left: '-' + (4 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li className={this.props.active == 'demand' ? 'active' : ''}><a href={globalConfig.context + '/portal/search/demand.html'}>需求谷</a></li>
                                        <li className={this.props.active == 'achievement' ? 'active' : ''} ><a href={globalConfig.context + '/portal/search/achievement.html'}>技术海</a></li>
                                        <li className={this.props.active == 'subscriberOrg' ? 'active' : ''}><a href={globalConfig.context + '/portal/search/subscriberOrg.html'}>伙伴</a></li>
                                        <li className={this.props.active == 'subscriberUser' ? 'active' : ''}><a href={globalConfig.context + '/portal/search/subscriberUser.html'}>行家</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/scienceTechnology/bigShot.html'}>大咖说</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (2 * 75) + 'px', left: '-' + (2 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li><a href={globalConfig.context + '/portal/scienceTechnology/star.html'}>科技明星</a></li>
                                        <li><a href={globalConfig.context + '/portal/scienceTechnology/lecture.html'}>科技讲堂</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/activity/activityIndex.html'}>活动圈</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (2 * 75) + 'px', left: '-' + (2 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li><a href={globalConfig.context + '/portal/activity/activityList.html?type=0'}>在线直播</a></li>
                                        <li><a href={globalConfig.context + '/portal/activity/activityList.html?type=1'}>线下现场</a></li>
                                    </ul>
                                </li >
                                <li>
                                    <a href={globalConfig.context + '/portal/websiteBuild/websiteBuildIndex.html'}>建设兵团</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (3 * 75) + 'px', left: '-' + (3 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li><a href={globalConfig.context + '/portal/websiteBuild/websiteBuildIndex.html#customized'}>平台定制</a></li>
                                        <li><a href={globalConfig.context + '/portal/websiteBuild/websiteBuildIndex.html#operates'}>平台运营</a></li>
                                        <li><a href={globalConfig.context + '/portal/websiteBuild/websiteBuildIndex.html#event_planning'}>活动筹划</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/international/internationalIndex.html'}>国际业务</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (3 * 75) + 'px', left: '-' + (3 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li><a href={globalConfig.context + '/portal/international/internationalIndex.html#internationalTechnology'}>国际技术</a></li>
                                        <li><a href={globalConfig.context + '/portal/international/internationalIndex.html#internationalPartner'}>国际伙伴</a></li>
                                        <li><a href={globalConfig.context + '/portal/international/internationalIndex.html#internationalExpert'}>国际专家</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/service/serviceIndex.html'}>服务汇</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (3 * 75) + 'px', left: '-' + (3 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li ><a href={globalConfig.context + '/portal/highTech/authentication.html'}>高企认定</a></li>
                                        <li ><a href={globalConfig.context + '/portal/ipr/service.html'}>知识产权</a></li >
                                        <li ><a href={globalConfig.context + '/portal/evaluation/index.html'}>技术评估</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/news/newsIndex.html'}>策源地</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (4 * 75) + 'px', left: '-' + (4 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li><a href={globalConfig.context + '/portal/news/newsDetails.html?type=1'}>新闻快讯</a></li>
                                        <li><a href={globalConfig.context + '/portal/news/newsDetails.html?type=3'}>技淘新闻</a></li>
                                        <li><a href={globalConfig.context + '/portal/news/newsDetails.html?type=4'}>科技政策</a></li>
                                        <li><a href={globalConfig.context + '/portal/news/newsDetails.html?type=2'}>政府往来</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/entrepreneurship/entrepreneurshipIndex.html'}>创业圈</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (3 * 75) + 'px', left: '-' + (3 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li><a href={globalConfig.context + '/portal/entrepreneurship/entrepreneurshipIndex.html'}>项目圈</a></li>
                                        <li><a href={globalConfig.context + '/portal/entrepreneurship/entrepreneurshipIndex.html#chuangke'}>创客圈</a></li>
                                        <li><a href={globalConfig.context + '/portal/entrepreneurship/entrepreneurshipIndex.html#jieyi'}>结义园</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/financial/financialIndex.html'}>金融圈</a>
                                    <ul className="secondary_navigation_nav" style={{ 'width': (1 * 75) + 'px', left: '-' + (1 * 75 / 2 - 74.25 / 2) + 'px' }}>
                                        <li ><a href={globalConfig.context + '/portal/financial/financialIndex.html'}>金融街</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href={globalConfig.context + '/portal/residentIntegration/index.html'}>军民融合</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div className="secondary_navigation"></div>
                </div>
            </div>
        )
    }
});

export default LoginTop;