feat:讨论api及参数修改

This commit is contained in:
wyx
2023-02-19 14:44:34 +08:00
parent e43a5db9ed
commit bfbe89f43d
3 changed files with 17 additions and 60 deletions

View File

@@ -106,7 +106,7 @@ export const PostCollection = `/statement/collection post`
// 帖子删除 // 帖子删除
export const PostDelete = postId => `/statement/delete?id=${postId} 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` export const PostUpdate = `/statement/update post`

View File

@@ -67,8 +67,7 @@
<div <div
class="discusslist" class="discusslist"
v-for="(d, j) in state?.postList" v-for="(d, j) in state?.postList"
:key="j" :key="j">
>
<div class="itemtitle" @click="comment(d)">{{ d.title }}</div> <div class="itemtitle" @click="comment(d)">{{ d.title }}</div>
<div class="itemdiscuss" @click="comment(d)" :v-html="d.content"></div> <div class="itemdiscuss" @click="comment(d)" :v-html="d.content"></div>
<div class="allstar clearfix"> <div class="allstar clearfix">
@@ -153,15 +152,12 @@ import {
DISCUSS_LIST, DISCUSS_LIST,
QueryDiscussSubmitDetailByDiscussId, QueryDiscussSubmitDetailByDiscussId,
FILE_UPLOAD, FILE_UPLOAD,
PostAdd, PostAdd,
PostDelete, PostDelete,
PostUpdate, PostUpdate,
PostList, PostList,
PostPraise, PostPraise,
PostCollection, PostCollection,
} from "@/api/api"; } from "@/api/api";
import "@wangeditor/editor/dist/css/style.css"; import "@wangeditor/editor/dist/css/style.css";
@@ -181,11 +177,6 @@ const {
query: { id, type, pName, sName }, query: { id, type, pName, sName },
} = useRoute(); } = useRoute();
const param = ref({
type,
id,
});
const dialogVisible = ref(false); const dialogVisible = ref(false);
const titleName = ref(""); const titleName = ref("");
@@ -196,14 +187,12 @@ const state = reactive({
pageNo:1, pageNo:1,
pageSize:10, pageSize:10,
searchType:1, searchType:1,
postList: [], //帖子列表 postList: [], //帖子列表
total:0, // 帖子总条数 total:0, // 帖子总条数
currentPage: 1, currentPage: 1,
content: 1 content: 1
}); });
// 编辑器实例,必须用 shallowRef // 编辑器实例,必须用 shallowRef
const editorRef = shallowRef(); const editorRef = shallowRef();
@@ -238,7 +227,6 @@ request(DISCUSS_LIST, {
type:type==1?2:1, type:type==1?2:1,
id, id,
}).then(e=>{ }).then(e=>{
console.log('112233---->',e)
state.info = e.data; state.info = e.data;
getPostList(e.data.discussDtoList[0].id); getPostList(e.data.discussDtoList[0].id);
}).catch(err=>{ }).catch(err=>{
@@ -248,18 +236,16 @@ request(DISCUSS_LIST, {
// 获取帖子 // 获取帖子
function getPostList(discussId) { function getPostList(discussId) {
console.log('获取帖子参数', { console.log('获取帖子参数', {
"discussId": discussId, "pid": discussId,
"pageNo": state.pageNo, "current": state.pageNo,
"pageSize": state.pageSize, "order": 1
"content": 1
}) })
request( request(
PostList, PostList,
{ {
"discussId": discussId, "pid": discussId,
"pageNo": state.pageNo, "current": state.pageNo,
"pageSize": state.pageSize "order": state.content
}).then(e=>{ }).then(e=>{
console.log('我是当前讨论下的帖子',e) console.log('我是当前讨论下的帖子',e)
state.postList = e.data.records; state.postList = e.data.records;
@@ -285,7 +271,6 @@ function hotPost(discussId) {
state.currentPage = 1; state.currentPage = 1;
getPostList(discussId); getPostList(discussId);
} }
// 分页 // 分页
function handleCurrentChange(e, k) { function handleCurrentChange(e, k) {
console.log('分页打印', e, k) console.log('分页打印', e, k)
@@ -293,14 +278,13 @@ function handleCurrentChange(e, k) {
state.pageNo = e; state.pageNo = e;
getPostList(state.info.discussDtoList[0].id); getPostList(state.info.discussDtoList[0].id);
} }
// 评论点击跳转
function comment({ discussId: id, id: postID }) { function comment({ discussId: id, id: postID }) {
router.push({ path: "discussdetail", query: { id, type, pName, sName, postID, postName:state.info.discussDtoList[0].discussName } }); router.push({ path: "discussdetail", query: { id, type, pName, sName, postID, postName:state.info.discussDtoList[0].discussName } });
} }
// 帖子点赞
function like(d) { 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; d.praised = !d.praised;
console.log('我是点赞传递的参数', { targetId: d.id, type: 2 }) console.log('我是点赞传递的参数', { targetId: d.id, type: 2 })
request(PostPraise, { targetId: d.id, type: 3 }).then(res=>{ request(PostPraise, { targetId: d.id, type: 3 }).then(res=>{
@@ -309,9 +293,9 @@ function like(d) {
console.log(err) console.log(err)
}); });
} }
// 帖子收藏
function collection(d) { 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; d.collected = !d.collected;
console.log('我是收藏传递的参数', { targetId: d.id, type: 2 }) console.log('我是收藏传递的参数', { targetId: d.id, type: 2 })
request(PostPraise, { targetId: d.id, type: 4 }).then(res=>{ request(PostPraise, { targetId: d.id, type: 4 }).then(res=>{
@@ -320,22 +304,15 @@ function collection(d) {
console.log(err) console.log(err)
}); });
} }
// 发表帖子弹框显示
// 发表帖子
function showPostModal() { function showPostModal() {
dialogVisible.value = true; dialogVisible.value = true;
} }
// 取消发布 // 取消发布
function cancelPost() { function cancelPost() {
dialogVisible.value = false; dialogVisible.value = false;
} }
// 发表帖子发布操作
// -------------------------------
// 发表帖子
const postAdd = () => { const postAdd = () => {
console.log('用户信息', userInfo.value) console.log('用户信息', userInfo.value)
let obj = { let obj = {
@@ -355,7 +332,6 @@ const postAdd = () => {
"userName": userInfo.value.realName, "userName": userInfo.value.realName,
"userOrgName": userInfo.value.orgName "userOrgName": userInfo.value.orgName
} }
console.log('发表帖子传递的参数', obj) console.log('发表帖子传递的参数', obj)
request(PostAdd,obj).then(res=>{ request(PostAdd,obj).then(res=>{
console.log(res) console.log(res)
@@ -370,9 +346,6 @@ const postAdd = () => {
console.log(err) console.log(err)
}) })
} }
// -------------------------------
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -312,10 +312,8 @@ import {
PostDelete, PostDelete,
PostUpdate, PostUpdate,
PostList, PostList,
PostPraise, PostPraise,
PostCollection, PostCollection,
GetComments, GetComments,
PostDetails, PostDetails,
GetMoreComments GetMoreComments
@@ -336,13 +334,6 @@ const {
query: { id, discussSubmitId, type, pName, sName, postID, postName }, query: { id, discussSubmitId, type, pName, sName, postID, postName },
} = useRoute(); } = useRoute();
// const { data: commontList, fetchData: commonFetch } = usePage(COMMENT_LIST, {
// id,
// type: 1,
// });
// const { data: disDetail } = useRequest(DISCUSS_DETAIL, { id, type });
// 编辑器实例,必须用 shallowRef // 编辑器实例,必须用 shallowRef
const editorRef = shallowRef(); const editorRef = shallowRef();
@@ -373,17 +364,16 @@ const handleCreated = (editor) => {
editorRef.value = editor; // 记录 editor 实例,重要! editorRef.value = editor; // 记录 editor 实例,重要!
}; };
const disDetail = ref({}); const disDetail = ref({});
const commontList = ref([]); const commontList = ref([]);
const spreadReply = ref(-1); const spreadReply = ref(-1);
// 查看更多 // 查看更多-展开回复列表
function lookMore(i) { function lookMore(i) {
i == spreadReply.value ? spreadReply.value = -1 : spreadReply.value = i; i == spreadReply.value ? spreadReply.value = -1 : spreadReply.value = i;
} }
// 清空回复输入框 // 清空回复及评论输入框
const clearText = () => { const clearText = () => {
disComment.value.content = ""; disComment.value.content = "";
fileListComment.value = []; fileListComment.value = [];
@@ -406,11 +396,6 @@ function handleCurrentChange(e, k) {
getData(); getData();
} }
// 清空评论回复输入框
const clearApplyText = () => {
}
// 获取数据 // 获取数据
const getData = () => { const getData = () => {
useRequest(PostDetails, {id:postID}, (e)=>{ useRequest(PostDetails, {id:postID}, (e)=>{
@@ -562,7 +547,6 @@ function submitReplayComment() {
}); });
} }
</script> </script>
<style lang="scss"> <style lang="scss">