import React from 'react';
import './portal.less';
import logo from '../../../image/logo.jpg';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';

const LoginTop = React.createClass({
    logOut() {
        $.ajax({
            method: "get",
            dataType: "json",
            url: globalConfig.context + "/login",
        }).done(function (data) {
            window.location.href = globalConfig.context + "/user/login.html"
        });
    },
    render() {
        return (
            <div className="portal-header">
                <div className="portal-logo clearfix">
                    <div className="logo">
                        <img src={logo} alt="" />
                    </div>
                    <div className="portal-text">
                        <span className="text">科技{this.props.searchType}搜索</span>
                        <span className="alink">
                            <a href={globalConfig.context + "/user/account/index.html"}>返回首页</a>
                            {window.userData.nickname ?
                                <span>
                                    <a href={globalConfig.context + "/user/account/index"}>尊敬的{userData.nickname || userData.number}</a>
                                    <a href="./index.html">交易管理中心</a>
                                    <a href="./index.html">消息</a>
                                </span>
                                : <a href={globalConfig.context + "/user/login/index"}>请登录</a>}
                            <a onClick={this.logOut}>退出</a>
                            <a href="./index.html">帮助中心</a>
                        </span>
                    </div>
                </div>
            </div>
        )
    }
});

export default LoginTop;