topTab.jsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React from 'react';
  2. import { Row, Col } from 'antd';
  3. import './topTab.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import logo from '../../../image/acc-logo.png';
  7. const TopTab = React.createClass({
  8. getInitialState() {
  9. return {
  10. username: 'username',
  11. };
  12. },
  13. logOut() {
  14. $.ajax({
  15. method: "get",
  16. dataType: "json",
  17. url: globalConfig.context + "/login",
  18. }).done(function (data) {
  19. window.location.href = globalConfig.context + "/portal/index.html"
  20. });
  21. },
  22. componentWillMount () {
  23. this.getData();
  24. },
  25. getData () {
  26. this.setState({
  27. loading: false
  28. });
  29. $.ajax({
  30. method: "get",
  31. dataType: "json",
  32. url: globalConfig.context + "/api/user/nickname"
  33. }).done(function (data) {
  34. if (data.error && data.error.length) {
  35. message.warning(data.error[0].message);
  36. } else {
  37. this.setState({
  38. nickname: data.data,
  39. })
  40. }
  41. }.bind(this)).always(function () {
  42. this.setState({
  43. loading: false
  44. });
  45. }.bind(this));
  46. },
  47. render() {
  48. return (
  49. <div className="account-top" >
  50. <div className="acc-top-user">
  51. <span className="acc-top-user-name">欢迎您, {this.state.nickname || userData.nickname || userData.number } <a onClick={this.logOut}>[ 退出 ]</a></span>
  52. <span className="acc-top-user-toindex"><a href={globalConfig.context + "/portal/index.html"}>返回首页</a></span>
  53. </div>
  54. <div className="acc-index">
  55. <div className="acc-index-imgbox">
  56. <img src={logo} alt="" />
  57. </div>
  58. <span><a href={globalConfig.context + "/user/account/index.html"}>会员中心首页</a></span>
  59. </div>
  60. <div className="acc-top-tab">
  61. <Row>
  62. <Col className={this.props.active === 'set' ? 'active' : ''} span={3}><a href={globalConfig.context + "/user/account/set.html"}>账号设置</a></Col>
  63. <Col className={this.props.active === 'services' ? 'active' : ''} span={3}><a href={globalConfig.context + "/user/account/services.html"}>科技服务</a></Col>
  64. <Col className={this.props.active === 'achievement' ? 'active' : ''} span={3}><a href={globalConfig.context + "/user/account/achievement.html"}>科技成果</a></Col>
  65. <Col className={this.props.active === 'demand' ? 'active' : ''} span={3}><a href={globalConfig.context + "/user/account/demand.html"}>科技需求</a></Col>
  66. </Row>
  67. </div>
  68. </div >
  69. )
  70. }
  71. });
  72. export default TopTab;