Browse Source

增加busness_user_id参数

narrowizard 5 years ago
parent
commit
e7cce410b7

+ 3
- 0
CHANGELOG.md View File

@@ -1,5 +1,8 @@
1 1
 # CHANGELOG
2 2
 
3
+## 1.0.1
4
+- [x] App增加business_user_id属性
5
+
3 6
 ## 1.0.0
4 7
 
5 8
 - [x] 完成通用评论国际化

+ 46
- 46
README.md View File

@@ -188,55 +188,55 @@ main();
188 188
 - 标记了`deprecated`的配置项表示不推荐使用,并且可能在将来版本中不再受支持。
189 189
 
190 190
 
191
-| props            | type           | default                            | required | description                                                                           |
192
-| ---------------- | -------------- | ---------------------------------- | -------- | ------------------------------------------------------------------------------------- |
193
-| type             | number         |                                    | true     | 评论的 type                                                                           |
194
-| businessId       | string         |                                    | true     | 评论的 business id                                                                    |
195
-| API              | string         | http://api.links123.net/comment/v1 | false    | API 前缀                                                                              |
196
-| showList         | boolean        | true                               | false    | 是否显示评论列表                                                                      |
197
-| showEditor       | boolean        | true                               | false    | 是否显示评论输入框                                                                    |
198
-| showAlertComment | boolean        | false                              | false    | 评论成功之后,是否通过 Antd 的 Message 组件进行提示                                   |
199
-| showAlertReply   | boolean        | false                              | false    | 回复成功之后,是否通过 Antd 的 Message 组件进行提示                                   |
200
-| showAlertFavor   | boolean        | false                              | false    | 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示                          |
201
-| showError        | boolean        | true                               | false    | 是否使用Antd的Message组件提示错误信息                                                 |
202
-| onError          | function(msg)  |                                    | false    | 错误回调, 出错了会被调用                                                              |
203
-| userId           | number         |                                    | false    | 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮     |
204
-| token            | string         |                                    | false    | [deprecated] token,用于身份认证,非必须。默认使用 cookie                             |
205
-| pageType         | string         | more                               | false    | 分页类别, more-加载更多 pagination-页码                                              |
206
-| page             | number         |                                    | false    | 页码受控模式,如果传递了此参数,则需要通过onPageChange回调手动维护page.                 |
207
-| limit             | number         |10                                  | false    | 一次加载的评论数量            |
208
-| onGetMoreBtnClick      | function() |                                    | false    | 点击查看更多按钮的回调                            |
209
-| onPageChange     | function(page) |                                    | false    | 页码发生变化时的回调,注意:分页数据获取还是在组件内部处理的                            |
210
-| onDelete         | function(type) |                                    | false    | 评论或回复删除成功后的回调, type: "comment" \| "reply" , 用于区分删除的是评论还是回复 |
211
-| locales          | string         | 语言                                | false    | 语言,zh-CN/en-US。默认根据 url 中的 lang 参数来获取。所以一般情况可不传入       
212
-
191
+| props             | type           | default                            | required | description                                       |                          |
192
+|-------------------|----------------|------------------------------------|----------|---------------------------------------------------|--------------------------|
193
+| type              | number         |                                    | true     | 评论的 type                                          |                          |
194
+| businessId        | string         |                                    | true     | 评论的 business id                                   |                          |
195
+| API               | string         | http://api.links123.net/comment/v1 | false    | API 前缀                                            |                          |
196
+| showList          | boolean        | true                               | false    | 是否显示评论列表                                          |                          |
197
+| showEditor        | boolean        | true                               | false    | 是否显示评论输入框                                         |                          |
198
+| showAlertComment  | boolean        | false                              | false    | 评论成功之后,是否通过 Antd 的 Message 组件进行提示                 |                          |
199
+| showAlertReply    | boolean        | false                              | false    | 回复成功之后,是否通过 Antd 的 Message 组件进行提示                 |                          |
200
+| showAlertFavor    | boolean        | false                              | false    | 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示            |                          |
201
+| showError         | boolean        | true                               | false    | 是否使用Antd的Message组件提示错误信息                          |                          |
202
+| onError           | function(msg)  |                                    | false    | 错误回调, 出错了会被调用                                     |                          |
203
+| userId            | number         |                                    | false    | 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮 |                          |
204
+| token             | string         |                                    | false    | [deprecated] token,用于身份认证,非必须。默认使用 cookie         |                          |
205
+| pageType          | string         | more                               | false    | 分页类别, more-加载更多 pagination-页码                     |                          |
206
+| page              | number         |                                    | false    | 页码受控模式,如果传递了此参数,则需要通过onPageChange回调手动维护page.      |                          |
207
+| limit             | number         | 10                                 | false    | 一次加载的评论数量                                         |                          |
208
+| onGetMoreBtnClick | function()     |                                    | false    | 点击查看更多按钮的回调                                       |                          |
209
+| onPageChange      | function(page) |                                    | false    | 页码发生变化时的回调,注意:分页数据获取还是在组件内部处理的                    |                          |
210
+| onDelete          | function(type) |                                    | false    | 评论或回复删除成功后的回调, type: "comment" \                  | "reply" , 用于区分删除的是评论还是回复 |
211
+| locales           | string         | 语言                                 | false    |                                                   |                          |
212
+| businessUserId    | number         |                                    | false    | 评论目标的用户id, 用于发送通知                                 |                          |
213 213
 
214 214
 ## Editor
215 215
 
216
-| props               | type                            | default       | required | description                                                                                       |
217
-| ------------------- | ------------------------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------- |
218
-| rows                | number                          | 5             | false    | 编辑器的高度。默认情况下,回复评论/回复回复的编辑器会比评论的编辑器高度小一行                     |
219
-| placeholder         | string                          | 说点什么吧... | false    | 评论的中的提示文字                                                                                |
220
-| showEmoji           | boolean                         | true          | false    | 是否显示 Toolbar 中表情工具                                                                       |
221
-| showUpload          | boolean                         | true          | false    | 是否显示 Toolbar 中 上传图片工具                                                                  |
222
-| maxUpload           | number                          | 1             | false    | 最大能够上传的图片数量                                                                            |
223
-| value               | string                          |               | false    | 编辑器的值。如果设置了该属性,则编辑器变为受控组件,需要父组件来维护 value                        |
224
-| onChange            | function(value)                 |               | false    | 编辑器内容改变的回调函数                                                                          |
225
-| onSubmit            | function({ text, files })       |               | false    | 点击提交按钮的回调函数,text 为编辑器的文本,files 为上传的文件列表                               |
226
-| beforeSubmit        | function ({text,files}):Promise |               | false    | 点击提交按钮后的钩子, 若Promise resolve false则不触发onSubmit函数, 主要用于控制默认的submit行为   |
227
-| onCommentSuccess    | function()                      |               | false    | 提交评论成功后的回调                                                                              |
228
-| btnSubmitText       | string                          | 发表          | false    | 提交按钮的文字                                                                                    |
229
-| btnLoading          | boolean                         | false         | false    | 按钮是否正在加载中                                                                                |
230
-| btnDisable          | boolean                         | false         | false    | 按钮是否禁用                                                                                      |
231
-| button              | ReactNode                       |               | false    | 按钮组件。如果上面几个 btn 相关的属性都无法满足要求,则可以使用 button 来自定义提交编辑器值的按钮 |
232
-| emojiToolIcon       | ReactNode                       |               | false    | Toolbar 中表情的图标                                                                              |
233
-| imageToolIcon       | ReactNode                       |               | false    | Toolbar 中上传文件的图标                                                                          |
234
-| onRef               | function                        |               | false    | 传递子组件的引用                                                                                  |
235
-| closeUploadWhenBlur | boolean                         |               | false    | 当 upload 失去焦点(鼠标点击非 Upload 的区域)的时候,是否自动关闭 Popover                        |
236
-| showError           | boolean                         | true          | false    | 是否使用Antd的Message组件提示错误信息, 主要是上传图片出错的情况                                   |
237
-| onError             | function(msg,{response})        |               | false    | 错误回调, 出错了会被调用, 主要是上传图片出错的情况                                                |
238
-| maxLength           | number                          | 140           | false    | 限制最大输入字数                                                                                  |
239
-| autoFocus           | boolean                         | false         | false    | 编辑器自动聚焦                                                                                    |
216
+| props               | type                            | default  | required | description                                                         |
217
+|---------------------|---------------------------------|----------|----------|---------------------------------------------------------------------|
218
+| rows                | number                          | 5        | false    | 编辑器的高度。默认情况下,回复评论/回复回复的编辑器会比评论的编辑器高度小一行                             |
219
+| placeholder         | string                          | 说点什么吧... | false    | 评论的中的提示文字                                                           |
220
+| showEmoji           | boolean                         | true     | false    | 是否显示 Toolbar 中表情工具                                                  |
221
+| showUpload          | boolean                         | true     | false    | 是否显示 Toolbar 中 上传图片工具                                               |
222
+| maxUpload           | number                          | 1        | false    | 最大能够上传的图片数量                                                         |
223
+| value               | string                          |          | false    | 编辑器的值。如果设置了该属性,则编辑器变为受控组件,需要父组件来维护 value                            |
224
+| onChange            | function(value)                 |          | false    | 编辑器内容改变的回调函数                                                        |
225
+| onSubmit            | function({ text, files })       |          | false    | 点击提交按钮的回调函数,text 为编辑器的文本,files 为上传的文件列表                             |
226
+| beforeSubmit        | function ({text,files}):Promise |          | false    | 点击提交按钮后的钩子, 若Promise resolve false则不触发onSubmit函数, 主要用于控制默认的submit行为 |
227
+| onCommentSuccess    | function()                      |          | false    | 提交评论成功后的回调                                                          |
228
+| btnSubmitText       | string                          | 发表       | false    | 提交按钮的文字                                                             |
229
+| btnLoading          | boolean                         | false    | false    | 按钮是否正在加载中                                                           |
230
+| btnDisable          | boolean                         | false    | false    | 按钮是否禁用                                                              |
231
+| button              | ReactNode                       |          | false    | 按钮组件。如果上面几个 btn 相关的属性都无法满足要求,则可以使用 button 来自定义提交编辑器值的按钮             |
232
+| emojiToolIcon       | ReactNode                       |          | false    | Toolbar 中表情的图标                                                      |
233
+| imageToolIcon       | ReactNode                       |          | false    | Toolbar 中上传文件的图标                                                    |
234
+| onRef               | function                        |          | false    | 传递子组件的引用                                                            |
235
+| closeUploadWhenBlur | boolean                         |          | false    | 当 upload 失去焦点(鼠标点击非 Upload 的区域)的时候,是否自动关闭 Popover                   |
236
+| showError           | boolean                         | true     | false    | 是否使用Antd的Message组件提示错误信息, 主要是上传图片出错的情况                              |
237
+| onError             | function(msg,{response})        |          | false    | 错误回调, 出错了会被调用, 主要是上传图片出错的情况                                         |
238
+| maxLength           | number                          | 140      | false    | 限制最大输入字数                                                            |
239
+| autoFocus           | boolean                         | false    | false    | 编辑器自动聚焦                                                             |
240 240
 
241 241
 
242 242
 ### 什么时候不要使用 value/onChange/onSubmit

+ 1
- 1
assets/example.html View File

@@ -20,7 +20,7 @@
20 20
   </div>
21 21
   
22 22
   <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"></script>
23
-  <script type="text/javascript" src="./static/js/main.6d72baad.js"></script>
23
+  <script type="text/javascript" src="./static/js/main.d5cd277c.js"></script>
24 24
   <script type="text/javascript" src="example.js"></script>
25 25
 </body>
26 26
 </html>

+ 0
- 2
assets/static/js/main.6d72baad.js
File diff suppressed because it is too large
View File


+ 0
- 1
assets/static/js/main.6d72baad.js.map
File diff suppressed because it is too large
View File


+ 2
- 0
assets/static/js/main.d5cd277c.js
File diff suppressed because it is too large
View File


+ 1
- 0
assets/static/js/main.d5cd277c.js.map
File diff suppressed because it is too large
View File


+ 5
- 1
lib/App.js View File

@@ -336,13 +336,15 @@ var App = function (_Component) {
336 336
       var _props3 = this.props,
337 337
           API = _props3.API,
338 338
           type = _props3.type,
339
-          businessId = _props3.businessId;
339
+          businessId = _props3.businessId,
340
+          businessUserId = _props3.businessUserId;
340 341
 
341 342
       this.axios(API + "/comments", {
342 343
         method: "post",
343 344
         data: {
344 345
           type: type,
345 346
           business_id: businessId,
347
+          business_user_id: businessUserId,
346 348
           content: content
347 349
         },
348 350
         withCredentials: true
@@ -612,6 +614,7 @@ var App = function (_Component) {
612 614
 App.propTypes = {
613 615
   type: _propTypes2.default.number.isRequired, // 评论的 type
614 616
   businessId: _propTypes2.default.string.isRequired, // 评论的 business_id
617
+  businessUserId: _propTypes2.default.number,
615 618
   API: _propTypes2.default.string, // 评论的 API 前缀
616 619
   showList: _propTypes2.default.bool, // 是否显示评论列表
617 620
   showEditor: _propTypes2.default.bool, // 是否显示评论输入框
@@ -631,6 +634,7 @@ App.propTypes = {
631 634
 };
632 635
 
633 636
 App.defaultProps = {
637
+  businessUserId: 0,
634 638
   API: "//api.links123.net/comment/v1",
635 639
   showList: true,
636 640
   showEditor: true,

+ 1
- 1
lib/App.js.map
File diff suppressed because it is too large
View File


+ 5
- 2
lib/components/CommentInput/index.js View File

@@ -71,6 +71,7 @@ var CommentInput = function (_Component) {
71 71
           action = _props.action,
72 72
           commentId = _props.commentId,
73 73
           replyId = _props.replyId,
74
+          userId = _props.userId,
74 75
           callback = _props.callback;
75 76
 
76 77
       if (action === "comment") {
@@ -80,7 +81,8 @@ var CommentInput = function (_Component) {
80 81
       } else if (action === "reply") {
81 82
         this.props.app.sCreateReply({
82 83
           comment_id: commentId,
83
-          content: value
84
+          content: value,
85
+          business_user_id: userId
84 86
         }, function () {
85 87
           return callback && callback();
86 88
         });
@@ -88,7 +90,8 @@ var CommentInput = function (_Component) {
88 90
         this.props.app.sCreateReply({
89 91
           comment_id: commentId,
90 92
           content: value,
91
-          reply_id: replyId
93
+          reply_id: replyId,
94
+          business_user_id: userId
92 95
         }, function () {
93 96
           return callback && callback();
94 97
         });

+ 1
- 1
lib/components/CommentInput/index.js.map
File diff suppressed because it is too large
View File


+ 1
- 0
lib/components/ContentItem/index.js View File

@@ -347,6 +347,7 @@ var CommentItem = function (_Component) {
347 347
           action: action,
348 348
           replyId: replyId,
349 349
           commentId: commentId,
350
+          userId: content.user_id,
350 351
           callback: this.handleToggleInput
351 352
         })
352 353
       );

+ 1
- 1
lib/components/ContentItem/index.js.map
File diff suppressed because it is too large
View File


+ 1
- 0
lib/index.example.js View File

@@ -94,6 +94,7 @@ var Index = function (_Component) {
94 94
           page: this.state.page,
95 95
           onPageChange: this.onPageChange,
96 96
           pageType: "more",
97
+          businessUserId: 4,
97 98
           onError: function onError(msg, _ref2) {
98 99
             var response = _ref2.response;
99 100
 

+ 1
- 1
lib/index.example.js.map
File diff suppressed because it is too large
View File


+ 2
- 1
lib/index.js View File

@@ -61,7 +61,8 @@ window.renderComment = renderComment;
61 61
 renderComment({
62 62
   id: "root-comment",
63 63
   type: 1,
64
-  businessId: "test"
64
+  businessId: "test",
65
+  businessUserId: 4
65 66
 });
66 67
 
67 68
 // renderComment({

+ 1
- 1
lib/index.js.map View File

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/index.js"],"names":["Index","props","editorProps","renderComment","config","id","Error","type","businessId","console","warn","API","ReactDOM","render","document","getElementById","window"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;;;AACA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,aAAQ,WAAW,CAAnB,EAAsB,eAAtB,IAAoCA,MAAMC,WAA1C;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAC7B,MAAI,CAACA,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,gBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOG,IAAZ,EAAkB;AAChB,UAAM,IAAID,KAAJ,CAAU,kBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOI,UAAZ,EAAwB;AACtB;AACAJ,WAAOI,UAAP,GAAoB,MAApB;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAP,WAAOO,GAAP,GAAa,oCAAb;AACAF,YAAQC,IAAR,CACE,sDADF;AAGD;;AAEDE,qBAASC,MAAT,CAAgB,8BAAC,KAAD,EAAWT,MAAX,CAAhB,EAAuCU,SAASC,cAAT,CAAwBX,OAAOC,EAA/B,CAAvC;AACA;AACD;;AAEDW,OAAOb,aAAP,GAAuBA,aAAvB;;AAEAA,cAAc;AACZE,MAAI,cADQ;AAEZE,QAAM,CAFM;AAGZC,cAAY;AAHA,CAAd;;AAMA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport App, { Editor } from \"./App\";\r\n// import registerServiceWorker from \"./registerServiceWorker\";\r\n\r\nconst Index = props => (\r\n  <App showAlertComment showAlertReply showAlertFavor showError {...props}>\r\n    <Editor maxUpload={9} autoFocus {...props.editorProps} />\r\n  </App>\r\n);\r\n\r\n/**\r\n * 渲染评论组件\r\n * @param {object} config 编辑器配置\r\n *  - {string} id 渲染评论的DOM的 ID\r\n *  - {number} type 评论的 type\r\n *  - {string} businessId 评论的 businessId\r\n *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1\r\n */\r\nfunction renderComment(config) {\r\n  if (!config.id) {\r\n    throw new Error(\"id is required\");\r\n  }\r\n  if (!config.type) {\r\n    throw new Error(\"type is required\");\r\n  }\r\n  if (!config.businessId) {\r\n    // throw new Error(\"businessId is required\");\r\n    config.businessId = \"test\";\r\n    console.warn(\"没有传入 businessId 参数,默认使用: test\");\r\n  }\r\n  if (!config.API) {\r\n    // throw new Error(\"API is required\");\r\n    config.API = \"http://api.links123.net/comment/v1\";\r\n    console.warn(\r\n      \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\r\n    );\r\n  }\r\n\r\n  ReactDOM.render(<Index {...config} />, document.getElementById(config.id));\r\n  // registerServiceWorker();\r\n}\r\n\r\nwindow.renderComment = renderComment;\r\n\r\nrenderComment({\r\n  id: \"root-comment\",\r\n  type: 1,\r\n  businessId: \"test\"\r\n});\r\n\r\n// renderComment({\r\n//   id: \"root-comment\",\r\n//   type: 1,\r\n//   businessId: \"test\",\r\n//   API: 'http://api.links123.net/comment/v1',\r\n// });\r\n"]}
1
+{"version":3,"sources":["../src/index.js"],"names":["Index","props","editorProps","renderComment","config","id","Error","type","businessId","console","warn","API","ReactDOM","render","document","getElementById","window","businessUserId"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;;;AACA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,aAAQ,WAAW,CAAnB,EAAsB,eAAtB,IAAoCA,MAAMC,WAA1C;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAC7B,MAAI,CAACA,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,gBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOG,IAAZ,EAAkB;AAChB,UAAM,IAAID,KAAJ,CAAU,kBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOI,UAAZ,EAAwB;AACtB;AACAJ,WAAOI,UAAP,GAAoB,MAApB;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAP,WAAOO,GAAP,GAAa,oCAAb;AACAF,YAAQC,IAAR,CACE,sDADF;AAGD;;AAEDE,qBAASC,MAAT,CAAgB,8BAAC,KAAD,EAAWT,MAAX,CAAhB,EAAuCU,SAASC,cAAT,CAAwBX,OAAOC,EAA/B,CAAvC;AACA;AACD;;AAEDW,OAAOb,aAAP,GAAuBA,aAAvB;;AAEAA,cAAc;AACZE,MAAI,cADQ;AAEZE,QAAM,CAFM;AAGZC,cAAY,MAHA;AAIZS,kBAAgB;AAJJ,CAAd;;AAOA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport App, { Editor } from \"./App\";\r\n// import registerServiceWorker from \"./registerServiceWorker\";\r\n\r\nconst Index = props => (\r\n  <App showAlertComment showAlertReply showAlertFavor showError {...props}>\r\n    <Editor maxUpload={9} autoFocus {...props.editorProps} />\r\n  </App>\r\n);\r\n\r\n/**\r\n * 渲染评论组件\r\n * @param {object} config 编辑器配置\r\n *  - {string} id 渲染评论的DOM的 ID\r\n *  - {number} type 评论的 type\r\n *  - {string} businessId 评论的 businessId\r\n *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1\r\n */\r\nfunction renderComment(config) {\r\n  if (!config.id) {\r\n    throw new Error(\"id is required\");\r\n  }\r\n  if (!config.type) {\r\n    throw new Error(\"type is required\");\r\n  }\r\n  if (!config.businessId) {\r\n    // throw new Error(\"businessId is required\");\r\n    config.businessId = \"test\";\r\n    console.warn(\"没有传入 businessId 参数,默认使用: test\");\r\n  }\r\n  if (!config.API) {\r\n    // throw new Error(\"API is required\");\r\n    config.API = \"http://api.links123.net/comment/v1\";\r\n    console.warn(\r\n      \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\r\n    );\r\n  }\r\n\r\n  ReactDOM.render(<Index {...config} />, document.getElementById(config.id));\r\n  // registerServiceWorker();\r\n}\r\n\r\nwindow.renderComment = renderComment;\r\n\r\nrenderComment({\r\n  id: \"root-comment\",\r\n  type: 1,\r\n  businessId: \"test\",\r\n  businessUserId: 4,\r\n});\r\n\r\n// renderComment({\r\n//   id: \"root-comment\",\r\n//   type: 1,\r\n//   businessId: \"test\",\r\n//   API: 'http://api.links123.net/comment/v1',\r\n// });\r\n"]}

+ 4
- 1
src/App.js View File

@@ -220,12 +220,13 @@ class App extends Component {
220 220
   sCreateComment({ content } = {}, cb) {
221 221
     if (!content) return this.error(intl.get("message.notNull"));
222 222
     this.handleChangeLoading("sCreateComment", true);
223
-    const { API, type, businessId } = this.props;
223
+    const { API, type, businessId, businessUserId } = this.props;
224 224
     this.axios(`${API}/comments`, {
225 225
       method: "post",
226 226
       data: {
227 227
         type,
228 228
         business_id: businessId,
229
+        business_user_id: businessUserId,
229 230
         content
230 231
       },
231 232
       withCredentials: true
@@ -481,6 +482,7 @@ class App extends Component {
481 482
 App.propTypes = {
482 483
   type: PropTypes.number.isRequired, // 评论的 type
483 484
   businessId: PropTypes.string.isRequired, // 评论的 business_id
485
+  businessUserId: PropTypes.number,
484 486
   API: PropTypes.string, // 评论的 API 前缀
485 487
   showList: PropTypes.bool, // 是否显示评论列表
486 488
   showEditor: PropTypes.bool, // 是否显示评论输入框
@@ -500,6 +502,7 @@ App.propTypes = {
500 502
 };
501 503
 
502 504
 App.defaultProps = {
505
+  businessUserId: 0,
503 506
   API: "//api.links123.net/comment/v1",
504 507
   showList: true,
505 508
   showEditor: true,

+ 5
- 3
src/components/CommentInput/index.js View File

@@ -27,7 +27,7 @@ class CommentInput extends Component {
27 27
       value = value.slice(0, -1);
28 28
     }
29 29
 
30
-    const { action, commentId, replyId, callback } = this.props;
30
+    const { action, commentId, replyId, userId, callback } = this.props;
31 31
     if (action === "comment") {
32 32
       this.props.app.sCreateComment(
33 33
         {
@@ -39,7 +39,8 @@ class CommentInput extends Component {
39 39
       this.props.app.sCreateReply(
40 40
         {
41 41
           comment_id: commentId,
42
-          content: value
42
+          content: value,
43
+          business_user_id: userId
43 44
         },
44 45
         () => callback && callback()
45 46
       );
@@ -48,7 +49,8 @@ class CommentInput extends Component {
48 49
         {
49 50
           comment_id: commentId,
50 51
           content: value,
51
-          reply_id: replyId
52
+          reply_id: replyId,
53
+          business_user_id: userId
52 54
         },
53 55
         () => callback && callback()
54 56
       );

+ 1
- 0
src/components/ContentItem/index.js View File

@@ -259,6 +259,7 @@ class CommentItem extends Component {
259 259
             action={action}
260 260
             replyId={replyId}
261 261
             commentId={commentId}
262
+            userId={content.user_id}
262 263
             callback={this.handleToggleInput}
263 264
           />
264 265
         )}

+ 1
- 0
src/index.example.js View File

@@ -53,6 +53,7 @@ class Index extends Component {
53 53
         page={this.state.page}
54 54
         onPageChange={this.onPageChange}
55 55
         pageType="more"
56
+        businessUserId={4}
56 57
         onError={(msg, { response }) => {
57 58
           if (response.status === 401) {
58 59
             console.log("unlogined");

+ 2
- 1
src/index.js View File

@@ -46,7 +46,8 @@ window.renderComment = renderComment;
46 46
 renderComment({
47 47
   id: "root-comment",
48 48
   type: 1,
49
-  businessId: "test"
49
+  businessId: "test",
50
+  businessUserId: 4
50 51
 });
51 52
 
52 53
 // renderComment({