Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
feat: (#246) 圈子帖子评论可以申请置顶了
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jun 29, 2018
1 parent d1b9a0f commit 93830c8
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/api/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ export function getPostCommentAudits({ after = 0, post = 0 }) {
});
}

/**
* 申请评论置顶
* @author mutoe <[email protected]>
* @export
* @param {Object} payload
* @param {Number} payload.postId
* @param {Number} payload.commentId
* @param {Object} data
* @param {Number} data.amount
* @param {Number} data.day
* @returns {Promise}
*/
export function applyTopPostComment({ postId, commentId }, data) {
const url = `/plus-group/currency-pinned/comments/${commentId}`;
Object.assign(data, { post_id: postId });
return api.post(url, data, { validateStatus: s => s === 201 });
}

/**
* 删除帖子评论
* @author mutoe <[email protected]>
Expand Down
27 changes: 26 additions & 1 deletion src/components/FeedCard/GroupFeedCard.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import bus from "@/bus.js";
import FeedCard from "./FeedCard.vue";
import { collectGroupPost } from "@/api/group.js";
import { collectGroupPost, applyTopPostComment } from "@/api/group.js";
export default {
name: "group-feed-card",
extends: FeedCard,
Expand Down Expand Up @@ -66,6 +66,31 @@ export default {
}
];
bus.$emit("actionSheet", [...base], "取消");
},
commentAction({ isMine = false, placeholder, reply_user, comment }) {
isMine
? bus.$emit("actionSheet", [
{
text: "申请评论置顶",
method: () => {
bus.$emit("applyTop", {
type: "postComment",
api: applyTopPostComment,
payload: { postId: this.feedID, commentId: comment.id }
});
}
},
{
text: "删除评论",
method: () => {
console.log("删除评论");
}
}
])
: this.handleComment({
placeholder,
reply_user
});
}
},
computed: {
Expand Down
31 changes: 28 additions & 3 deletions src/page/group/GroupPostDetail.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script>
import bus from "@/bus.js";
import markdownIt from "markdown-it";
import plusImagePlugin from "markdown-it-plus-image";
import FeedDetail from "../feed/feedDetail.vue";
import bus from "@/bus.js";
import wechatShare from "@/util/wechatShare.js";
import { limit } from "@/api/api.js";
import {
likeGroupPost,
collectGroupPost,
applyTopPostComment,
deletePostComment
} from "@/api/group.js";
import wechatShare from "@/util/wechatShare.js";
export default {
name: "group-post-detail",
Expand Down Expand Up @@ -236,6 +236,31 @@ export default {
this.fetching = false;
});
},
replyComment(uid, uname, commentId) {
if (uid === this.CURRENTUSER.id) {
const actionSheet = [
{
text: "申请评论置顶",
method: () => {
bus.$emit("applyTop", {
type: "postComment",
api: applyTopPostComment,
payload: { postId: Number(this.postID), commentId }
});
}
},
{ text: "删除评论", method: () => this.deleteComment(commentId) }
];
bus.$emit("actionSheet", actionSheet, "取消");
} else {
bus.$emit("commentInput", {
placeholder: `回复: ${uname}`,
onOk: text => {
this.sendComment({ reply_user: uid, body: text });
}
});
}
},
sendComment({ reply_user: replyUser, body }) {
const params = {};
if (body && body.length > 0) {
Expand Down

0 comments on commit 93830c8

Please sign in to comment.