From bfbe89f43d1bfe2dbf7f138477ebe47918a57974 Mon Sep 17 00:00:00 2001 From: wyx Date: Sun, 19 Feb 2023 14:44:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=AE=A8=E8=AE=BAapi=E5=8F=8A=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api.js | 2 +- src/views/discuss/DiscussPage.vue | 55 ++++++----------------- src/views/discussdetail/DiscussDetail.vue | 20 +-------- 3 files changed, 17 insertions(+), 60 deletions(-) diff --git a/src/api/api.js b/src/api/api.js index b7edda3..2899a88 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -106,7 +106,7 @@ export const PostCollection = `/statement/collection post` // 帖子删除 export const PostDelete = postId => `/statement/delete?id=${postId} post` // 贴子点赞 -export const PostPraise = `/statement/praise post` +export const PostPraise = `/statement/praise` // 帖子更新 export const PostUpdate = `/statement/update post` diff --git a/src/views/discuss/DiscussPage.vue b/src/views/discuss/DiscussPage.vue index 691a203..b331500 100644 --- a/src/views/discuss/DiscussPage.vue +++ b/src/views/discuss/DiscussPage.vue @@ -67,8 +67,7 @@
+ :key="j">
{{ d.title }}
@@ -153,15 +152,12 @@ import { DISCUSS_LIST, QueryDiscussSubmitDetailByDiscussId, FILE_UPLOAD, - PostAdd, PostDelete, PostUpdate, PostList, - PostPraise, PostCollection, - } from "@/api/api"; import "@wangeditor/editor/dist/css/style.css"; @@ -181,11 +177,6 @@ const { query: { id, type, pName, sName }, } = useRoute(); -const param = ref({ - type, - id, -}); - const dialogVisible = ref(false); const titleName = ref(""); @@ -196,14 +187,12 @@ const state = reactive({ pageNo:1, pageSize:10, searchType:1, - postList: [], //帖子列表 total:0, // 帖子总条数 currentPage: 1, content: 1 }); - // 编辑器实例,必须用 shallowRef const editorRef = shallowRef(); @@ -238,7 +227,6 @@ request(DISCUSS_LIST, { type:type==1?2:1, id, }).then(e=>{ - console.log('112233---->',e) state.info = e.data; getPostList(e.data.discussDtoList[0].id); }).catch(err=>{ @@ -248,18 +236,16 @@ request(DISCUSS_LIST, { // 获取帖子 function getPostList(discussId) { console.log('获取帖子参数', { - "discussId": discussId, - "pageNo": state.pageNo, - "pageSize": state.pageSize, - "content": 1 + "pid": discussId, + "current": state.pageNo, + "order": 1 }) - request( PostList, { - "discussId": discussId, - "pageNo": state.pageNo, - "pageSize": state.pageSize + "pid": discussId, + "current": state.pageNo, + "order": state.content }).then(e=>{ console.log('我是当前讨论下的帖子',e) state.postList = e.data.records; @@ -285,7 +271,6 @@ function hotPost(discussId) { state.currentPage = 1; getPostList(discussId); } - // 分页 function handleCurrentChange(e, k) { console.log('分页打印', e, k) @@ -293,14 +278,13 @@ function handleCurrentChange(e, k) { state.pageNo = e; getPostList(state.info.discussDtoList[0].id); } - - +// 评论点击跳转 function comment({ discussId: id, id: postID }) { router.push({ path: "discussdetail", query: { id, type, pName, sName, postID, postName:state.info.discussDtoList[0].discussName } }); } - +// 帖子点赞 function like(d) { - d.praised ? ((d.praiseNum) -= 1) : ((d.praiseNum) += 1); + d.praised ? ((d.praiseNum) = Number(d.praiseNum) - 1) : ((d.praiseNum) = Number(d.praiseNum) + 1); d.praised = !d.praised; console.log('我是点赞传递的参数', { targetId: d.id, type: 2 }) request(PostPraise, { targetId: d.id, type: 3 }).then(res=>{ @@ -309,9 +293,9 @@ function like(d) { console.log(err) }); } - +// 帖子收藏 function collection(d) { - d.collected ? ((d.collectionNum) -= 1) : ((d.collectionNum) += 1); + d.collected ? ((d.collectionNum) = Number(d.collectionNum) - 1) : ((d.collectionNum) = Number(d.collectionNum) + 1); d.collected = !d.collected; console.log('我是收藏传递的参数', { targetId: d.id, type: 2 }) request(PostPraise, { targetId: d.id, type: 4 }).then(res=>{ @@ -320,22 +304,15 @@ function collection(d) { console.log(err) }); } - - -// 发表帖子 - +// 发表帖子弹框显示 function showPostModal() { dialogVisible.value = true; } - // 取消发布 function cancelPost() { dialogVisible.value = false; } - - -// ------------------------------- -// 发表帖子 +// 发表帖子发布操作 const postAdd = () => { console.log('用户信息', userInfo.value) let obj = { @@ -355,7 +332,6 @@ const postAdd = () => { "userName": userInfo.value.realName, "userOrgName": userInfo.value.orgName } - console.log('发表帖子传递的参数', obj) request(PostAdd,obj).then(res=>{ console.log(res) @@ -370,9 +346,6 @@ const postAdd = () => { console.log(err) }) } - -// ------------------------------- -