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 e48fec1 commit 5f11ee0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
17 changes: 17 additions & 0 deletions src/api/feeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ export function getFeedCommentPinneds(after = 0) {
});
}

/**
* 评论申请置顶
* @author mutoe <[email protected]>
* @export
* @param {Object} payload 第一个参数
* @param {Number} payload.feedId
* @param {Number} payload.commentId
* @param {Object} data post入参
* @param {Number} data.amount 置顶总价
* @param {Number} data.day 置顶天数
* @returns Promise
*/
export function applyTopFeedComment({ feedId, commentId }, data) {
const url = `/feeds/${feedId}/comments/${commentId}/currency-pinneds`;
return api.post(url, data, { validateStatus: s => s === 201 });
}

/**
* 删除动态评论
* @author mutoe <[email protected]>
Expand Down
11 changes: 5 additions & 6 deletions src/components/FeedCard/CommentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<router-link tag="span" :to="`/users/${user.id}`" exact class='m-comment-usr'>
<a>{{ user.name }}</a>
</router-link>
<span class="m-comment-usr" v-if="replyUser">回复<router-link :to='`/users/${replyUser.id}`'>{{ replyUser.name }}</router-link></span>
<span class="m-comment-usr" v-if="replyUser">
回复<router-link :to='`/users/${replyUser.id}`'>{{ replyUser.name }}</router-link>
</span>
<span class="m-comment-body" @click="handelClick">{{ body }}</span>
<span v-if="pinned" class="m-art-comment-icon-top" style="margin-left: 5px; height: auto">置顶</span>
</p>
Expand All @@ -12,10 +14,7 @@
export default {
name: "comment-item",
props: {
comment: {
type: Object,
required: true
}
comment: { type: Object, required: true }
},
computed: {
isMine() {
Expand Down Expand Up @@ -46,7 +45,7 @@ export default {
placeholder: `回复${this.user.name}`,
reply_user: this.user.id
};
this.$emit("click", p);
this.$emit("click", Object.assign({ comment: this.comment }, p));
}
},
mounted() {
Expand Down
10 changes: 7 additions & 3 deletions src/components/FeedCard/FeedCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import FeedImage from "./FeedImage.vue";
import FeedVideo from "./FeedVideo.vue";
import CommentItem from "./CommentItem.vue";
import { time2txt } from "@/filters.js";
import { deleteFeed, applyTopFeed } from "@/api/feeds.js";
import { deleteFeed, applyTopFeed, applyTopFeedComment } from "@/api/feeds.js";
export default {
name: "feed-card",
Expand Down Expand Up @@ -337,13 +337,17 @@ export default {
];
bus.$emit("actionSheet", [...base, ...actions], "取消");
},
commentAction({ isMine = false, placeholder, reply_user }) {
commentAction({ isMine = false, placeholder, reply_user, comment }) {
isMine
? bus.$emit("actionSheet", [
{
text: "申请评论置顶",
method: () => {
console.log("申请评论置顶");
bus.$emit("applyTop", {
type: "feedComment",
api: applyTopFeedComment,
payload: { feedId: this.feedID, commentId: comment.id }
});
}
},
{
Expand Down
7 changes: 6 additions & 1 deletion src/page/feed/feedDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ import {
deleteFeed,
getFeedComments,
deleteFeedComment,
applyTopFeedComment,
applyTopFeed
} from "@/api/feeds.js";
Expand Down Expand Up @@ -517,7 +518,11 @@ export default {
{
text: "申请评论置顶",
method: () => {
this.$Message.info("置顶功能开发中,敬请期待");
bus.$emit("applyTop", {
type: "feedComment",
api: applyTopFeedComment,
payload: { feedId: this.feedID, commentId }
});
}
},
{ text: "删除评论", method: () => this.deleteComment(commentId) }
Expand Down

0 comments on commit 5f11ee0

Please sign in to comment.