{"version":3,"sources":["../src/App.js"],"names":["App","props","state","loading","oss","list","page","total","isNoMoreComment","handleChangeLoading","bind","sGetComment","sGetReply","sCreateComment","sCreateReply","sCommentFavor","sReplyFavor","sOssSts","key","value","setState","API","type","businessId","axios","get","LIMIT","then","response","data","newList","oldList","filter","o","isTemporary","concat","info","catch","error","msg","lang","ERROR_DEFAULT","message","finally","commentId","map","item","id","replies","reply_count","reply_page","isNoMoreReply","content","method","business_id","withCredentials","success","unshift","cb","console","log","comment_id","push","favored","favor_count","replyId","showHeader","marginBottom","border","borderRadius","color","marginRight","marginLeft","showEditor","children","showList","marginTop","Component","propTypes","PropTypes","number","isRequired","string","bool","defaultProps","Editor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;AACA;;AACA;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;IAEMA,G;;;AACJ,eAAYC,KAAZ,EAAmB;AAAA;;AAAA,0GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,eAAS,EADE;;AAGX;AACAC,WAAK,EAJM;;AAMX;AACAC,YAAM,EAPK;AAQXC,YAAM,CARK;AASXC,aAAO,CATI;AAUX;AACAC,uBAAiB;AAXN,KAAb;AAaA,UAAKC,mBAAL,GAA2B,MAAKA,mBAAL,CAAyBC,IAAzB,OAA3B;AACA,UAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBD,IAAjB,OAAnB;AACA,UAAKE,SAAL,GAAiB,MAAKA,SAAL,CAAeF,IAAf,OAAjB;AACA,UAAKG,cAAL,GAAsB,MAAKA,cAAL,CAAoBH,IAApB,OAAtB;AACA,UAAKI,YAAL,GAAoB,MAAKA,YAAL,CAAkBJ,IAAlB,OAApB;AACA,UAAKK,aAAL,GAAqB,MAAKA,aAAL,CAAmBL,IAAnB,OAArB;AACA,UAAKM,WAAL,GAAmB,MAAKA,WAAL,CAAiBN,IAAjB,OAAnB;AACA,UAAKO,OAAL,GA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E,SAAJ,GAAgB;AACdxD,QAAMyD,oBAAUC,MAAV,CAAiBC,UADT,EACqB;AACnC1D,cAAYwD,oBAAUG,MAAV,CAAiBD,UAFf,EAE2B;AACzC5D,OAAK0D,oBAAUG,MAHD,EAGS;AACvBP,YAAUI,oBAAUI,IAJN,EAIY;AAC1BV,cAAYM,oBAAUI,IALR,EAKc;AAC5BjB,cAAYa,oBAAUI,IANR,CAMc;AANd,CAAhB;;AASAnF,IAAIoF,YAAJ,GAAmB;AACjB/D,OAAK,oCADY;AAEjBsD,YAAU,IAFO;AAGjBF,cAAY,IAHK;AAIjBP,cAAY;AAJK,CAAnB;;QAOSmB,M,GAAAA,gB;kBAEMrF,G","file":"App.js","sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { message, Tag } from 'antd';\nimport axios from './axios';\nimport { ERROR_DEFAULT, LIMIT } from './constant';\nimport { CommentContext } from './Comment';\nimport { isFunction } from './helper';\nimport CommentInput from './components/CommentInput';\nimport CommentList from './components/CommentList';\nimport Editor from './components/Editor';\nimport lang from './lang';\nimport './App.css';\n\nclass App extends Component {\n constructor(props) {\n super(props);\n this.state = {\n loading: {},\n\n // oss 配置\n oss: {},\n\n // 评论数据\n list: [],\n page: 1,\n total: 0,\n // 是否没有更多评论了\n isNoMoreComment: false,\n };\n this.handleChangeLoading = this.handleChangeLoading.bind(this);\n this.sGetComment = this.sGetComment.bind(this);\n this.sGetReply = this.sGetReply.bind(this);\n this.sCreateComment = this.sCreateComment.bind(this);\n this.sCreateReply = this.sCreateReply.bind(this);\n this.sCommentFavor = this.sCommentFavor.bind(this);\n this.sReplyFavor = this.sReplyFavor.bind(this);\n this.sOssSts = this.sOssSts.bind(this);\n }\n\n componentDidMount() {}\n\n /**\n * 改变 loading 状态\n * @param {string} key key\n * @param {string} value value\n */\n handleChangeLoading(key, value) {\n const { loading } = this.state;\n loading[key] = value;\n this.setState({ loading });\n }\n\n /**\n * 获取评论列表\n */\n sGetComment({ page = 1 } = {}) {\n this.handleChangeLoading('sGetComment', true);\n const { API, type, businessId } = this.props;\n axios\n .get(\n `${API}/comments?type=${type}&business_id=${businessId}&page=${page}&limit=${LIMIT}`\n )\n .then(response => {\n const { list, page, total } = response.data;\n if (list) {\n let newList = list;\n if (page > 1) {\n let { list: oldList } = this.state;\n // 删除临时数据\n oldList = oldList.filter(o => !o.isTemporary);\n newList = oldList.concat(newList);\n }\n this.setState({\n list: newList,\n page,\n total,\n });\n } else {\n message.info('没有更多评论了');\n this.setState({\n isNoMoreComment: true,\n });\n }\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sGetComment', false);\n });\n }\n\n /**\n * 获取更多回复\n */\n sGetReply({ commentId, page = 1 } = {}) {\n this.handleChangeLoading('sGetReply', true);\n const { API } = this.props;\n axios\n .get(`${API}/replies?comment_id=${commentId}&page=${page}&limit=${LIMIT}`)\n .then(response => {\n if (!response.data.list) {\n message.info('没有更多数据了!');\n }\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n if (!item.replies) item.replies = [];\n if (response.data.list) {\n if (page === 1) {\n // 如果当前页数为第一页,则清空当前所有的 replies\n // 并将获取到的 replies 存放在 state\n item.replies = response.data.list;\n } else {\n item.replies = item.replies\n .filter(o => !o.isTemporary)\n .concat(response.data.list);\n // 如果当前页数非第一页,则合并 replies\n }\n item.reply_count = response.data.total;\n item.reply_page = response.data.page;\n } else {\n item.isNoMoreReply = true;\n }\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sGetReply', false);\n });\n }\n\n /**\n * 添加评论\n * @param {object} {content} comment content\n */\n sCreateComment({ content } = {}) {\n if (!content) return message.error('评论内容不能为空 ');\n this.handleChangeLoading('sCreateComment', true);\n const { API, type, businessId } = this.props;\n axios(`${API}/comments`, {\n method: 'post',\n data: {\n type,\n business_id: businessId,\n content,\n },\n withCredentials: true,\n })\n .then(response => {\n message.success('评论成功!');\n // 将数据写入到 list 中\n // 临时插入\n // 等到获取数据之后,删除临时数据\n const { list, total } = this.state;\n list.unshift({\n ...response.data,\n isTemporary: true, // 临时的数据\n });\n this.setState({ list, total: total + 1 });\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sCreateComment', false);\n });\n }\n\n /**\n * 添加回复\n * 回复评论/回复回复\n * @param {object} data { comment_id, content, [reply_id] }\n */\n sCreateReply(data, cb) {\n console.log('list: ', this.state.list);\n\n if (!data.content) return message.error('回复内容不能为空 ');\n this.handleChangeLoading('sCreateReply', true);\n const { API } = this.props;\n axios(`${API}/replies`, {\n method: 'post',\n data,\n withCredentials: true,\n })\n .then(response => {\n message.success('回复成功!');\n if (isFunction(cb)) cb();\n // 将数据写入到 list 中\n // 临时插入\n // 等到获取数据之后,删除临时数据\n const list = this.state.list.map(item => {\n if (item.id === data.comment_id) {\n if (!item.replies) item.replies = [];\n item.replies.push({\n ...response.data,\n isTemporary: true, // 临时的数据\n });\n item.reply_count += 1;\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sCreateReply', false);\n });\n }\n\n /**\n * 评论 点赞/取消点赞\n * @param {string} commentId { commentId }\n * @param {boolean} favored 是否已经点过赞\n */\n sCommentFavor(commentId, favored) {\n this.handleChangeLoading('sCommentFavor', true);\n const { API } = this.props;\n axios(`${API}/comments/${commentId}/favor`, {\n method: favored ? 'delete' : 'put',\n withCredentials: true,\n })\n .then(response => {\n message.success(favored ? '取消点赞成功!' : '点赞成功!');\n // 更新 list 中的该项数据的 favored\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n item.favored = !favored;\n item.favor_count += favored ? -1 : 1;\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sCommentFavor', false);\n });\n }\n\n /**\n * 回复 点赞/取消点赞\n * @param {string} replyId replyId\n * @param {string} commentId commentId\n * @param {boolean} favored 是否已经点过赞\n */\n sReplyFavor(replyId, commentId, favored) {\n this.handleChangeLoading('sReplyFavor', true);\n console.log('replyId, commentId ', replyId, commentId);\n\n const { API } = this.props;\n axios(`${API}/replies/${replyId}/favor`, {\n method: favored ? 'delete' : 'put',\n withCredentials: true,\n })\n .then(response => {\n console.log('response: ', response);\n\n message.success(favored ? '取消点赞成功!' : '点赞成功!');\n // TODO: (2018.07.20 node) 对评论的回复点赞,报错\n // // 更新 list 中的该项数据的 favored\n // const list = this.state.list.map(item => {\n // if (item.id === replyId) {\n // item.favored = !favored;\n // item.favor_count += favored ? -1 : 1;\n // }\n // return item;\n // });\n // this.setState({ list });\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sReplyFavor', false);\n });\n }\n\n /**\n * 获取 OSS 上传的参数\n */\n sOssSts() {\n this.handleChangeLoading('sOssSts', true);\n const { API } = this.props;\n axios\n .get(`${API}/oss/sts`)\n .then(response => {\n this.setState({ oss: { ...response.data } });\n })\n .catch(error => {\n if (error.response && error.response.data && error.response.data.msg) {\n message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\n return;\n }\n message.error(lang[error.message] || ERROR_DEFAULT);\n })\n .finally(() => {\n this.handleChangeLoading('sOssSts', false);\n });\n }\n\n render() {\n // 添加到 Context 的数据\n const value = {\n ...this.state,\n ...this.props,\n sCreateComment: this.sCreateComment,\n sGetComment: this.sGetComment,\n sCommentFavor: this.sCommentFavor,\n sReplyFavor: this.sReplyFavor,\n sCreateReply: this.sCreateReply,\n sGetReply: this.sGetReply,\n sOssSts: this.sOssSts,\n };\n\n return (\n \n
\n {this.props.showHeader && (\n
\n \n 留言\n \n \n 口碑\n \n \n (全站挑出毛病或提出合理建议,奖励10到100元红包)\n \n
\n )}\n {this.props.showEditor && (\n \n )}\n {this.props.showList && (\n
\n \n
\n )}\n
\n
\n );\n }\n}\n\nApp.propTypes = {\n type: PropTypes.number.isRequired, // 评论的 type\n businessId: PropTypes.string.isRequired, // 评论的 business_id\n API: PropTypes.string, // 评论的 API 前缀\n showList: PropTypes.bool, // 是否显示评论列表\n showEditor: PropTypes.bool, // 是否显示评论输入框\n showHeader: PropTypes.bool, // 是否显示评论顶部的提示\n};\n\nApp.defaultProps = {\n API: 'http://api.links123.net/comment/v1',\n showList: true,\n showEditor: true,\n showHeader: true,\n};\n\nexport { Editor };\n\nexport default App;\n"]}