|
|
|
@ -44,7 +44,7 @@ class MemoDetail extends Component {
|
|
|
|
|
this.state = {
|
|
|
|
|
memoLoading: true,
|
|
|
|
|
hasMoreComments: false,
|
|
|
|
|
pageCount: 1,
|
|
|
|
|
pageCount: 2,
|
|
|
|
|
|
|
|
|
|
goldRewardDialogOpen: false
|
|
|
|
|
}
|
|
|
|
@ -54,12 +54,12 @@ class MemoDetail extends Component {
|
|
|
|
|
|
|
|
|
|
const { match } = this.props
|
|
|
|
|
|
|
|
|
|
const memoUrl = `/api/v1/memos/${match.params.memoId}`;
|
|
|
|
|
const memoUrl = `/memos/${match.params.memoId}.json`;
|
|
|
|
|
this.setState({
|
|
|
|
|
memoLoading: true
|
|
|
|
|
})
|
|
|
|
|
axios.get(memoUrl,{
|
|
|
|
|
withCredentials: true,
|
|
|
|
|
// withCredentials: true,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
const memo = response.data.memo
|
|
|
|
@ -86,14 +86,16 @@ class MemoDetail extends Component {
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
hasMoreComments,
|
|
|
|
|
pageCount: 1,
|
|
|
|
|
pageCount: 2,
|
|
|
|
|
comments: memo_replies
|
|
|
|
|
})
|
|
|
|
|
delete response.data.memo_replies;
|
|
|
|
|
// reset
|
|
|
|
|
response.data.memo.praise_count = response.data.memo.memo_praise_count
|
|
|
|
|
this.props.initForumState(response.data)
|
|
|
|
|
const user = response.data.current_user;
|
|
|
|
|
user.tidding_count = response.data.tidding_count;
|
|
|
|
|
this.props.initCommonState(user)
|
|
|
|
|
// const user = response.data.current_user;
|
|
|
|
|
// user.tidding_count = response.data.tidding_count;
|
|
|
|
|
// this.props.initCommonState(user)
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
memoLoading: false
|
|
|
|
@ -116,10 +118,10 @@ class MemoDetail extends Component {
|
|
|
|
|
$('body>#root').off('onMemoDelete')
|
|
|
|
|
}
|
|
|
|
|
onMemoDelete(memo) {
|
|
|
|
|
const deleteUrl = `/api/v1/memos/${memo.id}`;
|
|
|
|
|
const deleteUrl = `/memos/${memo.id}.json`;
|
|
|
|
|
// 获取memo list
|
|
|
|
|
axios.delete(deleteUrl, {
|
|
|
|
|
withCredentials: true,
|
|
|
|
|
// withCredentials: true,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
const status = response.data.status
|
|
|
|
@ -158,14 +160,14 @@ class MemoDetail extends Component {
|
|
|
|
|
|
|
|
|
|
clickPraise(){
|
|
|
|
|
const { memo } = this.props;
|
|
|
|
|
const url = `/api/v1/discusses/${memo.id}/plus`;
|
|
|
|
|
const url = `/discusses/${memo.id}/plus.json`;
|
|
|
|
|
console.log(url)
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
container_type: 'Memo',
|
|
|
|
|
type: 1 // "踩0;赞1"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
@ -223,7 +225,8 @@ class MemoDetail extends Component {
|
|
|
|
|
this.createNewComment(commentContent, id, editor);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const url = `/api/v1/memos/${id}/reply`;
|
|
|
|
|
// /${id}
|
|
|
|
|
const url = `/memos/reply.json`;
|
|
|
|
|
const { comments } = this.state;
|
|
|
|
|
const user = this._getUser();
|
|
|
|
|
/*
|
|
|
|
@ -235,12 +238,14 @@ class MemoDetail extends Component {
|
|
|
|
|
commentContent = commentContent.replace(/(\n<p>\n\t<br \/>\n<\/p>)*$/g,'');
|
|
|
|
|
}
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
parent_id: id,
|
|
|
|
|
content: commentContent
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
response.data.memo = response.data
|
|
|
|
|
if (response.data.memo) {
|
|
|
|
|
let newDiscuss = response.data.memo;
|
|
|
|
|
|
|
|
|
@ -303,12 +308,12 @@ class MemoDetail extends Component {
|
|
|
|
|
if (childCommentId) {
|
|
|
|
|
deleteCommentId = childCommentId;
|
|
|
|
|
}
|
|
|
|
|
const url = `/api/v1/memos/${deleteCommentId}`
|
|
|
|
|
const url = `/memos/${deleteCommentId}.json`
|
|
|
|
|
let comments = this.state.comments;
|
|
|
|
|
|
|
|
|
|
axios.delete(url,
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
// TODO 删除成功或失败
|
|
|
|
@ -346,7 +351,7 @@ class MemoDetail extends Component {
|
|
|
|
|
const { comments } = this.state;
|
|
|
|
|
const commentIndex = this._findById(discussId, comments);
|
|
|
|
|
|
|
|
|
|
const url = `/api/v1/discusses/${discussId}/plus`
|
|
|
|
|
const url = `/discusses/${discussId}/plus.json`
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
// id: discussId,
|
|
|
|
|
// container_id: challenge.id,
|
|
|
|
@ -354,7 +359,7 @@ class MemoDetail extends Component {
|
|
|
|
|
type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0;赞1"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data.praise_count === 0 || response.data.praise_count) {
|
|
|
|
@ -379,7 +384,7 @@ class MemoDetail extends Component {
|
|
|
|
|
handleComment = childComment;
|
|
|
|
|
}
|
|
|
|
|
let handleCommentId = handleComment.id;
|
|
|
|
|
const url = `/api/v1/discusses/${handleCommentId}/reward_code`
|
|
|
|
|
const url = `/discusses/${handleCommentId}/reward_code.json`
|
|
|
|
|
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
id: handleCommentId,
|
|
|
|
@ -389,7 +394,7 @@ class MemoDetail extends Component {
|
|
|
|
|
user_id: handleComment.user_id
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data && response.data.code) {
|
|
|
|
@ -423,7 +428,7 @@ class MemoDetail extends Component {
|
|
|
|
|
const id = item.id
|
|
|
|
|
const { showSnackbar } = this.props;
|
|
|
|
|
const user = this._getUser();
|
|
|
|
|
const url = `/api/v1/memos/${id}/hidden`
|
|
|
|
|
const url = `/memos/${id}/hidden.json`
|
|
|
|
|
const { comments } = this.state;
|
|
|
|
|
|
|
|
|
|
const commentIndex = this._findById(id, comments);
|
|
|
|
@ -432,14 +437,14 @@ class MemoDetail extends Component {
|
|
|
|
|
hidden: !comment.hidden ? "1" : "0"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data.status === -1) {
|
|
|
|
|
showSnackbar(response.data.message)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (response.data.status === 1) {
|
|
|
|
|
if (response.data.status === 0) {
|
|
|
|
|
|
|
|
|
|
if (!childCommentId) {
|
|
|
|
|
comment.hidden = !comment.hidden;
|
|
|
|
@ -473,14 +478,16 @@ class MemoDetail extends Component {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const url = `/api/v1/memos/${memo.id}/reply`;
|
|
|
|
|
// /${memo.id}
|
|
|
|
|
const url = `/memos/reply.json`;
|
|
|
|
|
let { comments } = this.state;
|
|
|
|
|
const user = this._getUser();
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
parent_id: memo.id,
|
|
|
|
|
content: content
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data.status === -1) {
|
|
|
|
@ -488,6 +495,7 @@ class MemoDetail extends Component {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (response.data) {
|
|
|
|
|
response.data.memo = response.data
|
|
|
|
|
const newMemo = response.data.memo;
|
|
|
|
|
// ke
|
|
|
|
|
editor.html && editor.html('');
|
|
|
|
@ -536,12 +544,12 @@ class MemoDetail extends Component {
|
|
|
|
|
let { comments, pageCount } = this.state;
|
|
|
|
|
let { memo } = this.props;
|
|
|
|
|
const user = this._getUser();
|
|
|
|
|
const url = `/api/v1/memos/${memo.id}/more_reply?page=${pageCount}`;
|
|
|
|
|
const url = `/memos/${memo.id}/more_reply.json?page=${pageCount}`;
|
|
|
|
|
axios.get(url, {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
withCredentials: true
|
|
|
|
|
// withCredentials: true
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data.status === -1) {
|
|
|
|
@ -584,10 +592,10 @@ class MemoDetail extends Component {
|
|
|
|
|
params.forum_id = this.state.p_forum_id;
|
|
|
|
|
}
|
|
|
|
|
let paramsUrl = urlStringify(params)
|
|
|
|
|
const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`;
|
|
|
|
|
const set_top_or_down_Url = `/memos/${memo.id}/sticky_or_cancel.json?${paramsUrl}`;
|
|
|
|
|
// 获取memo list
|
|
|
|
|
axios.get(set_top_or_down_Url, {
|
|
|
|
|
withCredentials: true,
|
|
|
|
|
axios.post(set_top_or_down_Url, {
|
|
|
|
|
// withCredentials: true,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
const status = response.data.status
|
|
|
|
@ -608,9 +616,8 @@ class MemoDetail extends Component {
|
|
|
|
|
const { memo, author_info } = this.props;
|
|
|
|
|
const newMemo = Object.assign({}, memo);
|
|
|
|
|
const _reward = parseInt(inputVal)
|
|
|
|
|
const newMemoUrl = `/api/v1/memos/${memo.id}/update`
|
|
|
|
|
|
|
|
|
|
const url = `/api/v1/discusses/${memo.id}/reward_code`
|
|
|
|
|
const url = `/discusses/${memo.id}/reward_code.json`
|
|
|
|
|
|
|
|
|
|
axios.post(url, {
|
|
|
|
|
id: memo.id,
|
|
|
|
@ -619,7 +626,7 @@ class MemoDetail extends Component {
|
|
|
|
|
score: _reward,
|
|
|
|
|
user_id: author_info.user_id
|
|
|
|
|
}, {
|
|
|
|
|
withCredentials: true,
|
|
|
|
|
// withCredentials: true,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
const { code } = response.data;
|
|
|
|
@ -659,14 +666,24 @@ class MemoDetail extends Component {
|
|
|
|
|
const { memo, recommend_shixun, current_user,author_info } = this.props;
|
|
|
|
|
const { comments, hasMoreComments, goldRewardDialogOpen } = this.state;
|
|
|
|
|
|
|
|
|
|
if (this.state.memoLoading) {
|
|
|
|
|
if (!memo || this.state.memoLoading) {
|
|
|
|
|
return <div className="edu-back-white" id="forum_index_list"></div>
|
|
|
|
|
}
|
|
|
|
|
current_user.user_url = `/users/${current_user.login}`;
|
|
|
|
|
let _current_user = {}
|
|
|
|
|
if (current_user) {
|
|
|
|
|
_current_user = current_user
|
|
|
|
|
}
|
|
|
|
|
(_current_user.user_url = `/users/${_current_user.login}`);
|
|
|
|
|
memo.isDetailPage = true;
|
|
|
|
|
// TODO 图片上传地址
|
|
|
|
|
return (
|
|
|
|
|
<div className="edu-back-white" id="forum_index_list"> {/* fl with100 */}
|
|
|
|
|
<div className="edu-back-white memoDetail" id="forum_index_list"> {/* fl with100 */}
|
|
|
|
|
<style>{`
|
|
|
|
|
.memoDetail .commentsbtn {
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
}
|
|
|
|
|
`}</style>
|
|
|
|
|
|
|
|
|
|
<RewardDialog goldRewardDialogOpen={goldRewardDialogOpen}
|
|
|
|
|
setRewardDialogVisible={this.setRewardDialogVisible}
|
|
|
|
|
rewardCode={this.rewardCodeMemo}
|
|
|
|
@ -681,11 +698,11 @@ class MemoDetail extends Component {
|
|
|
|
|
data-tip-down={`获得平台奖励金币:${memo.reward}`} >
|
|
|
|
|
<i className="iconfont icon-gift mr5"></i>{memo.reward}
|
|
|
|
|
</span> }
|
|
|
|
|
{ current_user && (current_user.admin === true || current_user.user_id === author_info.user_id) &&
|
|
|
|
|
<div className="edu-position-hidebox" style={{position: 'absolute', right: '18px',top:'4px'}}>
|
|
|
|
|
{ _current_user && (_current_user.admin === true || _current_user.user_id === author_info.user_id) &&
|
|
|
|
|
<div className="edu-position-hidebox" style={{position: 'absolute', right: '12px',top:'4px'}}>
|
|
|
|
|
<a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a>
|
|
|
|
|
<ul className="edu-position-hide undis">
|
|
|
|
|
{ current_user.admin === true &&
|
|
|
|
|
{ _current_user.admin === true &&
|
|
|
|
|
( memo.sticky === true ?
|
|
|
|
|
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li>
|
|
|
|
|
:
|
|
|
|
@ -701,15 +718,22 @@ class MemoDetail extends Component {
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
<Link className={`task-hide fr return_btn color-grey-6 mt2 ${ current_user && (current_user.admin === true
|
|
|
|
|
|| current_user.user_id === author_info.user_id) ? '': 'no_mr'} `} to="/forums" >
|
|
|
|
|
<Link className={`task-hide fr return_btn color-grey-6 mt2 ${ _current_user && (_current_user.admin === true
|
|
|
|
|
|| _current_user.user_id === author_info.user_id) ? '': 'no_mr'} `} to="/forums"
|
|
|
|
|
style={{ marginRight: '10px'}}
|
|
|
|
|
>
|
|
|
|
|
返回
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="color-grey-9 clearfix">
|
|
|
|
|
<span className="fl">{moment(memo.time).fromNow()} 发布</span>
|
|
|
|
|
<div className="fr">
|
|
|
|
|
{ current_user.admin && <Tooltip title={ "帖子奖励" }>
|
|
|
|
|
<div className="fr detailIcons">
|
|
|
|
|
<style>{`
|
|
|
|
|
.detailIcons i{
|
|
|
|
|
vertical-align: sub;
|
|
|
|
|
}
|
|
|
|
|
`}</style>
|
|
|
|
|
{ _current_user.admin && <Tooltip title={ "帖子奖励" }>
|
|
|
|
|
<span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}>
|
|
|
|
|
<i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i>
|
|
|
|
|
</span>
|
|
|
|
@ -770,7 +794,7 @@ class MemoDetail extends Component {
|
|
|
|
|
<span className="count">{memo.replies_count}</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Comments comments={comments} user={current_user}
|
|
|
|
|
<Comments comments={comments} user={_current_user}
|
|
|
|
|
replyComment={this.replyComment}
|
|
|
|
|
deleteComment={this.deleteComment}
|
|
|
|
|
commentPraise={this.commentPraise}
|
|
|
|
|