|
@@ -1,11 +1,11 @@
|
1
|
|
-"use strict";
|
|
1
|
+'use strict';
|
2
|
2
|
|
3
|
3
|
Object.defineProperty(exports, "__esModule", {
|
4
|
4
|
value: true
|
5
|
5
|
});
|
6
|
6
|
exports.RenderText = exports.Editor = undefined;
|
7
|
7
|
|
8
|
|
-var _message2 = require("antd/es/message");
|
|
8
|
+var _message2 = require('antd/es/message');
|
9
|
9
|
|
10
|
10
|
var _message3 = _interopRequireDefault(_message2);
|
11
|
11
|
|
|
@@ -13,57 +13,57 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
|
13
|
13
|
|
14
|
14
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
15
|
15
|
|
16
|
|
-require("antd/es/message/style");
|
|
16
|
+require('antd/es/message/style');
|
17
|
17
|
|
18
|
|
-var _react = require("react");
|
|
18
|
+var _react = require('react');
|
19
|
19
|
|
20
|
20
|
var _react2 = _interopRequireDefault(_react);
|
21
|
21
|
|
22
|
|
-var _propTypes = require("prop-types");
|
|
22
|
+var _propTypes = require('prop-types');
|
23
|
23
|
|
24
|
24
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
25
|
25
|
|
26
|
|
-var _axios = require("axios");
|
|
26
|
+var _axios = require('axios');
|
27
|
27
|
|
28
|
28
|
var _axios2 = _interopRequireDefault(_axios);
|
29
|
29
|
|
30
|
|
-var _jsCookie = require("js-cookie");
|
|
30
|
+var _jsCookie = require('js-cookie');
|
31
|
31
|
|
32
|
32
|
var _jsCookie2 = _interopRequireDefault(_jsCookie);
|
33
|
33
|
|
34
|
|
-var _reactIntlUniversal = require("react-intl-universal");
|
|
34
|
+var _reactIntlUniversal = require('react-intl-universal');
|
35
|
35
|
|
36
|
36
|
var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
|
37
|
37
|
|
38
|
|
-var _constant = require("./constant");
|
|
38
|
+var _constant = require('./constant');
|
39
|
39
|
|
40
|
|
-var _Comment = require("./Comment");
|
|
40
|
+var _Comment = require('./Comment');
|
41
|
41
|
|
42
|
|
-var _helper = require("./helper");
|
|
42
|
+var _helper = require('./helper');
|
43
|
43
|
|
44
|
|
-var _CommentInput = require("./components/CommentInput");
|
|
44
|
+var _CommentInput = require('./components/CommentInput');
|
45
|
45
|
|
46
|
46
|
var _CommentInput2 = _interopRequireDefault(_CommentInput);
|
47
|
47
|
|
48
|
|
-var _CommentList = require("./components/CommentList");
|
|
48
|
+var _CommentList = require('./components/CommentList');
|
49
|
49
|
|
50
|
50
|
var _CommentList2 = _interopRequireDefault(_CommentList);
|
51
|
51
|
|
52
|
|
-var _Editor = require("./components/Editor");
|
|
52
|
+var _Editor = require('./components/Editor');
|
53
|
53
|
|
54
|
54
|
var _Editor2 = _interopRequireDefault(_Editor);
|
55
|
55
|
|
56
|
|
-var _RenderText = require("./components/RenderText");
|
|
56
|
+var _RenderText = require('./components/RenderText');
|
57
|
57
|
|
58
|
58
|
var _RenderText2 = _interopRequireDefault(_RenderText);
|
59
|
59
|
|
60
|
|
-var _EditComment = require("./components/EditComment/EditComment");
|
|
60
|
+var _EditComment = require('./components/EditComment/EditComment');
|
61
|
61
|
|
62
|
62
|
var _EditComment2 = _interopRequireDefault(_EditComment);
|
63
|
63
|
|
64
|
|
-var _lang = require("./lang");
|
|
64
|
+var _lang = require('./lang');
|
65
|
65
|
|
66
|
|
-require("./App.css");
|
|
66
|
+require('./App.css');
|
67
|
67
|
|
68
|
68
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
69
|
69
|
|
|
@@ -94,13 +94,13 @@ var App = function (_Component) {
|
94
|
94
|
// 是否没有更多评论了
|
95
|
95
|
isNoMoreComment: false,
|
96
|
96
|
initDone: false,
|
97
|
|
- locale: "zh-CN",
|
|
97
|
+ locale: 'zh-CN',
|
98
|
98
|
editModalVisible: false,
|
99
|
|
- action: "",
|
100
|
|
- replyId: "",
|
101
|
|
- commentId: "",
|
102
|
|
- userId: "",
|
103
|
|
- content: "",
|
|
99
|
+ action: '',
|
|
100
|
+ replyId: '',
|
|
101
|
+ commentId: '',
|
|
102
|
+ userId: '',
|
|
103
|
+ content: '',
|
104
|
104
|
replyPage: 1,
|
105
|
105
|
emojiList: []
|
106
|
106
|
};
|
|
@@ -123,16 +123,16 @@ var App = function (_Component) {
|
123
|
123
|
}
|
124
|
124
|
|
125
|
125
|
_createClass(App, [{
|
126
|
|
- key: "componentWillMount",
|
|
126
|
+ key: 'componentWillMount',
|
127
|
127
|
value: function componentWillMount() {
|
128
|
128
|
this.axios = _axios2.default;
|
129
|
129
|
this.axios.defaults.withCredentials = true;
|
130
|
130
|
if (this.props.token) {
|
131
|
|
- this.axios.defaults.headers.common["Authorization"] = "Bearer " + this.props.token;
|
|
131
|
+ this.axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.props.token;
|
132
|
132
|
}
|
133
|
133
|
}
|
134
|
134
|
}, {
|
135
|
|
- key: "componentDidMount",
|
|
135
|
+ key: 'componentDidMount',
|
136
|
136
|
value: function componentDidMount() {
|
137
|
137
|
this.loadLocales();
|
138
|
138
|
this.loadEmoji();
|
|
@@ -145,27 +145,27 @@ var App = function (_Component) {
|
145
|
145
|
*/
|
146
|
146
|
|
147
|
147
|
}, {
|
148
|
|
- key: "loadLocales",
|
|
148
|
+ key: 'loadLocales',
|
149
|
149
|
value: function loadLocales() {
|
150
|
150
|
var _this2 = this;
|
151
|
151
|
|
152
|
152
|
var currentLocale = this.props.locales;
|
153
|
153
|
|
154
|
|
- var cookieLang = _jsCookie2.default.get("lnk_lang");
|
|
154
|
+ var cookieLang = _jsCookie2.default.get('lnk_lang');
|
155
|
155
|
if (!currentLocale) {
|
156
|
156
|
currentLocale = cookieLang || _reactIntlUniversal2.default.determineLocale({
|
157
|
|
- urlLocaleKey: "lang"
|
|
157
|
+ urlLocaleKey: 'lang'
|
158
|
158
|
});
|
159
|
159
|
}
|
160
|
160
|
currentLocale = _lang.SUPPORT_LOCALES.find(function (item) {
|
161
|
161
|
return item.value === currentLocale;
|
162
|
|
- }) ? currentLocale : "zh-CN";
|
163
|
|
- var version = require("./version.json").hash;
|
|
162
|
+ }) ? currentLocale : 'zh-CN';
|
|
163
|
+ var version = require('./version.json').hash;
|
164
|
164
|
// 使用绝对路径
|
165
|
|
- var languageURL = _constant.LANGUAGE_LINK + "/" + currentLocale + ".json?v=" + version;
|
|
165
|
+ var languageURL = _constant.LANGUAGE_LINK + '/' + currentLocale + '.json?v=' + version;
|
166
|
166
|
return fetch(languageURL).then(function (response) {
|
167
|
167
|
if (response.status >= 400) {
|
168
|
|
- throw new Error("Bad response from server");
|
|
168
|
+ throw new Error('Bad response from server');
|
169
|
169
|
}
|
170
|
170
|
return response.json();
|
171
|
171
|
}).then(function (data) {
|
|
@@ -184,21 +184,21 @@ var App = function (_Component) {
|
184
|
184
|
*/
|
185
|
185
|
|
186
|
186
|
}, {
|
187
|
|
- key: "loadEmoji",
|
|
187
|
+ key: 'loadEmoji',
|
188
|
188
|
value: function loadEmoji() {
|
189
|
189
|
var _this3 = this;
|
190
|
190
|
|
191
|
|
- this.axios.get(this.props.emojiAPI + "/emoticons").then(function (response) {
|
|
191
|
+ this.axios.get(this.props.emojiAPI + '/emoticons').then(function (response) {
|
192
|
192
|
var emojiMap = {};
|
193
|
193
|
response.data.list.forEach(function (item) {
|
194
|
194
|
emojiMap[item.name] = item.url;
|
195
|
195
|
});
|
196
|
|
- window.sessionStorage.setItem("emojiMap", JSON.stringify(emojiMap));
|
|
196
|
+ window.sessionStorage.setItem('emojiMap', JSON.stringify(emojiMap));
|
197
|
197
|
_this3.setState({ emojiList: response.data.list });
|
198
|
198
|
}).catch(this.errorHandler);
|
199
|
199
|
}
|
200
|
200
|
}, {
|
201
|
|
- key: "handleEdit",
|
|
201
|
+ key: 'handleEdit',
|
202
|
202
|
value: function handleEdit(_ref) {
|
203
|
203
|
var replyId = _ref.replyId,
|
204
|
204
|
commentId = _ref.commentId,
|
|
@@ -208,7 +208,7 @@ var App = function (_Component) {
|
208
|
208
|
|
209
|
209
|
this.setState({
|
210
|
210
|
editModalVisible: true,
|
211
|
|
- action: content.replies ? "comment" : content.reply ? "replyToReply" : "reply",
|
|
211
|
+ action: content.replies ? 'comment' : content.reply ? 'replyToReply' : 'reply',
|
212
|
212
|
replyId: replyId,
|
213
|
213
|
commentId: commentId,
|
214
|
214
|
userId: userId,
|
|
@@ -217,14 +217,14 @@ var App = function (_Component) {
|
217
|
217
|
});
|
218
|
218
|
}
|
219
|
219
|
}, {
|
220
|
|
- key: "handleClose",
|
|
220
|
+ key: 'handleClose',
|
221
|
221
|
value: function handleClose() {
|
222
|
222
|
this.setState({
|
223
|
223
|
editModalVisible: false
|
224
|
224
|
});
|
225
|
225
|
}
|
226
|
226
|
}, {
|
227
|
|
- key: "error",
|
|
227
|
+ key: 'error',
|
228
|
228
|
value: function error(msg) {
|
229
|
229
|
var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
230
|
230
|
|
|
@@ -236,7 +236,7 @@ var App = function (_Component) {
|
236
|
236
|
}
|
237
|
237
|
}
|
238
|
238
|
}, {
|
239
|
|
- key: "errorHandler",
|
|
239
|
+ key: 'errorHandler',
|
240
|
240
|
value: function errorHandler(error) {
|
241
|
241
|
var locale = this.state.locale;
|
242
|
242
|
|
|
@@ -259,7 +259,7 @@ var App = function (_Component) {
|
259
|
259
|
*/
|
260
|
260
|
|
261
|
261
|
}, {
|
262
|
|
- key: "handleChangeLoading",
|
|
262
|
+ key: 'handleChangeLoading',
|
263
|
263
|
value: function handleChangeLoading(key, value) {
|
264
|
264
|
var loading = this.state.loading;
|
265
|
265
|
|
|
@@ -272,24 +272,26 @@ var App = function (_Component) {
|
272
|
272
|
*/
|
273
|
273
|
|
274
|
274
|
}, {
|
275
|
|
- key: "sGetComment",
|
|
275
|
+ key: 'sGetComment',
|
276
|
276
|
value: function sGetComment() {
|
277
|
277
|
var _this4 = this;
|
278
|
278
|
|
279
|
279
|
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
280
|
280
|
_ref2$page = _ref2.page,
|
281
|
|
- page = _ref2$page === undefined ? 1 : _ref2$page;
|
|
281
|
+ page = _ref2$page === undefined ? 1 : _ref2$page,
|
|
282
|
+ _ref2$filterSpeak = _ref2.filterSpeak,
|
|
283
|
+ filterSpeak = _ref2$filterSpeak === undefined ? 0 : _ref2$filterSpeak;
|
282
|
284
|
|
283
|
285
|
var pageType = this.props.pageType;
|
284
|
286
|
|
285
|
|
- this.handleChangeLoading("sGetComment", true);
|
|
287
|
+ this.handleChangeLoading('sGetComment', true);
|
286
|
288
|
var _props = this.props,
|
287
|
289
|
API = _props.API,
|
288
|
290
|
type = _props.type,
|
289
|
291
|
businessId = _props.businessId,
|
290
|
292
|
limit = _props.limit;
|
291
|
293
|
|
292
|
|
- this.axios.get(API + "/comments?type=" + type + "&business_id=" + businessId + "&page=" + page + "&limit=" + limit).then(function (response) {
|
|
294
|
+ this.axios.get(API + '/comments?type=' + type + '&business_id=' + businessId + '&is_speak=' + filterSpeak + '&page=' + page + '&limit=' + limit).then(function (response) {
|
293
|
295
|
var _response$data = response.data,
|
294
|
296
|
list = _response$data.list,
|
295
|
297
|
page = _response$data.page,
|
|
@@ -299,7 +301,7 @@ var App = function (_Component) {
|
299
|
301
|
var newList = list;
|
300
|
302
|
var oldList = _this4.state.list;
|
301
|
303
|
|
302
|
|
- if (pageType === "more") {
|
|
304
|
+ if (pageType === 'more') {
|
303
|
305
|
if (page > 1) {
|
304
|
306
|
// 删除临时数据
|
305
|
307
|
oldList = oldList.filter(function (o) {
|
|
@@ -307,7 +309,7 @@ var App = function (_Component) {
|
307
|
309
|
});
|
308
|
310
|
newList = oldList.concat(newList);
|
309
|
311
|
}
|
310
|
|
- } else if (pageType === "pagination") {
|
|
312
|
+ } else if (pageType === 'pagination') {
|
311
|
313
|
// TODO 滚动到顶部
|
312
|
314
|
window.scrollTo(0, 0);
|
313
|
315
|
}
|
|
@@ -319,13 +321,13 @@ var App = function (_Component) {
|
319
|
321
|
});
|
320
|
322
|
_this4.props.onCountChange(total);
|
321
|
323
|
} else {
|
322
|
|
- _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreComment"));
|
|
324
|
+ _message3.default.info(_reactIntlUniversal2.default.get('message.noMoreComment'));
|
323
|
325
|
_this4.setState({
|
324
|
326
|
isNoMoreComment: true
|
325
|
327
|
});
|
326
|
328
|
}
|
327
|
329
|
}).catch(this.errorHandler).finally(function () {
|
328
|
|
- _this4.handleChangeLoading("sGetComment", false);
|
|
330
|
+ _this4.handleChangeLoading('sGetComment', false);
|
329
|
331
|
});
|
330
|
332
|
}
|
331
|
333
|
|
|
@@ -334,7 +336,7 @@ var App = function (_Component) {
|
334
|
336
|
*/
|
335
|
337
|
|
336
|
338
|
}, {
|
337
|
|
- key: "sGetReply",
|
|
339
|
+ key: 'sGetReply',
|
338
|
340
|
value: function sGetReply() {
|
339
|
341
|
var _this5 = this;
|
340
|
342
|
|
|
@@ -343,14 +345,14 @@ var App = function (_Component) {
|
343
|
345
|
_ref3$page = _ref3.page,
|
344
|
346
|
page = _ref3$page === undefined ? 1 : _ref3$page;
|
345
|
347
|
|
346
|
|
- this.handleChangeLoading("sGetReply", true);
|
|
348
|
+ this.handleChangeLoading('sGetReply', true);
|
347
|
349
|
var _props2 = this.props,
|
348
|
350
|
API = _props2.API,
|
349
|
351
|
limit = _props2.limit;
|
350
|
352
|
|
351
|
|
- this.axios.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + limit).then(function (response) {
|
|
353
|
+ this.axios.get(API + '/replies?comment_id=' + commentId + '&page=' + page + '&limit=' + limit).then(function (response) {
|
352
|
354
|
if (!response.data.list) {
|
353
|
|
- _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreData"));
|
|
355
|
+ _message3.default.info(_reactIntlUniversal2.default.get('message.noMoreData'));
|
354
|
356
|
}
|
355
|
357
|
var list = _this5.state.list.map(function (item) {
|
356
|
358
|
if (item.id === commentId) {
|
|
@@ -376,7 +378,7 @@ var App = function (_Component) {
|
376
|
378
|
});
|
377
|
379
|
_this5.setState({ list: list });
|
378
|
380
|
}).catch(this.errorHandler).finally(function () {
|
379
|
|
- _this5.handleChangeLoading("sGetReply", false);
|
|
381
|
+ _this5.handleChangeLoading('sGetReply', false);
|
380
|
382
|
});
|
381
|
383
|
}
|
382
|
384
|
|
|
@@ -386,7 +388,7 @@ var App = function (_Component) {
|
386
|
388
|
*/
|
387
|
389
|
|
388
|
390
|
}, {
|
389
|
|
- key: "sCreateComment",
|
|
391
|
+ key: 'sCreateComment',
|
390
|
392
|
value: function sCreateComment() {
|
391
|
393
|
var _this6 = this;
|
392
|
394
|
|
|
@@ -395,16 +397,16 @@ var App = function (_Component) {
|
395
|
397
|
|
396
|
398
|
var cb = arguments[1];
|
397
|
399
|
|
398
|
|
- if (!content) return this.error(_reactIntlUniversal2.default.get("message.notNull"));
|
399
|
|
- this.handleChangeLoading("sCreateComment", true);
|
|
400
|
+ if (!content) return this.error(_reactIntlUniversal2.default.get('message.notNull'));
|
|
401
|
+ this.handleChangeLoading('sCreateComment', true);
|
400
|
402
|
var _props3 = this.props,
|
401
|
403
|
API = _props3.API,
|
402
|
404
|
type = _props3.type,
|
403
|
405
|
businessId = _props3.businessId,
|
404
|
406
|
businessUserId = _props3.businessUserId;
|
405
|
407
|
|
406
|
|
- this.axios(API + "/comments", {
|
407
|
|
- method: "post",
|
|
408
|
+ this.axios(API + '/comments', {
|
|
409
|
+ method: 'post',
|
408
|
410
|
data: {
|
409
|
411
|
type: type,
|
410
|
412
|
business_id: businessId,
|
|
@@ -414,7 +416,7 @@ var App = function (_Component) {
|
414
|
416
|
withCredentials: true
|
415
|
417
|
}).then(function (response) {
|
416
|
418
|
if (_this6.props.showAlertComment) {
|
417
|
|
- _message3.default.success(_reactIntlUniversal2.default.get("message.success"));
|
|
419
|
+ _message3.default.success(_reactIntlUniversal2.default.get('message.success'));
|
418
|
420
|
}
|
419
|
421
|
if ((0, _helper.isFunction)(cb)) cb(response.data);
|
420
|
422
|
// 将数据写入到 list 中
|
|
@@ -434,7 +436,7 @@ var App = function (_Component) {
|
434
|
436
|
_this6.props.onCommentFail(error.response.status);
|
435
|
437
|
_this6.errorHandler(error);
|
436
|
438
|
}).finally(function () {
|
437
|
|
- _this6.handleChangeLoading("sCreateComment", false);
|
|
439
|
+ _this6.handleChangeLoading('sCreateComment', false);
|
438
|
440
|
});
|
439
|
441
|
}
|
440
|
442
|
|
|
@@ -443,15 +445,15 @@ var App = function (_Component) {
|
443
|
445
|
*/
|
444
|
446
|
|
445
|
447
|
}, {
|
446
|
|
- key: "sDeleteComment",
|
|
448
|
+ key: 'sDeleteComment',
|
447
|
449
|
value: function sDeleteComment(commentId) {
|
448
|
450
|
var _this7 = this;
|
449
|
451
|
|
450
|
|
- this.handleChangeLoading("sDeleteComment", true);
|
|
452
|
+ this.handleChangeLoading('sDeleteComment', true);
|
451
|
453
|
var API = this.props.API;
|
452
|
454
|
|
453
|
|
- this.axios(API + "/comments/" + commentId, {
|
454
|
|
- method: "delete",
|
|
455
|
+ this.axios(API + '/comments/' + commentId, {
|
|
456
|
+ method: 'delete',
|
455
|
457
|
withCredentials: true
|
456
|
458
|
}).then(function () {
|
457
|
459
|
var _state2 = _this7.state,
|
|
@@ -468,7 +470,7 @@ var App = function (_Component) {
|
468
|
470
|
_this7.props.onDelete(_constant.COMMENT_TYPE.COMMENT, deletedItem);
|
469
|
471
|
_this7.props.onCountChange(total - 1);
|
470
|
472
|
}).catch(this.errorHandler).finally(function () {
|
471
|
|
- _this7.handleChangeLoading("sDeleteComment", false);
|
|
473
|
+ _this7.handleChangeLoading('sDeleteComment', false);
|
472
|
474
|
});
|
473
|
475
|
}
|
474
|
476
|
/**
|
|
@@ -477,18 +479,18 @@ var App = function (_Component) {
|
477
|
479
|
*/
|
478
|
480
|
|
479
|
481
|
}, {
|
480
|
|
- key: "sUpdateComment",
|
|
482
|
+ key: 'sUpdateComment',
|
481
|
483
|
value: function sUpdateComment(_ref5) {
|
482
|
484
|
var _this8 = this;
|
483
|
485
|
|
484
|
486
|
var commentId = _ref5.commentId,
|
485
|
487
|
content = _ref5.content;
|
486
|
488
|
|
487
|
|
- this.handleChangeLoading("sUpdateComment", true);
|
|
489
|
+ this.handleChangeLoading('sUpdateComment', true);
|
488
|
490
|
var API = this.props.API;
|
489
|
491
|
|
490
|
|
- this.axios(API + "/comments/" + commentId, {
|
491
|
|
- method: "post",
|
|
492
|
+ this.axios(API + '/comments/' + commentId, {
|
|
493
|
+ method: 'post',
|
492
|
494
|
data: {
|
493
|
495
|
content: content
|
494
|
496
|
},
|
|
@@ -504,10 +506,10 @@ var App = function (_Component) {
|
504
|
506
|
}
|
505
|
507
|
return it;
|
506
|
508
|
});
|
507
|
|
- _this8.props.onUpdateComment("comment");
|
|
509
|
+ _this8.props.onUpdateComment('comment');
|
508
|
510
|
_this8.setState({ list: list });
|
509
|
511
|
}).catch(this.errorHandler).finally(function () {
|
510
|
|
- _this8.handleChangeLoading("sUpdateComment", false);
|
|
512
|
+ _this8.handleChangeLoading('sUpdateComment', false);
|
511
|
513
|
});
|
512
|
514
|
}
|
513
|
515
|
/**
|
|
@@ -517,21 +519,21 @@ var App = function (_Component) {
|
517
|
519
|
*/
|
518
|
520
|
|
519
|
521
|
}, {
|
520
|
|
- key: "sCreateReply",
|
|
522
|
+ key: 'sCreateReply',
|
521
|
523
|
value: function sCreateReply(data, cb) {
|
522
|
524
|
var _this9 = this;
|
523
|
525
|
|
524
|
|
- if (!data.content) return this.error(_reactIntlUniversal2.default.get("message.replyNoNull"));
|
525
|
|
- this.handleChangeLoading("sCreateReply", true);
|
|
526
|
+ if (!data.content) return this.error(_reactIntlUniversal2.default.get('message.replyNoNull'));
|
|
527
|
+ this.handleChangeLoading('sCreateReply', true);
|
526
|
528
|
var API = this.props.API;
|
527
|
529
|
|
528
|
|
- this.axios(API + "/replies", {
|
529
|
|
- method: "post",
|
|
530
|
+ this.axios(API + '/replies', {
|
|
531
|
+ method: 'post',
|
530
|
532
|
data: data,
|
531
|
533
|
withCredentials: true
|
532
|
534
|
}).then(function (response) {
|
533
|
535
|
if (_this9.props.showAlertReply) {
|
534
|
|
- _message3.default.success(_reactIntlUniversal2.default.get("message.replySuccess"));
|
|
536
|
+ _message3.default.success(_reactIntlUniversal2.default.get('message.replySuccess'));
|
535
|
537
|
}
|
536
|
538
|
if ((0, _helper.isFunction)(cb)) cb(response.data);
|
537
|
539
|
// 将数据写入到 list 中
|
|
@@ -552,7 +554,7 @@ var App = function (_Component) {
|
552
|
554
|
_this9.props.onCommentFail(error.response.status);
|
553
|
555
|
_this9.errorHandler(error);
|
554
|
556
|
}).finally(function () {
|
555
|
|
- _this9.handleChangeLoading("sCreateReply", false);
|
|
557
|
+ _this9.handleChangeLoading('sCreateReply', false);
|
556
|
558
|
});
|
557
|
559
|
}
|
558
|
560
|
|
|
@@ -563,15 +565,15 @@ var App = function (_Component) {
|
563
|
565
|
*/
|
564
|
566
|
|
565
|
567
|
}, {
|
566
|
|
- key: "sDeleteReply",
|
|
568
|
+ key: 'sDeleteReply',
|
567
|
569
|
value: function sDeleteReply(replyId, commentId) {
|
568
|
570
|
var _this10 = this;
|
569
|
571
|
|
570
|
|
- this.handleChangeLoading("sDeleteReply", true);
|
|
572
|
+ this.handleChangeLoading('sDeleteReply', true);
|
571
|
573
|
var API = this.props.API;
|
572
|
574
|
|
573
|
|
- this.axios(API + "/replies/" + replyId + "?CommentID=" + commentId, {
|
574
|
|
- method: "delete",
|
|
575
|
+ this.axios(API + '/replies/' + replyId + '?CommentID=' + commentId, {
|
|
576
|
+ method: 'delete',
|
575
|
577
|
withCredentials: true
|
576
|
578
|
}).then(function () {
|
577
|
579
|
var deletedItem = null;
|
|
@@ -591,7 +593,7 @@ var App = function (_Component) {
|
591
|
593
|
_this10.setState({ list: list });
|
592
|
594
|
_this10.props.onDelete(_constant.COMMENT_TYPE.REPLY, deletedItem);
|
593
|
595
|
}).catch(this.errorHandler).finally(function () {
|
594
|
|
- _this10.handleChangeLoading("sDeleteReply", false);
|
|
596
|
+ _this10.handleChangeLoading('sDeleteReply', false);
|
595
|
597
|
});
|
596
|
598
|
}
|
597
|
599
|
/**
|
|
@@ -601,7 +603,7 @@ var App = function (_Component) {
|
601
|
603
|
*/
|
602
|
604
|
|
603
|
605
|
}, {
|
604
|
|
- key: "sUpdateReply",
|
|
606
|
+ key: 'sUpdateReply',
|
605
|
607
|
value: function sUpdateReply(_ref6) {
|
606
|
608
|
var _this11 = this;
|
607
|
609
|
|
|
@@ -610,11 +612,11 @@ var App = function (_Component) {
|
610
|
612
|
replyId = _ref6.replyId,
|
611
|
613
|
replyPage = _ref6.replyPage;
|
612
|
614
|
|
613
|
|
- this.handleChangeLoading("sUpdateReply", true);
|
|
615
|
+ this.handleChangeLoading('sUpdateReply', true);
|
614
|
616
|
var API = this.props.API;
|
615
|
617
|
|
616
|
|
- this.axios(API + "/replies/" + replyId, {
|
617
|
|
- method: "post",
|
|
618
|
+ this.axios(API + '/replies/' + replyId, {
|
|
619
|
+ method: 'post',
|
618
|
620
|
data: {
|
619
|
621
|
comment_id: commentId,
|
620
|
622
|
content: content
|
|
@@ -624,9 +626,9 @@ var App = function (_Component) {
|
624
|
626
|
for (var i = 1; i <= replyPage; i++) {
|
625
|
627
|
_this11.sGetReply({ commentId: commentId, page: i });
|
626
|
628
|
}
|
627
|
|
- _this11.props.onUpdateComment("reply");
|
|
629
|
+ _this11.props.onUpdateComment('reply');
|
628
|
630
|
}).catch(this.errorHandler).finally(function () {
|
629
|
|
- _this11.handleChangeLoading("sUpdateReply", false);
|
|
631
|
+ _this11.handleChangeLoading('sUpdateReply', false);
|
630
|
632
|
});
|
631
|
633
|
}
|
632
|
634
|
/**
|
|
@@ -636,19 +638,19 @@ var App = function (_Component) {
|
636
|
638
|
*/
|
637
|
639
|
|
638
|
640
|
}, {
|
639
|
|
- key: "sCommentFavor",
|
|
641
|
+ key: 'sCommentFavor',
|
640
|
642
|
value: function sCommentFavor(commentId, favored) {
|
641
|
643
|
var _this12 = this;
|
642
|
644
|
|
643
|
|
- this.handleChangeLoading("sCommentFavor", true);
|
|
645
|
+ this.handleChangeLoading('sCommentFavor', true);
|
644
|
646
|
var API = this.props.API;
|
645
|
647
|
|
646
|
|
- this.axios(API + "/comments/" + commentId + "/favor", {
|
647
|
|
- method: favored ? "delete" : "put",
|
|
648
|
+ this.axios(API + '/comments/' + commentId + '/favor', {
|
|
649
|
+ method: favored ? 'delete' : 'put',
|
648
|
650
|
withCredentials: true
|
649
|
651
|
}).then(function (response) {
|
650
|
652
|
if (_this12.props.showAlertFavor) {
|
651
|
|
- _message3.default.success(favored ? _reactIntlUniversal2.default.get("message.cancelLickSuccess") : _reactIntlUniversal2.default.get("message.likeSuccess"));
|
|
653
|
+ _message3.default.success(favored ? _reactIntlUniversal2.default.get('message.cancelLickSuccess') : _reactIntlUniversal2.default.get('message.likeSuccess'));
|
652
|
654
|
}
|
653
|
655
|
// 更新 list 中的该项数据的 favored
|
654
|
656
|
var list = _this12.state.list.map(function (item) {
|
|
@@ -660,7 +662,7 @@ var App = function (_Component) {
|
660
|
662
|
});
|
661
|
663
|
_this12.setState({ list: list });
|
662
|
664
|
}).catch(this.errorHandler).finally(function () {
|
663
|
|
- _this12.handleChangeLoading("sCommentFavor", false);
|
|
665
|
+ _this12.handleChangeLoading('sCommentFavor', false);
|
664
|
666
|
});
|
665
|
667
|
}
|
666
|
668
|
|
|
@@ -672,21 +674,21 @@ var App = function (_Component) {
|
672
|
674
|
*/
|
673
|
675
|
|
674
|
676
|
}, {
|
675
|
|
- key: "sReplyFavor",
|
|
677
|
+ key: 'sReplyFavor',
|
676
|
678
|
value: function sReplyFavor(replyId, commentId, favored) {
|
677
|
679
|
var _this13 = this;
|
678
|
680
|
|
679
|
|
- this.handleChangeLoading("sReplyFavor", true);
|
|
681
|
+ this.handleChangeLoading('sReplyFavor', true);
|
680
|
682
|
var API = this.props.API;
|
681
|
683
|
|
682
|
|
- this.axios(API + "/replies/" + replyId + "/favor", {
|
683
|
|
- method: favored ? "delete" : "put",
|
|
684
|
+ this.axios(API + '/replies/' + replyId + '/favor', {
|
|
685
|
+ method: favored ? 'delete' : 'put',
|
684
|
686
|
data: {
|
685
|
687
|
comment_id: commentId
|
686
|
688
|
},
|
687
|
689
|
withCredentials: true
|
688
|
690
|
}).then(function (response) {
|
689
|
|
- _message3.default.success(favored ? _reactIntlUniversal2.default.get("message.cancelLickSuccess") : _reactIntlUniversal2.default.get("message.likeSuccess"));
|
|
691
|
+ _message3.default.success(favored ? _reactIntlUniversal2.default.get('message.cancelLickSuccess') : _reactIntlUniversal2.default.get('message.likeSuccess'));
|
690
|
692
|
// 更新 list 中的该项数据的 favored
|
691
|
693
|
var list = _this13.state.list.map(function (item) {
|
692
|
694
|
if (item.id === commentId) {
|
|
@@ -705,7 +707,7 @@ var App = function (_Component) {
|
705
|
707
|
});
|
706
|
708
|
_this13.setState({ list: list });
|
707
|
709
|
}).catch(this.errorHandler).finally(function () {
|
708
|
|
- _this13.handleChangeLoading("sReplyFavor", false);
|
|
710
|
+ _this13.handleChangeLoading('sReplyFavor', false);
|
709
|
711
|
});
|
710
|
712
|
}
|
711
|
713
|
|
|
@@ -714,21 +716,21 @@ var App = function (_Component) {
|
714
|
716
|
*/
|
715
|
717
|
|
716
|
718
|
}, {
|
717
|
|
- key: "sOssSts",
|
|
719
|
+ key: 'sOssSts',
|
718
|
720
|
value: function sOssSts() {
|
719
|
721
|
var _this14 = this;
|
720
|
722
|
|
721
|
|
- this.handleChangeLoading("sOssSts", true);
|
|
723
|
+ this.handleChangeLoading('sOssSts', true);
|
722
|
724
|
var API = this.props.API;
|
723
|
725
|
|
724
|
|
- this.axios.get(API + "/oss/sts").then(function (response) {
|
|
726
|
+ this.axios.get(API + '/oss/sts').then(function (response) {
|
725
|
727
|
_this14.setState({ oss: _extends({}, response.data) });
|
726
|
728
|
}).catch(this.errorHandler).finally(function () {
|
727
|
|
- _this14.handleChangeLoading("sOssSts", false);
|
|
729
|
+ _this14.handleChangeLoading('sOssSts', false);
|
728
|
730
|
});
|
729
|
731
|
}
|
730
|
732
|
}, {
|
731
|
|
- key: "render",
|
|
733
|
+ key: 'render',
|
732
|
734
|
value: function render() {
|
733
|
735
|
// 添加到 Context 的数据
|
734
|
736
|
var value = _extends({}, this.state, this.props, {
|
|
@@ -750,11 +752,11 @@ var App = function (_Component) {
|
750
|
752
|
_Comment.CommentContext.Provider,
|
751
|
753
|
{ value: value },
|
752
|
754
|
_react2.default.createElement(
|
753
|
|
- "div",
|
754
|
|
- { className: "comment" },
|
|
755
|
+ 'div',
|
|
756
|
+ { className: 'comment' },
|
755
|
757
|
this.props.showEditor && _react2.default.createElement(_CommentInput2.default, { content: this.props.children }),
|
756
|
758
|
this.props.showList && _react2.default.createElement(
|
757
|
|
- "div",
|
|
759
|
+ 'div',
|
758
|
760
|
{ style: { marginTop: 20 } },
|
759
|
761
|
_react2.default.createElement(_CommentList2.default, null)
|
760
|
762
|
)
|
|
@@ -805,9 +807,9 @@ App.propTypes = {
|
805
|
807
|
|
806
|
808
|
App.defaultProps = {
|
807
|
809
|
businessUserId: 0,
|
808
|
|
- API: "//api.links123.net/comment/v1",
|
809
|
|
- emojiAPI: "//api.links123.net/link/v1",
|
810
|
|
- LOGINLINK: process.env.RUN_MOD === "production" ? "https://passport.links123.com/login" : "http://test.links123.net:5050/login",
|
|
810
|
+ API: '//api.links123.net/comment/v1',
|
|
811
|
+ emojiAPI: '//api.links123.net/link/v1',
|
|
812
|
+ LOGINLINK: process.env.RUN_MOD === 'production' ? 'https://passport.links123.com/login' : 'http://test.links123.net:5050/login',
|
811
|
813
|
showList: true,
|
812
|
814
|
showEditor: true,
|
813
|
815
|
showAlertComment: false,
|
|
@@ -815,7 +817,7 @@ App.defaultProps = {
|
815
|
817
|
showAlertFavor: false,
|
816
|
818
|
showError: true,
|
817
|
819
|
showEdit: false,
|
818
|
|
- pageType: "more",
|
|
820
|
+ pageType: 'more',
|
819
|
821
|
limit: _constant.LIMIT,
|
820
|
822
|
onGetMoreBtnClick: function onGetMoreBtnClick() {},
|
821
|
823
|
onPageChange: function onPageChange(page) {},
|