通用评论

1
  1. {"version":3,"sources":["../../../src/components/CommentInput/index.js"],"names":["PLACEHOLDER","normal","default","CommentInput","props","state","value","fileList","fileMap","handleChange","bind","handleSubmit","handleChangeFileList","handleChangeEmoji","handleUpload","e","setState","target","emojiId","uid","path","length","forEach","OSS_LINK","item","type","commentId","replyId","handleToggleInput","app","sCreateComment","business_id","content","sCreateReply","comment_id","reply_id","border","color","padding","marginLeft","marginTop","loading","Component","propTypes","PropTypes","oneOf","defaultProps"],"mappings":";;;;;;;;AAAA;;;;AACA;;;;AACA;;AACA;;;;AACA;;;;;;;;;;;;AAEA,IAAMA,cAAc;AAClBC,UAAQ,UADU;AAElBC,WAAS;AAFS,CAApB;;IAKMC,Y;;;AACJ,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA,4HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,aAAO,EADI;;AAGXC,gBAAU,EAHC,EAGG;AACdC,eAAS,EAJE,CAIC;AAJD,KAAb;AAMA,UAAKC,YAAL,GAAoB,MAAKA,YAAL,CAAkBC,IAAlB,OAApB;AACA,UAAKC,YAAL,GAAoB,MAAKA,YAAL,CAAkBD,IAAlB,OAApB;AACA,UAAKE,oBAAL,GAA4B,MAAKA,oBAAL,CAA0BF,IAA1B,OAA5B;AACA,UAAKG,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBH,IAAvB,OAAzB;AACA,UAAKI,YAAL,GAAoB,MAAKA,YAAL,CAAkBJ,IAAlB,OAApB;AAZiB;AAalB;;;;iCAEYK,C,EAAG;AACd,WAAKC,QAAL,CAAc,EAAEV,OAAOS,EAAEE,MAAF,CAASX,KAAlB,EAAd;AACD;;;yCAEoBC,Q,EAAU;AAC7B,WAAKS,QAAL,CAAc,EAAET,kBAAF,EAAd;AACD;;;sCAEiBW,O,EAAS;AAAA,UACnBZ,KADmB,GACT,KAAKD,KADI,CACnBC,KADmB;;AAEzBA,qBAAaY,OAAb;AACA,WAAKF,QAAL,CAAc,EAAEV,YAAF,E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ACCH,IADD,GACU,KAAKrB,KADf,CACCqB,IADD;AAAA,oBAEqB,KAAKpB,KAF1B;AAAA,UAECC,KAFD,WAECA,KAFD;AAAA,UAEQC,QAFR,WAEQA,QAFR;;;AAIP,aACE;AAAA;AAAA;AACGkB,iBAAS,QAAT,GACC;AAAA;AAAA;AACE;AAAA;AAAA;AACE,qBAAO;AACLW,wBAAQ,mBADH;AAELC,uBAAO,MAFF;AAGLC,yBAAS;AAHJ;AADT;AAAA;AAAA,WADF;AAUE;AAAA;AAAA,cAAM,OAAO,EAAEC,YAAY,MAAd,EAAsBF,OAAO,SAA7B,EAAb;AAAA;AAEE;AAAA;AAAA,gBAAM,OAAO,EAAEE,YAAY,MAAd,EAAsBF,OAAO,SAA7B,EAAb;AAAA;AAAA;AAFF;AAVF,SADD,GAkBG,IAnBN;AAoBE;AAAA;AAAA,YAAK,OAAO,EAAEG,WAAW,EAAb,EAAZ;AACE,wCAAC,gBAAD;AACE,mBAAOlC,KADT;AAEE,yBAAaN,YAAYyB,IAAZ,KAAqBzB,YAAYE,OAFhD;AAGE,sBAAUK,QAHZ;AAIE,sBAAU,KAAKE,YAJjB;AAKE,sBAAU,KAAKE,YALjB;AAME,8BAAkB,KAAKC,oBANzB;AAOE,2BAAe,KAAKC,iBAPtB;AAQE,sBAAU,KAAKC,YARjB;AASE,qBAAS,KAAKV,KAAL,CAAWyB,GAAX,CAAeY,OAAf,CAAuBX;AATlC;AADF;AApBF,OADF;AAoCD;;;;EA/GwBY,gB;;AAkH3BvC,aAAawC,SAAb,GAAyB;AACvB;AACAlB,QAAMmB,oBAAUC,KAAV,CAAgB,CAAC,QAAD,EAAW,SAAX,EAAsB,OAAtB,CAAhB;AAFiB,CAAzB;;AAKA1C,aAAa2C,YAAb,GAA4B;AAC1BrB,QAAM;AADoB,CAA5B;;kBAIe,uBAAQtB,YAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { OSS_LINK } from \"../../constant\";\nimport Comment from \"../../Comment\";\nimport Editor from \"../Editor\";\n\nconst PLACEHOLDER = {\n normal: \"说点什么吧...\",\n default: \"说点什么吧...\"\n};\n\nclass CommentInput extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: \"\",\n\n fileList: [], // 图片列表\n fileMap: {} // 已经上传的图片路径和 uid 的映射 { uid: path }\n };\n this.handleChange = this.handleChange.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleChangeFileList = this.handleChangeFileList.bind(this);\n this.handleChangeEmoji = this.handleChangeEmoji.bind(this);\n this.handleUpload = this.handleUpload.bind(this);\n }\n\n handleChange(e) {\n this.setState({ value: e.target.value });\n }\n\n handleChangeFileList(fileList) {\n this.setState({ fileList });\n }\n\n handleChangeEmoji(emojiId) {\n let { value } = this.state;\n value += `[${emojiId}]`;\n this.setState({ value });\n }\n\n handleUpload({ uid, path }) {\n const { fileMap } = this.state;\n fileMap[uid] = path;\n this.setState({ fileMap });\n }\n\n handleSubmit() {\n let { value, fileMap, fileList } = this.state;\n if (fileList.length) {\n fileList.forEach(item => {\n value += `[${OSS_LINK}${fileMap[item.uid]}]`;\n });\n }\n\n const { type, commentId, replyId, handleToggleInput } = this.props;\n if (type === \"normal\") {\n this.props.app.sCreateComment({\n type: 1,\n business_id: \"1\",\n content: value\n });\n } else if (type === \"comment\") {\n this.props.app.sCreateReply(\n {\n comment_id: commentId,\n content: value\n },\n () => handleToggleInput()\n );\n } else if (type === \"reply\") {\n this.props.app.sCreateReply(\n {\n comment_id: commentId,\n content: value,\n reply_id: replyId\n },\n () => handleToggleInput()\n );\n }\n }\n\n render() {\n const { type } = this.props;\n const { value, fileList } = this.state;\n\n return (\n <div>\n {type === \"normal\" ? (\n <div>\n <span\n style={{\n border: \"1px solid #CECECE\",\n color: \"#666\",\n padding: \"2px 3px\"\n }}\n >\n 回复\n </span>\n <span style={{ marginLeft: \"20px\", color: \"#5198EB\" }}>\n 口碑\n <span style={{ marginLeft: \"20px\", color: \"#666666\" }}>\n (全站挑出毛病或提出合理建议,奖励10到100元红包)\n </span>\n </span>\n </div>\n ) : null}\n <div style={{ marginTop: 40 }}>\n <Editor\n value={value}\n placeholder={PLACEHOLDER[type] || PLACEHOLDER.default}\n fileList={fileList}\n onChange={this.handleChange}\n onSubmit={this.handleSubmit}\n onChangeFileList={this.handleChangeFileList}\n onChangeEmoji={this.handleChangeEmoji}\n onUpload={this.handleUpload}\n loading={this.props.app.loading.sCreateComment}\n />\n </div>\n </div>\n );\n }\n}\n\nCommentInput.propTypes = {\n // normal 有切换回复/口碑的 header ; comment 评论输入框 / reply 回复输入框\n type: PropTypes.oneOf([\"normal\", \"comment\", \"reply\"])\n};\n\nCommentInput.defaultProps = {\n type: \"normal\"\n};\n\nexport default Comment(CommentInput);\n"]}