jwyu 3 年之前
父節點
當前提交
f1ee641a12
共有 2 個文件被更改,包括 54 次插入41 次删除
  1. 50 33
      src/components/Comment.vue
  2. 4 8
      src/components/Notice.vue

+ 50 - 33
src/components/Comment.vue

@@ -109,12 +109,34 @@ const getMyCommnet=async ()=>{
     })
     if(res.code===200){
         myCommentList.value=res.data.list||[]
-        if(route.query.frompage==='message'){
-            await nextTick()
-            const h=$('.comment-list-wrap').offset().top
-            console.log(h);
-            $('body,html').animate({scrollTop:h}, 300, 'swing');
+    }
+}
+
+//获取精选留言
+let hotCommentList=reactive({
+    list:[],
+    page:1,
+    pageSize:20,
+    finished:false,
+    loading:false
+})
+const getHotCommentList=async ()=>{
+    hotCommentList.loading=true
+    const res=await apiReportHotCommentList({
+        report_id:Number(props.data.report_id),
+        report_chapter_id:Number(props.data.report_chapter_id),
+        old_report_id:Number(props.data.old_report_id),
+        old_report_chapter_id:Number(props.data.old_report_chapter_id),
+        current_index:hotCommentList.page,
+        page_size:hotCommentList.pageSize
+    })
+    hotCommentList.loading=false
+    if(res.code===200){
+        if(res.data.paging.is_end){
+            hotCommentList.finished=true
         }
+        const arr=res.data.list||[]
+        hotCommentList.list=[...hotCommentList.list,...arr]
     }
 }
 
@@ -137,7 +159,7 @@ const handleDelMyComment=(item)=>{
         }).then(res=>{
             if(res.code===200){
                 ElMessage.success('删除成功')
-                getMyCommnet()
+                formatCommentList(item.comment_id)
             }
         })
     }).catch(()=>{
@@ -145,31 +167,20 @@ const handleDelMyComment=(item)=>{
     })
 }
 
-//获取精选留言
-let hotCommentList=reactive({
-    list:[],
-    page:1,
-    pageSize:20,
-    finished:false,
-    loading:false
-})
-const getHotCommentList=async ()=>{
-    hotCommentList.loading=true
-    const res=await apiReportHotCommentList({
-        report_id:Number(props.data.report_id),
-        report_chapter_id:Number(props.data.report_chapter_id),
-        old_report_id:Number(props.data.old_report_id),
-        old_report_chapter_id:Number(props.data.old_report_chapter_id),
-        current_index:hotCommentList.page,
-        page_size:hotCommentList.pageSize
-    })
-    hotCommentList.loading=false
-    if(res.code===200){
-        if(res.data.paging.is_end){
-            hotCommentList.finished=true
-        }
-        const arr=res.data.list||[]
-        hotCommentList.list=[...hotCommentList.list,...arr]
+//删除留言后 更新我的留言和精选留言数据
+const formatCommentList=(id)=>{
+    // 我的留言列表
+    if(myCommentList.value.length>0){
+        myCommentList.value=myCommentList.value.filter(item=>{
+            return item.comment_id!=id
+        })
+    }
+    
+    // 精选留言
+    if(hotCommentList.list.length>0){
+        hotCommentList.list=hotCommentList.list.filter(item=>{
+            return item.comment_id!=id
+        })
     }
 }
 
@@ -256,7 +267,7 @@ onMounted(() => {
         <template v-if="hotCommentList.list.length>0">
             <ul class="comment-list-box hot-comment-box">
                 <p class="label">精选留言</p>
-                <li class="flex comment-item" v-for="item in hotCommentList.list" :key="item.comment_id">
+                <li class="flex comment-item" v-for="(item,index) in hotCommentList.list" :key="item.comment_id">
                     <el-image 
                         class="avatar" 
                         style="width: 46px; height: 46px" 
@@ -264,6 +275,9 @@ onMounted(() => {
                         fit="cover" 
                     />
                     <div class="comment-con">
+                        <div class="right-box" v-if="item.user_id==$store.state.userInfo.user_id">
+                            <span class="del-btn2" @click="handleDelMyComment(item,index)">删除</span>
+                        </div>
                         <div :class="['user-name',item.IsTop==1&&'is-top']">{{item.user_name}}</div>
                         <div class="commment-msg">{{item.content}}</div>
                         <ul>
@@ -422,7 +436,7 @@ onMounted(() => {
                     color: #999;
                 }
             }
-            .del-btn{
+            .del-btn,.del-btn2{
                 display: none;
                 cursor: pointer;
                 color: #F3A52F;
@@ -435,6 +449,9 @@ onMounted(() => {
                     margin-right: 5px;
                 }
             }
+            &:hover .del-btn2{
+                display: inline-block;
+            }
             .user-name{
                 font-size: 18px;
                 color: #999;

+ 4 - 8
src/components/Notice.vue

@@ -144,8 +144,7 @@ const handleGoDetail=async (item)=>{
             path:'/activity/chapterdetail',
             query:{
                 research_report_type_id:item.old_report_chapter_id,
-                research_report_id:item.old_report_id,
-                frompage:'message'
+                research_report_id:item.old_report_id
             }
         })
         return
@@ -155,8 +154,7 @@ const handleGoDetail=async (item)=>{
         router.push({
             path:'/activity/reportdetail',
             query:{
-                research_report_id:item.old_report_id,
-                frompage:'message'
+                research_report_id:item.old_report_id
             }
         })
         return
@@ -166,8 +164,7 @@ const handleGoDetail=async (item)=>{
         router.push({
             path:'/report/chapterdetail',
             query:{
-                chapterId:item.report_chapter_id,
-                frompage:'message'
+                chapterId:item.report_chapter_id
             }
         })
         return 
@@ -177,8 +174,7 @@ const handleGoDetail=async (item)=>{
         router.push({
             path:'/report/detail',
             query:{
-                reportId:item.report_id,
-                frompage:'message'
+                reportId:item.report_id
             }
         })
         return