From 87f9681c23c2fd49fed17d6fd8316b1a7d2895e6 Mon Sep 17 00:00:00 2001 From: mutoe Date: Mon, 12 Nov 2018 17:39:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20(#608)=20=E4=B8=BE=E6=8A=A5=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.js | 14 ++++++++++++++ src/components/Report.vue | 6 ++++-- src/page/UserHome.vue | 22 ++++++++++++++++++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/api/user.js b/src/api/user.js index 04a6a5cf..b51acf67 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -274,3 +274,17 @@ export function patchCertification(payload) { export function getUserVerifyInfo() { return api.get("/user/certification", { validateStatus: s => s === 200 }); } + +/** + * 举报用户 + * + * @author mutoe + * @export + * @param {number} userId + * @param {string} reason + * @returns + */ +export function reportUser(userId, reason) { + const url = `/report/users/${userId}`; + return api.post(url, { reason }, { validateStatus: s => s === 201 }); +} diff --git a/src/components/Report.vue b/src/components/Report.vue index f9995b99..7c215bcf 100644 --- a/src/components/Report.vue +++ b/src/components/Report.vue @@ -9,7 +9,7 @@
-

举报 {{ username }} 的{{ typeText }}

+

举报 {{ username }} {{ typeText ? `的${typeText}` : '' }}

{{ reference }}
@@ -39,6 +39,7 @@ import { noop } from "@/util"; import { reportFeed } from "@/api/feeds"; import { reportNews } from "@/api/news"; import { reportPost, reportPostComment } from "@/api/group"; +import { reportUser } from "@/api/user"; import { reportComment } from "@/api"; import TextareaInput from "@/components/common/TextareaInput"; @@ -47,7 +48,8 @@ const apiMap = { news: reportNews, post: reportPost, postComment: reportPostComment, - comment: reportComment + comment: reportComment, + user: reportUser }; export default { diff --git a/src/page/UserHome.vue b/src/page/UserHome.vue index cc73b45c..17a0c40c 100644 --- a/src/page/UserHome.vue +++ b/src/page/UserHome.vue @@ -22,9 +22,9 @@ {{ user.name }}
- + + +
@@ -461,7 +461,6 @@ export default { this.tags = data; }); }, - fetchUserFeed(loadmore) { if (this.fetchFeeding) return; this.fetchFeeding = true; @@ -564,6 +563,21 @@ export default { stopDrag() { this.dragging = false; this.dY > 300 && this.scrollTop <= 0 ? this.updateData() : (this.dY = 0); + }, + onMoreClick() { + const actions = []; + actions.push({ + text: "举报", + method: () => { + this.$bus.$emit("report", { + type: "user", + payload: this.userID, + username: this.user.name, + reference: this.user.bio + }); + } + }); + this.$bus.$emit("actionSheet", actions); } } };