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

Commit

Permalink
chore: 删除动态接口移入接口文件中
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jun 29, 2018
1 parent 1e593fd commit 4b18817
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 52 deletions.
25 changes: 25 additions & 0 deletions src/api/feeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ export function getFeedsByType(type, limit = 15, after) {
);
}

/**
* 申请动态置顶
* @author mutoe <[email protected]>
* @export
* @param {Number} feedId
* @param {Object} params
* @returns {Promise}
*/
export function applyTopFeed(feedId, params) {
return api.post(`/feeds/${feedId}/currency-pinneds`, params, {
validateStatus: s => s === 201
});
}

/**
* 删除动态
* @author mutoe <[email protected]>
* @export
* @param {Number} feedId
* @returns {Promise}
*/
export function deleteFeed(feedId) {
return api.delete(`/feeds/${feedId}`, { validateStatus: s => s === 204 });
}

/**
* 获取当前用户收藏的动态
* @type {Number}
Expand Down
45 changes: 18 additions & 27 deletions src/components/FeedCard/FeedCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@
<script>
import bus from "@/bus.js";
import { mapState } from "vuex";
import { time2txt } from "@/filters.js";
import FeedImage from "./FeedImage.vue";
import FeedVideo from "./FeedVideo.vue";
import CommentItem from "./CommentItem.vue";
import { time2txt } from "@/filters.js";
import { deleteFeed } from "@/api/feeds.js";
export default {
name: "feed-card",
components: {
Expand Down Expand Up @@ -299,34 +301,23 @@ export default {
{
text: "删除动态",
method: () => {
// DELETE /feeds/:feed
setTimeout(() => {
bus.$emit(
"actionSheet",
[
{
text: "删除",
style: {
color: "#f4504d"
},
method: () => {
this.$http
.delete(`/feeds/${this.feedID}`, {
validataStatus: s => s === 204
})
.then(() => {
this.$Message.success("删除动态成功");
this.$nextTick(() => {
this.$el.remove();
this.$emit("afterDelete");
});
});
}
const actionSheet = [
{
text: "删除",
style: { color: "#f4504d" },
method: () => {
deleteFeed(this.feedID).then(() => {
this.$Message.success("删除动态成功");
this.$nextTick(() => {
this.$el.remove();
this.$emit("afterDelete");
});
});
}
],
"取消",
"确认删除?"
);
}
];
bus.$emit("actionSheet", actionSheet, "取消", "确认删除?");
}, 200);
}
}
Expand Down
43 changes: 18 additions & 25 deletions src/page/feed/feedDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ import ArticleCard from "@/page/article/ArticleCard.vue";
import CommentItem from "@/page/article/ArticleComment.vue";
import wechatShare from "@/util/wechatShare.js";
import { limit } from "@/api/api.js";
import { getFeedComments, deleteFeedComment } from "@/api/feeds.js";
import {
deleteFeed,
getFeedComments,
deleteFeedComment
} from "@/api/feeds.js";
import { followUserByStatus, getUserInfoById } from "@/api/user.js";
export default {
Expand Down Expand Up @@ -472,33 +476,22 @@ export default {
}
},
{
text: "删除",
text: "删除动态",
method: () => {
// DELETE /feeds/:feed
setTimeout(() => {
bus.$emit(
"actionSheet",
[
{
text: "删除",
style: {
color: "#f4504d"
},
method: () => {
this.$http
.delete(`/feeds/${this.feedID}`, {
validataStatus: s => s === 204
})
.then(() => {
this.$Message.success("删除动态成功");
this.goBack();
});
}
const actionSheet = [
{
text: "删除",
style: { color: "#f4504d" },
method: () => {
deleteFeed(this.feedID).then(() => {
this.$Message.success("删除动态成功");
this.goBack();
});
}
],
"取消",
"确认删除?"
);
}
];
bus.$emit("actionSheet", actionSheet, "取消", "确认删除?");
}, 200);
}
}
Expand Down

0 comments on commit 4b18817

Please sign in to comment.