Browse Source

修改分时段

yu_ber 4 years ago
parent
commit
ce22aa9447

+ 21 - 53
UI/src/pages/sellmanage/msgComponent.js

@@ -82,7 +82,9 @@ class MsgComponent extends React.Component {
             selectKeysProps: "",
             imgInitialization: false,
             _ID: "",
-            anyKes: false
+            anyKes: false,
+            tabsKes:false,
+            num:false
         };
     }
 
@@ -133,36 +135,10 @@ class MsgComponent extends React.Component {
     };
     //点击 上传图片/重新上传
     upload1 = () => {
-
-        // if (this.state.chooseKey == 'text') {
-        //     this.setState({
-        //         imageVisiable: true,
-        //         imgUrlText: '',
-        //         mediaIdText: '',
-        //         selectIndex: -1,
-        //         imgSelect: "",
-        //     });
-        // } else if (this.state.chooseKey == 'news') {
-        //     this.setState({
-        //         imageVisiable: true,
-        //         imgUrlNews: '',
-        //         mediaIdNews: '',
-        //         selectIndex: -1,
-        //         imgSelect: "",
-        //     });
-        // } else if (this.state.chooseKey == 'miniprogrampage') {
-        //     this.setState({
-        //         imageVisiable: true,
-        //         imgUrlMini: '',
-        //         mediaIdMini: '',
-        //         selectIndex: -1,
-        //         imgSelect: "",
-        //     });
-        // }
-
         this.props.updateFrom();
         this.setState({
             imageVisiable: true,
+            tabsKes:true
         })
         this.loadData();
 
@@ -353,27 +329,22 @@ class MsgComponent extends React.Component {
         });
     }
     componentWillReceiveProps(nextProps) {
-        //   console.log(nextProps);
-        if (!nextProps.type && nextProps.mediaId && nextProps.chooseKey == nextProps.cutextKey) {
-            this.setState({ anyKes:nextProps.cutextKey,chooseKey: nextProps.chooseKey, _ID:nextProps.mediaId ? nextProps.mediaId : null }, () => { this.loadImgs()})
-        } else {
-            this.setState({
-                imgUrlText:"",
-                imgUrlNews:"",
-                imgUrlMini:"",
-            })
-        }
-        // if (nextProps.mediaId && nextProps.mediaId != null && nextProps.chooseKey == nextProps.cutextKey) {
-        //     // this.loadImgs();
-        // } else {
-        //     // console.log("cuo wu");
-        //     // this.setState({
-        //     //     imgUrlText:"",
-        //     //     imgUrlNews:"",
-        //     //     imgUrlMini:"",
-        //     // })
-        // }
-
+        // console.log(nextProps,'------------');
+        if(nextProps.selectKeys == nextProps.tabIndex){
+            if(!this.state.tabsKes){
+               
+                if (!nextProps.type && nextProps.mediaId && nextProps.chooseKey == nextProps.cutextKey) {
+                    console.log(nextProps,'nextProps');
+                    this.setState({anyKes:nextProps.cutextKey,chooseKey: nextProps.chooseKey, _ID:this.state.chooseKey != "miniprogrampage" ? nextProps.mediaId : nextProps.thumbMediaId }, () => { this.loadImgs()})
+                } else {
+                    this.setState({
+                        imgUrlText:"",
+                        imgUrlNews:"",
+                        imgUrlMini:"",
+                    })
+                }
+            }
+    }
         // let self = this;
         // if (!util.object.equal(nextProps.msgId, this.state.msgId)) {
         //     self.setState({ msgId: nextProps.msgId }, () => { self.loadImgs()});
@@ -412,13 +383,10 @@ class MsgComponent extends React.Component {
                 }).then(function (res) {
                     if (res.success == 1) {
                         if (self.state.chooseKey == 'text') {
-                            console.log("我是text")
                             self.setState({ imgUrlText: res.result.localUrl })
                         } else if (self.state.chooseKey == 'news') {
-                            console.log("我是news")
                             self.setState({ imgUrlNews: res.result.localUrl }) //imgUrlNews = res.result.localUrl;
                         } else if (self.state.chooseKey == 'miniprogrampage') {
-                            console.log("我是miniprogrampage")
                             self.setState({ imgUrlMini: res.result.localUrl }) //imgUrlMini = res.result.localUrl;
                         }
                     }
@@ -646,6 +614,7 @@ class MsgComponent extends React.Component {
                         self.props.chooseKeyChange(key);
                         this.setState({
                             chooseKey: key,
+                            tabsKes:true
                         });
                     }}
                     onTabClick={key => this.tabChange(key)}
@@ -907,7 +876,6 @@ function mapStateToProps(state) {
 
 export default connect(mapStateToProps)(Form.create({
     mapPropsToFields(props) {
-        // console.log(props);
         if (!props || !props.chooseKey) {
             props = {
                 content: '', title: '', description: '', url: '',

+ 37 - 45
UI/src/pages/sellmanage/pushMessage/index.js

@@ -89,12 +89,9 @@ class PushMessage extends React.Component {
         {}
       ],
       selectIndex: 'text',
-      fromText: {},
-      fromNews: {},
-      fromminiprogrampage: {},
       disabled: false,
       contentValueItem: "",
-      typeText:"text",
+      typeText: "text",
       TimePicker: [
         {
           value: [],
@@ -129,10 +126,10 @@ class PushMessage extends React.Component {
     if (items) {
       if (!items[key])
         items[key] = {};
-        items[key].disable = checked ? 0 : 1;
-        var chooseKey
-        let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
-        chooseKey =  keys && keys.message  && keys.message.msgType ? keys.message.msgType : 'text';
+      items[key].disable = checked ? 0 : 1;
+      var chooseKey
+      let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
+      chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
       let messageItem = {}
       messageItem.content = content;
       messageItem.miniAppTitle = miniAppTitle;
@@ -145,7 +142,7 @@ class PushMessage extends React.Component {
       items[key].message = messageItem;
       initData.items = items;
     }
-    
+
     this.props.dispatch({ type: 'pushMessage/updateState', payload: { initData: initData } });
   }
 
@@ -172,10 +169,10 @@ class PushMessage extends React.Component {
     if (items) {
       if (!items[key])
         items[key] = {};
-        items[key].week = value;
-        var chooseKey
-        let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
-        chooseKey =  keys && keys.message  && keys.message.msgType ? keys.message.msgType : 'text';
+      items[key].week = value;
+      var chooseKey
+      let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
+      chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
       let messageItem = {}
       messageItem.content = content;
       messageItem.miniAppTitle = miniAppTitle;
@@ -229,14 +226,14 @@ class PushMessage extends React.Component {
       var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
       var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
       var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
-  
-  
+
+
       if (items) {
         if (!items[key])
           items[key] = {};
-          var chooseKey
-          let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
-          chooseKey =  keys && keys.message  && keys.message.msgType ? keys.message.msgType : 'text';
+        var chooseKey
+        let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
+        chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
         let messageItem = {}
         messageItem.content = content;
         messageItem.miniAppTitle = miniAppTitle;
@@ -280,13 +277,13 @@ class PushMessage extends React.Component {
       var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
       var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
       var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
-  
+
       if (items) {
         if (!items[key])
           items[key] = {};
-          var chooseKey
-          let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
-          chooseKey =  keys && keys.message  && keys.message.msgType ? keys.message.msgType : 'text';
+        var chooseKey
+        let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
+        chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
         let messageItem = {}
         messageItem.content = content;
         messageItem.miniAppTitle = miniAppTitle;
@@ -313,12 +310,12 @@ class PushMessage extends React.Component {
       if (!items[key])
         items[key] = {};
 
-      var message1 = { msgType:this.state.typeText };
+      var message1 = { msgType: this.state.typeText };
       if (this.props.pushMessage.initData.items[key] && this.props.pushMessage.initData.items[key].message) {
         message1 = this.props.pushMessage.initData.items[key].message;
         message1.msgType = this.props.pushMessage.initData.items[key].message.msgType ? this.props.pushMessage.initData.items[key].message.msgType : 'text'
         message1.msgId = this.props.pushMessage.initData.items[key].message.msgId ? this.props.pushMessage.initData.items[key].message.msgId : null
-        message1.thumbMediaId = this.props.pushMessage.initData.items[key].message.mediaId ? this.props.pushMessage.initData.items[key].message.mediaId  : null
+        message1.thumbMediaId = this.props.pushMessage.initData.items[key].message.mediaId ? this.props.pushMessage.initData.items[key].message.mediaId : null
       }
       // thumbMediaId
       message1.content = this.state.msgComponent[key].props.form.getFieldValue('content')
@@ -331,7 +328,6 @@ class PushMessage extends React.Component {
       items[key].message = message1;
       initData.items = items;
     }
-    console.log(message1,'message1');
     var data = initData.items[key];
     if (typeof (data.disable) === 'undefined')
       data.disable = 0;
@@ -357,7 +353,7 @@ class PushMessage extends React.Component {
 
       let week1 = items.week;
 
-      var message1 = {  msgType:this.state.typeText }
+      var message1 = { msgType: this.state.typeText }
       if (this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[key]
         && this.props.pushMessage.initData.items[key].message) {
 
@@ -406,9 +402,9 @@ class PushMessage extends React.Component {
     if (items) {
       if (!items[key])
         items[key] = {};
-        var chooseKey
-        let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
-        chooseKey =  keys && keys.message  && keys.message.msgType ? keys.message.msgType : 'text';
+      var chooseKey
+      let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
+      chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
       let messageItem = {}
       messageItem.content = content;
       messageItem.miniAppTitle = miniAppTitle;
@@ -434,14 +430,14 @@ class PushMessage extends React.Component {
     if (items) {
       if (!items[key])
         items[key] = {};
-      var message1 = {  msgType:this.state.typeText }
+      var message1 = { msgType: this.state.typeText }
       if (this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[key]
         && this.props.pushMessage.initData.items[key].message) {
         message1 = this.props.pushMessage.initData.items[key].message
       }
 
       if (chooseKey)
-      message1.chooseKey = chooseKey;
+        message1.chooseKey = chooseKey;
       message1.msgType = chooseKey;
       items[key].message = message1;
       initData.items = items;
@@ -509,9 +505,9 @@ class PushMessage extends React.Component {
     if (items) {
       if (!items[key])
         items[key] = {};
-        var chooseKey
-        let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
-        chooseKey =  keys && keys.message  && keys.message.msgType ? keys.message.msgType : 'text';
+      var chooseKey
+      let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
+      chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
       let messageItem = {}
       messageItem.content = content;
       messageItem.miniAppTitle = miniAppTitle;
@@ -531,11 +527,7 @@ class PushMessage extends React.Component {
   onSelect = (index) => {
     this.setState({
       currentState: index,
-      fromText: {},
-      fromNews: {},
-      fromminiprogrampage: {}
     })
-    // this.props.dispatch({ type: 'pushMessage/initMessage', payload: {} });
   }
 
   render() {
@@ -572,6 +564,8 @@ class PushMessage extends React.Component {
               weekItem = data.items && data.items[key] && typeof (data.items[key].week) !== 'undefined' ? data.items[key].week : 1;
             }
 
+          
+
             var chooseKey = 'text';
             var cutextKey = "text"
             var message1 = {};
@@ -582,12 +576,10 @@ class PushMessage extends React.Component {
               keys ? chooseKey = keys.message && keys.message.msgType : chooseKey = "text"
               let item = self.props.pushMessage.selectKesData.items[self.state.currentState]
               item ? cutextKey = item.message && item.message.msgType : cutextKey = "text"
-
               message1 = self.props.pushMessage.initData.items[self.state.currentState].message;
-              message1.content = self.props.pushMessage.initData.items[self.state.currentState].message.content ? 
-              self.props.pushMessage.initData.items[self.state.currentState].message.content : this.state.contentValueItem
+              message1.content = self.props.pushMessage.initData.items[self.state.currentState].message.content ?
+                self.props.pushMessage.initData.items[self.state.currentState].message.content : this.state.contentValueItem
             }
-            // console.log(message1,'-----message1--()--message1------');
 
             return (
               <div className={styles.connect} style={{ display: (key === self.state.currentState) ? "block" : "none" }}>
@@ -619,10 +611,10 @@ class PushMessage extends React.Component {
 
                 <div className={styles.contentList}>
                   <MsgComponent tabIndex={key}
-                    { ...message1 }
+                    {...message1}
                     chooseKey={chooseKey}
-                    cutextKey = { cutextKey }
-                    selectKeys = { self.state.currentState }
+                    cutextKey={cutextKey}
+                    selectKeys={self.state.currentState}
                     bottomFriom={(key) => { self.handleSubmit(key) }}
                     mediaIdChange={(v) => { self.cb_mediaId(v, key) }}
                     onChange={(v, av) => { self.cb_formChange(v, av, key) }}

+ 11 - 1
UI/src/pages/sellmanage/pushMessage/model.js

@@ -27,6 +27,7 @@ export default {
         try{
           const data = yield call(getData, {appId:wxAppIdValue});
           const itemkey = yield call(getData, {appId:wxAppIdValue});
+          
           let defaulttimesList = data.items;
           let times = {};
           var tempItem ={};
@@ -38,6 +39,15 @@ export default {
           }
           data.items= newItems;
 
+          
+          var element = {};
+          var itemsTem = [];
+          for(var v in itemkey.items){
+            element = itemkey.items[v];
+            itemsTem[element.tableNo] = element;
+          }
+          itemkey.items= itemsTem;
+
           for(var i in newItems){
             var timeranges = [];
             for(var j in newItems[i].timesList){
@@ -51,7 +61,7 @@ export default {
            times[newItems[i].tableNo] = timeranges;
           }
 
-
+          console.log(data,itemkey);
           yield put({
             type: 'updateState',
             payload: {

+ 1 - 1
UI/src/pages/sellmanage/templateMessage/index.js

@@ -679,7 +679,7 @@ class TemplateMessage extends React.Component {
                     <div className={styles.fieldList}>
                     {
                       ItemFromMation && ItemFromMation.contentValueList.map((item, key) => {
-                        return  <div className={styles.list}><div className={styles.fieldTitle} style={{minWidth:"120px"}}>{item.prefix}:</div><div className={styles.fieldItem}>{item.value}</div></div>
+                        return  <div className={styles.list}><div className={styles.fieldTitle} style={{minWidth:"120px"}}>{item.prefix}</div><div className={styles.fieldItem}>{item.value}</div></div>
                       })
                     }
                     </div>