|
|
@@ -1,7 +1,10 @@
|
|
|
import React, {Component} from 'react';
|
|
|
-import {Input, Radio, Collapse, Button, Icon} from 'antd';
|
|
|
+import {Input, Spin, Button, Icon} from 'antd';
|
|
|
import './index.css';
|
|
|
import {idGen} from "../../../func";
|
|
|
+import {SHOW_WXCONTENT} from "../../../gql";
|
|
|
+import gql from "graphql-tag";
|
|
|
+import {Mutation, Query} from "react-apollo";
|
|
|
|
|
|
class WxConfig extends Component {
|
|
|
|
|
|
@@ -9,8 +12,6 @@ class WxConfig extends Component {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
configs: ['AppName', 'AppID', 'AppSecret', 'URL', 'Token', 'welcome_words', 'pay_api_key', 'attach', 'mch_id', 'body', 'spbill_create_ip', 'notify_url'],
|
|
|
- appName: '',
|
|
|
- configID: '',
|
|
|
mch_id: '',
|
|
|
notify_url: '',
|
|
|
appSecret: '',
|
|
|
@@ -21,7 +22,9 @@ class WxConfig extends Component {
|
|
|
pay_api_key: '',
|
|
|
body: '',
|
|
|
welcome_words: '',
|
|
|
- attach: ''
|
|
|
+ attach: '',
|
|
|
+ configID: props.location.state === undefined ? props.configID : props.location.state.configID,
|
|
|
+ appName: props.location.state === undefined ? props.appName : props.location.state.appName,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -33,19 +36,42 @@ class WxConfig extends Component {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+ componentWillReceiveProps(next) {
|
|
|
+ this.setState({
|
|
|
+ configID: next.configID,
|
|
|
+ appName: next.appName,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
return (
|
|
|
- <div>
|
|
|
+ <Query query={gql(SHOW_WXCONTENT)} variables={{id: this.state.configID}}>
|
|
|
{
|
|
|
- this.state.configs.map(config => (
|
|
|
- <div key={config} style={{marginBottom: 10}}>
|
|
|
- <span className='vice-title'>{config}: </span>
|
|
|
- <Input value={this.state[config]} style={{width: 200}} onChange={this.switchConfig(config)}/>
|
|
|
- </div>
|
|
|
- ))
|
|
|
+ ({loading, error, data}) => {
|
|
|
+ if (loading) {
|
|
|
+ return <Spin style={{marginLeft: 3}}/>
|
|
|
+ }
|
|
|
+ if (error) {
|
|
|
+ return 'error!';
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ {
|
|
|
+ this.state.configs.map(config => (
|
|
|
+ <div key={config} style={{marginBottom: 10}}>
|
|
|
+ <span className='vice-title'>{config}: </span>
|
|
|
+ <Input value={this.state[config]} style={{width: 200}} onChange={this.switchConfig(config)}/>
|
|
|
+ </div>
|
|
|
+ ))
|
|
|
+ }
|
|
|
+ <Button type={'primary'}>save</Button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
- <Button type={'primary'}>save</Button>
|
|
|
- </div>
|
|
|
+ </Query>
|
|
|
+
|
|
|
)
|
|
|
}
|
|
|
}
|