leftMenu.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import React from 'react';
  2. import { Menu, Icon } from 'antd';
  3. import '../leftTab.less';
  4. const SubMenu = Menu.SubMenu;
  5. const MenuItemGroup = Menu.ItemGroup;
  6. import { Link } from 'react-router';
  7. import ajax from 'jquery/src/ajax/xhr.js';
  8. import $ from 'jquery/src/ajax';
  9. import { menu } from '@/account/menu';
  10. import logo from 'img/acc-logo.png';
  11. const LeftTab = React.createClass({
  12. getInitialState() {
  13. return {
  14. openKeys: [ 'sub1' ],
  15. current: 'account'
  16. };
  17. },
  18. loadData() {
  19. $.ajax({
  20. method: 'post',
  21. dataType: 'json',
  22. url: globalConfig.context + '/api/admin/customer/left',
  23. data: {}
  24. }).done(
  25. function(data) {
  26. if (!data.data.error.length) {
  27. this.setState({
  28. state: data.data.aa
  29. });
  30. } else {
  31. message.warning(data.error[0].message);
  32. }
  33. }.bind(this)
  34. );
  35. },
  36. menuClick(e) {
  37. this.setState({
  38. current: e.key
  39. });
  40. window.location.hash=e.key;
  41. },
  42. componentWillMount() {
  43. this.loadData();
  44. if (window.location.hash) {
  45. let current = window.location.hash.substr(2);
  46. this.setState({
  47. current
  48. })
  49. }
  50. },
  51. render() {
  52. console.log(this.state.current)
  53. return (
  54. <div>
  55. <div className="acc-index">
  56. <img src={logo} alt="" />
  57. <span>
  58. <a href={globalConfig.context + '/user/account/index.html'}>会员中心首页</a>
  59. </span>
  60. </div>
  61. <Menu
  62. onClick={this.menuClick}
  63. defaultOpenKeys={this.state.openKeys}
  64. selectedKeys={[ this.state.current ]}
  65. mode="inline"
  66. theme='light'
  67. className="account-left"
  68. >
  69. {menu.map((subMenu) => {
  70. if (subMenu.children && subMenu.children.length) {
  71. return (
  72. <SubMenu
  73. key={subMenu.url}
  74. title={
  75. <span>
  76. <Icon type={subMenu.icon} />
  77. <span>{subMenu.name}</span>
  78. </span>
  79. }
  80. >
  81. {subMenu.children.map((menu) => (
  82. <Menu.Item key={menu.url}>
  83. {menu.name}
  84. </Menu.Item>
  85. ))}
  86. </SubMenu>
  87. );
  88. }
  89. return (
  90. <Menu.Item key={subMenu.url}>
  91. <Link to={`/${subMenu.url}`}>
  92. <Icon type={subMenu.icon} />
  93. <span className="nav-text">{subMenu.name}</span>
  94. </Link>
  95. </Menu.Item>
  96. );
  97. })}
  98. </Menu>
  99. </div>
  100. );
  101. }
  102. });
  103. export default LeftTab;
  104. // <Menu.Item key="base">
  105. // 基本信息
  106. // </Menu.Item>
  107. // <Menu.Item key="person">
  108. // 个人资料
  109. // </Menu.Item>
  110. // <Menu.Item key="edu">
  111. // 教育信息
  112. // </Menu.Item>
  113. // <Menu.Item key="pfs">
  114. // 职业信息
  115. // </Menu.Item>
  116. // <Menu.Item key="ablt">
  117. // 能力标签
  118. // </Menu.Item>