-
+
-
+
+
+
@@ -297,9 +317,11 @@ import {
PostCollection,
GetComments,
- PostDetails
+ PostDetails,
+ GetMoreComments
} from "@/api/api";
import UploadPostImg from "@/components/img/UploadPostImg.vue";
+import { height } from "dom7";
const router = useRouter();
const refInput =ref()
@@ -314,10 +336,10 @@ const {
query: { id, discussSubmitId, type, pName, sName, postID, postName },
} = useRoute();
-const { data: commontList, fetchData: commonFetch } = usePage(COMMENT_LIST, {
- id,
- type: 1,
-});
+// const { data: commontList, fetchData: commonFetch } = usePage(COMMENT_LIST, {
+// id,
+// type: 1,
+// });
// const { data: disDetail } = useRequest(DISCUSS_DETAIL, { id, type });
@@ -353,30 +375,71 @@ const handleCreated = (editor) => {
const disDetail = ref({});
+const commontList = ref([]);
+const spreadReply = ref(-1);
-useRequest(PostDetails, {id:postID}, (e)=>{
- console.log(e)
- disDetail.value = e.data
- console.log('查询帖子下的评论参数',{
- statementId:e.data.discussId,
- pageNo:10,
- pageSize:1
- })
- // 获取帖子下的评论
- request(GetComments,{
- statementId:e.data.id,
- pageNo:10,
- pageSize:1
- }).then(res=>{
- console.log('我是获取当前帖子的评论', res)
- }).catch(err=>{
- console.log(err)
- })
+// 查看更多
+function lookMore(i) {
+ i == spreadReply.value ? spreadReply.value = -1 : spreadReply.value = i;
+}
+// 清空回复输入框
+const clearText = () => {
+ disComment.value.content = "";
+ fileListComment.value = [];
+ fileListCommentRelpay.value = [];
+ replayComment.value.content = "";
+}
+
+const hfPage = ref({
+ currentPage: 1,
+ pageNo: 1,
+ pageSize: 10,
+ total: 0
})
+// 回复分页
+function handleCurrentChange(e, k) {
+ console.log('分页打印', e, k)
+ hfPage.value.currentPage = e;
+ hfPage.value.pageNo = e;
+ getData();
+}
+
+// 清空评论回复输入框
+const clearApplyText = () => {
+
+}
+
+// 获取数据
+const getData = () => {
+ useRequest(PostDetails, {id:postID}, (e)=>{
+ console.log(e)
+ disDetail.value = e.data
+ console.log('查询帖子下的评论参数',{
+ statementId:e.data.discussId,
+ pageNo:10,
+ pageSize:1
+ })
+ // 获取帖子下的评论
+ request(COMMENT_LIST, {
+ id: e.data.id,
+ type: 1,
+ pageNo:hfPage.value.currentPage,
+ pageSize:10
+ }).then(res=>{
+ console.log('我是获取当前帖子的评论', res)
+ commontList.value = res.data.records;
+ hfPage.value.total = Number(res.data.total);
+ clearText()
+ }).catch(err=>{
+ console.log(err)
+ })
+ })
+}
+
+getData()
-const fileList = ref([]);
const commentSubmitFileList = ref([]);
const disComment = ref({
@@ -388,79 +451,6 @@ const replayComment = ref({
pid: "",
});
-function removeImg(i) {
- fileList.value.splice(i, 1);
-}
-
-function removeCommentImg(i) {
- fileListComment.value.splice(i, 1);
-}
-
-function like() {
- disDetail.value.praised
- ? (disDetail.value.praiseNum -= 1)
- : (disDetail.value.praiseNum += 1);
- disDetail.value.praised = !disDetail.value.praised;
- request(COMMENT_PRAISE, { targetId: disDetail.value.discussId, type: 5 });
-}
-
-function collection() {
- disDetail.value.collected
- ? (disDetail.value.collectionNum -= 1)
- : (disDetail.value.collectionNum += 1);
- disDetail.value.collected = !disDetail.value.collected;
- request(COMMENT_COLLECTION, { targetId: disDetail.value.discussId, type: 6 });
-}
-
-function commentLike(obj) {
- obj.praised ? (obj.praiseNum -= 1) : (obj.praiseNum += 1);
- obj.praised = !obj.praised;
- request(COMMENT_PRAISE, { targetId: obj.id, type: 5 });
-}
-
-function commentComment(obj) {
- replayComment.value.placeholder = "@ " + obj.userName;
- replayComment.value.pid = obj.id;
-}
-
-function submitComment() {
- console.log(disDetail.value)
- console.log('帖子评论参数',{
- targetId: disDetail.value.id,
- content: disComment.value.content,
- type: 1,
- })
- request(COMMENT_ADD, {
- targetId: disDetail.value.id,
- content: disComment.value.content,
- type: 1,
- }).then((res) => {
- console.log(res)
- commonFetch();
- }).catch(err=>{
- console.log(err)
- });
-}
-
-function submitReplayComment() {
- console.log('帖子回复评论参数',{
- targetId: disDetail.value.discussId,
- content: disComment.value.content,
- type: 2,
- })
- request(COMMENT_ADD, {
- targetId: disDetail.value.discussId,
- content: replayComment.value.content,
- type: 2,
- pid: replayComment.value.pid,
- }).then((res) => {
- console.log(res)
- commonFetch();
- }).catch(err=>{
- console.log(err)
- });
-}
-
// 评论图片展示数组
const fileListComment = ref([]);
// 回复图片展示数组
@@ -471,6 +461,108 @@ const uploadBack = (e) => {
console.log('--------->', e)
fileListComment.value.push(e)
}
+
+const uploadReplyBack = (e) => {
+ console.log('--------->', e)
+ fileListCommentRelpay.value.push(e)
+}
+
+function removeImg(i) {
+ fileListCommentRelpay.value.splice(i, 1);
+}
+
+function removeCommentImg(i) {
+ fileListComment.value.splice(i, 1);
+}
+
+function like() {
+ console.log(disDetail.value)
+ disDetail.value.praised
+ ? (disDetail.value.praiseNum = Number(disDetail.value.praiseNum) - 1)
+ : (disDetail.value.praiseNum = Number(disDetail.value.praiseNum) + 1);
+ disDetail.value.praised = !disDetail.value.praised;
+ request(COMMENT_PRAISE, { targetId: disDetail.value.id, type: 1 });
+}
+
+function collection() {
+ disDetail.value.collectionInfo
+ ? (disDetail.value.collectionNum = Number(disDetail.value.collectionNum) - 1)
+ : (disDetail.value.collectionNum = Number(disDetail.value.collectionNum) + 1);
+ disDetail.value.collectionInfo = !disDetail.value.collectionInfo;
+ request(COMMENT_PRAISE, { targetId: disDetail.value.id, type: 2 });
+}
+
+function commentLike(obj) {
+ obj.praised ? (obj.praiseNum = Number(obj.praiseNum) - 1) : (obj.praiseNum = Number(obj.praiseNum) + 1);
+ obj.praised = !obj.praised;
+ request(COMMENT_PRAISE, { targetId: obj.id, type: 1 });
+}
+
+function commentComment(obj) {
+ console.log(obj)
+ replayComment.value.placeholder = "@ " + obj.createName;
+ replayComment.value.pid = obj.id;
+}
+
+// 提交评论
+function submitComment() {
+ console.log(disDetail.value, fileListComment.value)
+ let imgFileUrl = []
+ for(let i=0;i
{
+ console.log(res)
+ getData();
+ }).catch(err=>{
+ console.log(err)
+ });
+}
+
+// 回复评论
+function submitReplayComment() {
+ let imgFileUrl = []
+ for(let i=0;i {
+ console.log(res)
+ getData();
+ }).catch(err=>{
+ console.log(err)
+ });
+}
+
+