WxUserCreate.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React, {Component} from 'react';
  2. import {Layout, Menu} from 'antd';
  3. import {getIdUrl} from '../../config'
  4. import WxConfig from "./wxConfig/WxConfig";
  5. import WxDeploy from "../common/deploy/Deploy";
  6. import WxResult from './wxResult/WxResult';
  7. import axios from 'axios';
  8. import {FormattedMessage} from 'react-intl';
  9. axios.defaults.withCredentials = true;
  10. const {Content} = Layout;
  11. class WxUserCreate extends Component {
  12. constructor() {
  13. super();
  14. this.state = {
  15. menuLevel3: "wechat-config",
  16. userID: '',
  17. getIdUrl
  18. }
  19. }
  20. componentWillMount() {
  21. let _this = this;
  22. axios.get(this.state.getIdUrl)
  23. .then((res) => {
  24. if (res.data !== '') {
  25. _this.setState({
  26. userID: res.data
  27. })
  28. }
  29. })
  30. .catch(function (err) {
  31. console.log(err);
  32. });
  33. }
  34. switchMenu = (menuName, e) => {
  35. this.setState({
  36. [menuName]: e.key,
  37. });
  38. };
  39. render() {
  40. let configID = this.props.history.location.state ? this.props.history.location.state.configID : "ecommerce_wxConfigID";
  41. let appName = this.props.history.location.state ? this.props.history.location.state.appName : "ecommerce";
  42. return (
  43. <div>
  44. <Menu
  45. mode="horizontal"
  46. defaultSelectedKeys={['wechat-config']}
  47. style={{
  48. padding: '0 24px',
  49. position: 'fixed',
  50. width: '100%',
  51. zIndex: '1',
  52. lineHeight: '50px',
  53. fontWeight: 600
  54. }}
  55. onClick={(e) => this.switchMenu('menuLevel3', e)}
  56. selectedKeys={[this.state.menuLevel3]}
  57. >
  58. <Menu.Item key="wechat-config"><FormattedMessage id="config"/></Menu.Item>
  59. <Menu.Item key="wechat-deploy"><FormattedMessage id="deploy"/></Menu.Item>
  60. <Menu.Item key="wechat-result"><FormattedMessage id="result"/></Menu.Item>
  61. </Menu>
  62. <Layout style={{padding: '24px', zIndex: '0'}}>
  63. <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
  64. {(() => {
  65. switch (this.state.menuLevel3) {
  66. case 'wechat-config':
  67. return <WxConfig history={this.props.history} location={this.props.location}/>;
  68. case 'wechat-deploy':
  69. return <WxDeploy trialcase={false} userID={this.state.userID} configID={configID}/>;
  70. case 'wechat-result':
  71. return <WxResult/>;
  72. default:
  73. return <WxConfig/>
  74. }
  75. })()}
  76. </Content>
  77. </Layout>
  78. </div>
  79. )
  80. }
  81. }
  82. export default WxUserCreate;