|
|
@@ -5,7 +5,7 @@ import {Modal, Row, Col, Input, Icon, Button, Spin} from 'antd';
|
|
|
import {Mutation, Query} from "react-apollo";
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
-import {ADD_WXCONFIG, SHOW_WXCONFIG} from '../../../gql'
|
|
|
+import {ADD_WXCONFIG,ADD_PROJECT_AND_WX, SHOW_WXCONFIG} from '../../../gql'
|
|
|
import './index.css';
|
|
|
import {getCookie} from "../../../cookie";
|
|
|
import {idGen} from "../../../func";
|
|
|
@@ -44,13 +44,19 @@ class WxCreate extends Component {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- handleOk = (userID, create_wxConfig) => {
|
|
|
+ handleOk = (userID, create_project_and_wxConfig) => {
|
|
|
let {mch_id, notify_url, appSecret, appID, token, spbill_create_ip, enter_url, pay_api_key, body, welcome_words, attach} = this.state;
|
|
|
- let varobj = {
|
|
|
- id: idGen('wxConfig'),
|
|
|
+ let wxConfigId = idGen('wxConfig');
|
|
|
+ let projectId= idGen('project');
|
|
|
+ let appName = this.state.appName;
|
|
|
+ let createdAt = new Date().getTime();
|
|
|
+
|
|
|
+ let wxConfigVarObj = {
|
|
|
+ wxConfigId,
|
|
|
+ appName,
|
|
|
user_id: userID,
|
|
|
- createdAt: new Date().getTime(),
|
|
|
- updatedAt: '',
|
|
|
+ wxCreatedAt: createdAt,
|
|
|
+ wxUpdatedAt: '',
|
|
|
mch_id,
|
|
|
notify_url,
|
|
|
appSecret,
|
|
|
@@ -63,16 +69,29 @@ class WxCreate extends Component {
|
|
|
welcome_words,
|
|
|
attach
|
|
|
};
|
|
|
- let appName = this.state.appName;
|
|
|
+ let projectVarObj = {
|
|
|
+ projectCreatedAt: createdAt,
|
|
|
+ projectUpdatedAt: '',
|
|
|
+ database_id: '',
|
|
|
+ apiGWGroup_id: '',
|
|
|
+ projectName: appName,
|
|
|
+ deploy_id: '',
|
|
|
+ projectId,
|
|
|
+ projectType: 'wx',
|
|
|
+ cloud_id: '',
|
|
|
+ user_id: userID,
|
|
|
+ wxConfig_id: wxConfigId,
|
|
|
+ schema_id: ''
|
|
|
+ };
|
|
|
|
|
|
this.setState({
|
|
|
confirmLoading: true,
|
|
|
});
|
|
|
|
|
|
- create_wxConfig({
|
|
|
+ create_project_and_wxConfig({
|
|
|
variables: {
|
|
|
- ...varobj,
|
|
|
- appName
|
|
|
+ ...wxConfigVarObj,
|
|
|
+ ...projectVarObj
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -89,7 +108,7 @@ class WxCreate extends Component {
|
|
|
pathname: `/wechat-service/my-create/${appName}`,
|
|
|
state: {
|
|
|
appName,
|
|
|
- configID: varobj.id,
|
|
|
+ configID: wxConfigId,
|
|
|
create: true
|
|
|
}
|
|
|
});
|
|
|
@@ -102,11 +121,9 @@ class WxCreate extends Component {
|
|
|
return (
|
|
|
<div>
|
|
|
<Mutation
|
|
|
- mutation={gql(ADD_WXCONFIG)}
|
|
|
- refetchQueries={[{query: gql(SHOW_WXCONFIG), variables: {user_id: userID}}]}
|
|
|
+ mutation={gql(ADD_PROJECT_AND_WX)}
|
|
|
>
|
|
|
-
|
|
|
- {(create_wxConfig, {loading, error}) => {
|
|
|
+ {(create_project_and_wxConfig, {loading, error}) => {
|
|
|
if (loading)
|
|
|
return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
|
if (error)
|
|
|
@@ -115,7 +132,7 @@ class WxCreate extends Component {
|
|
|
<Modal title="Create Wechat Service"
|
|
|
centered
|
|
|
visible={visible}
|
|
|
- onOk={() => this.handleOk(userID, create_wxConfig)}
|
|
|
+ onOk={() => this.handleOk(userID, create_project_and_wxConfig)}
|
|
|
confirmLoading={confirmLoading}
|
|
|
onCancel={() => {
|
|
|
this.props.hideModal();
|