Browse Source

add:评论后回调加传评论参数,用于推送处理

zhengyingya 5 years ago
parent
commit
a7dfebaf27

+ 2
- 2
src/App.js View File

246
         if (this.props.showAlertComment) {
246
         if (this.props.showAlertComment) {
247
           message.success(intl.get("message.success"));
247
           message.success(intl.get("message.success"));
248
         }
248
         }
249
-        if (isFunction(cb)) cb();
249
+        if (isFunction(cb)) cb(response.data);
250
         // 将数据写入到 list 中
250
         // 将数据写入到 list 中
251
         // 临时插入
251
         // 临时插入
252
         // 等到获取数据之后,删除临时数据
252
         // 等到获取数据之后,删除临时数据
305
         if (this.props.showAlertReply) {
305
         if (this.props.showAlertReply) {
306
           message.success(intl.get("message.replySuccess"));
306
           message.success(intl.get("message.replySuccess"));
307
         }
307
         }
308
-        if (isFunction(cb)) cb();
308
+        if (isFunction(cb)) cb(response.data);
309
         // 将数据写入到 list 中
309
         // 将数据写入到 list 中
310
         // 临时插入
310
         // 临时插入
311
         // 等到获取数据之后,删除临时数据
311
         // 等到获取数据之后,删除临时数据

+ 10
- 9
src/components/CommentInput/index.js View File

36
         cb
36
         cb
37
       );
37
       );
38
     } else if (action === "reply") {
38
     } else if (action === "reply") {
39
-      this.props.app.sCreateReply(
40
-        {
41
-          comment_id: commentId,
42
-          content: value,
43
-          business_user_id: userId
44
-        },
45
-        () => callback && callback()
46
-      );
39
+      console.log("[[[", callback);
40
+      // this.props.app.sCreateReply(
41
+      //   {
42
+      //     comment_id: commentId,
43
+      //     content: value,
44
+      //     business_user_id: userId
45
+      //   },
46
+      //   (data) => callback && callback(data)
47
+      // );
47
     } else if (action === "replyToReply") {
48
     } else if (action === "replyToReply") {
48
       this.props.app.sCreateReply(
49
       this.props.app.sCreateReply(
49
         {
50
         {
52
           reply_id: replyId,
53
           reply_id: replyId,
53
           business_user_id: userId
54
           business_user_id: userId
54
         },
55
         },
55
-        () => callback && callback()
56
+        data => callback && callback(data)
56
       );
57
       );
57
     }
58
     }
58
   }
59
   }

+ 12
- 6
src/components/ContentItem/index.js View File

61
     });
61
     });
62
   }
62
   }
63
 
63
 
64
+  handleUserAvaClick = () => {
65
+    const { user_id } = this.props;
66
+    const { userAvaClick } = this.props.app;
67
+    if (userAvaClick) {
68
+      userAvaClick(user_id);
69
+    }
70
+  };
71
+
64
   renderTextWithReply(text, content) {
72
   renderTextWithReply(text, content) {
65
     let newText = text;
73
     let newText = text;
66
     const { reply } = content;
74
     const { reply } = content;
94
       user_id
102
       user_id
95
     } = this.props;
103
     } = this.props;
96
 
104
 
97
-    const { locale, userAvaClick, showHoverCard } = this.props.app;
105
+    const { locale, showHoverCard } = this.props.app;
98
     const { showInput } = this.state;
106
     const { showInput } = this.state;
99
 
107
 
100
     let newContent = content.content;
108
     let newContent = content.content;
147
                 style={{
155
                 style={{
148
                   backgroundImage: `url(${content.user_avatar || avatar})`
156
                   backgroundImage: `url(${content.user_avatar || avatar})`
149
                 }}
157
                 }}
150
-                onClick={() => userAvaClick(user_id)}
158
+                onClick={this.handleUserAvaClick}
151
               />
159
               />
152
             </Popover>
160
             </Popover>
153
           ) : (
161
           ) : (
156
               style={{
164
               style={{
157
                 backgroundImage: `url(${content.user_avatar || avatar})`
165
                 backgroundImage: `url(${content.user_avatar || avatar})`
158
               }}
166
               }}
159
-              onClick={() => {
160
-                userAvaClick(user_id);
161
-              }}
167
+              onClick={this.handleUserAvaClick}
162
             />
168
             />
163
           )}
169
           )}
164
         </div>
170
         </div>
168
               {content.user_name || "暂无昵称"}
174
               {content.user_name || "暂无昵称"}
169
             </a> */}
175
             </a> */}
170
             <strong
176
             <strong
171
-              onClick={() => userAvaClick(user_id)}
177
+              onClick={this.handleUserAvaClick}
172
               style={{ cursor: "pointer" }}
178
               style={{ cursor: "pointer" }}
173
             >
179
             >
174
               {content.user_name || intl.get("comment.tourist")}
180
               {content.user_name || intl.get("comment.tourist")}

+ 5
- 0
src/components/Editor/Upload.css View File

7
   margin-top: 8px;
7
   margin-top: 8px;
8
   color: #666;
8
   color: #666;
9
 }
9
 }
10
+
11
+.upload-img-preview .ant-modal-close {
12
+  top: -10px;
13
+  right: -15px;
14
+}

+ 1
- 0
src/components/Editor/Upload.js View File

124
           {fileList.length >= maxUpload ? null : uploadButton}
124
           {fileList.length >= maxUpload ? null : uploadButton}
125
         </Upload>
125
         </Upload>
126
         <Modal
126
         <Modal
127
+          className="upload-img-preview"
127
           visible={previewVisible}
128
           visible={previewVisible}
128
           footer={null}
129
           footer={null}
129
           onCancel={this.handleCancel}
130
           onCancel={this.handleCancel}

+ 4
- 4
src/components/Editor/index.js View File

147
       Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
147
       Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
148
         res => {
148
         res => {
149
           if (!(res === false)) {
149
           if (!(res === false)) {
150
-            this.props.onSubmit({ text: value, files }, () => {
150
+            this.props.onSubmit({ text: value, files }, res => {
151
               this.resetState();
151
               this.resetState();
152
               if (this.props.onCommentSuccess) {
152
               if (this.props.onCommentSuccess) {
153
-                this.props.onCommentSuccess();
153
+                this.props.onCommentSuccess(res);
154
               }
154
               }
155
             });
155
             });
156
           }
156
           }
157
         }
157
         }
158
       );
158
       );
159
     } else {
159
     } else {
160
-      this.props.onSubmit({ text: value, files }, () => {
160
+      this.props.onSubmit({ text: value, files }, res => {
161
         this.resetState();
161
         this.resetState();
162
         if (this.props.onCommentSuccess) {
162
         if (this.props.onCommentSuccess) {
163
-          this.props.onCommentSuccess();
163
+          this.props.onCommentSuccess(res);
164
         }
164
         }
165
       });
165
       });
166
     }
166
     }

+ 5
- 1
src/index.js View File

123
     onCountChange: c => {
123
     onCountChange: c => {
124
       console.log(c);
124
       console.log(c);
125
     },
125
     },
126
-    editorProps: {}
126
+    editorProps: {
127
+      onCommentSuccess: data => {
128
+        console.log(data);
129
+      }
130
+    }
127
   });
131
   });
128
 }
132
 }
129
 
133