xy 7 lat temu
rodzic
commit
2480180e4e

+ 39 - 13
src/app/wechatService/wxConfig/WxConfig.jsx

@@ -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>
+
         )
     }
 }

+ 2 - 1
src/app/wechatService/wxTrialCase/WXTrialCase.js

@@ -5,6 +5,7 @@ import {Layout, Menu} from 'antd';
 import WxConfig from "../wxConfig/WxConfig";
 import WxDeploy from "../wxDeploy/WxDeploy";
 import WxResult from '../wxResult/WxResult';
+import Schema from "../../graphqlService/common/schema/Schema";
 
 const {Content} = Layout;
 
@@ -49,7 +50,7 @@ class WXTrialCase extends Component {
                         {(() => {
                             switch (this.state.menuLevel3) {
                                 case 'wechat-config':
-                                    return <WxConfig/>;
+                                    return <WxConfig history={this.props.history} location={this.props.location}/>;
                                 case 'wechat-deploy':
                                     return <WxDeploy/>;
                                 case 'wechat-result':

+ 2 - 1
src/app/wechatService/wxUserCreate/WXUserCreate.js

@@ -5,6 +5,7 @@ import {Layout, Menu} from 'antd';
 import WxConfig from "../wxConfig/WxConfig";
 import WxDeploy from "../wxDeploy/WxDeploy";
 import WxResult from '../wxResult/WxResult';
+import Schema from "../../graphqlService/common/schema/Schema";
 
 const {Content} = Layout;
 
@@ -49,7 +50,7 @@ class WXUserCreate extends Component {
                         {(() => {
                             switch (this.state.menuLevel3) {
                                 case 'wechat-config':
-                                    return <WxConfig/>;
+                                    return <WxConfig history={this.props.history} location={this.props.location}/>;
                                 case 'wechat-deploy':
                                     return <WxDeploy/>;
                                 case 'wechat-result':

+ 22 - 1
src/gql.js

@@ -467,6 +467,26 @@ const ADD_WXCONFIG = `
             }
 `;
 
+const SHOW_WXCONTENT = `
+            query wxConfigbyid($id: ID) {
+                wxConfig_by_id(id: $id) {
+                    mch_id
+                    appName
+                    notify_url
+                    appSecret
+                    appID
+                    token
+                    spbill_create_ip
+                    enter_url
+                    id
+                    pay_api_key
+                    body
+                    welcome_words
+                    attach
+                }
+            }
+        `;
+
 export {
     ADD_USER,
     GET_USER,
@@ -494,5 +514,6 @@ export {
     SHOW_FC,
     SHOW_ALL_WXCONFIG,
     SHOW_WXCONFIG,
-    ADD_WXCONFIG
+    ADD_WXCONFIG,
+    SHOW_WXCONTENT
 }