wbspool 4 anos atrás
pai
commit
bc60e37b6f

+ 2 - 0
src/common/config/api.js

@@ -21,6 +21,8 @@ const api = {
         subscribe:`${root}/cms/subscribe`,
         like:`${root}/cms/like`,
         collect:`${root}/cms/collect`,
+        comment:`${root}/cms/comment`,
+        listComments:`${root}/cms/listComments`,
     },
     mzUser:{
         login:`${root}/mzUser/login`,

+ 2 - 0
src/pc/components.d.ts

@@ -12,6 +12,7 @@ declare module '@vue/runtime-core' {
     Hero: typeof import('./components/Hero.vue')['default']
     HomeNew: typeof import('./pages/home/_components/home-new.vue')['default']
     HomeTags: typeof import('./pages/home/_components/home-tags.vue')['default']
+    HotArticle: typeof import('./components/ui-hot-artcile/HotArticle.vue')['default']
     LayoutBasic: typeof import('./components/layout-basic/layout-basic.vue')['default']
     LayoutUser: typeof import('./components/layout-user/layout-user.vue')['default']
     LayoutUserHeader: typeof import('./components/layout-user/layout-user-header.vue')['default']
@@ -21,6 +22,7 @@ declare module '@vue/runtime-core' {
     RouterView: typeof import('vue-router')['RouterView']
     TimeLimitBtn: typeof import('./components/TimeLimitBtn.vue')['default']
     UiDevider: typeof import('./components/ui-devider/ui-devider.vue')['default']
+    UiHotArticle: typeof import('./components/ui-hot-artcile/ui-hot-article.vue')['default']
     UiInput: typeof import('./components/ui-input/ui-input.vue')['default']
     UiMainArticle: typeof import('./components/ui-main-article/ui-main-article.vue')['default']
     UiNavBar: typeof import('./components/ui-nav-bar/ui-nav-bar.vue')['default']

+ 53 - 0
src/pc/components/ui-hot-artcile/ui-hot-article.vue

@@ -0,0 +1,53 @@
+<template>
+    <div class="px-20px bg-white">
+        <div class="h-17px"></div>
+        <div class="relative inline-flex mb-6.5px">
+            <img src="/imgs/hot.png" class="w-24px h-auto mr-4px"/>
+            <div class="font-thin text-[#000] text-size-20px">{{ $t("热榜文章") }}</div>
+
+            <div
+                    class="w-full h-3px absolute left-0 bottom-[-7.5px] bg-primary rounded-full"
+            ></div>
+        </div>
+        <ui-devider></ui-devider>
+        <div class="h-21px"></div>
+        <ui-swiper
+                class="mb-20px"
+                :items="[
+              { url: '/imgs/article_cover1.png', title: '这是标题' },
+              { url: '/imgs/article_cover1.png', title: '这是标题' },
+            ]"
+                titleClass="swiper-title"
+        ></ui-swiper>
+        <ui-devider></ui-devider>
+
+        <div v-for="item in cmsArticles" :key="item">
+            <ui-small-article :item="item"></ui-small-article>
+            <ui-devider></ui-devider>
+        </div>
+    </div>
+</template>
+
+<script>
+    export default {
+
+        data(){
+            return {
+                cmsArticles:[]
+            }
+        },
+        async created() {
+
+            let resp = await  this.$http.post(this.$api.cms.articles);
+            if(resp.data.status === 200){
+                this.cmsArticles = resp.data.data.cmsArticles;
+            }
+
+        }
+
+    }
+</script>
+
+<style  scoped>
+
+</style>

+ 16 - 5
src/pc/components/ui-small-article/ui-small-article.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="flex bg-white items-center h-87px">
     <div class="relative">
-      <img class="w-116px h-65px object-cover" src="/imgs/article_cover1.png" />
-      <div class="absolute left-0 top-0 text-white text-size-12px">
+      <img v-if="item.cover" class="w-116px h-65px object-cover" :src="item.coverUrl" />
+      <div v-if="item.vip === '1'" class="absolute left-0 top-0 text-white text-size-12px">
         <img class="w-60px h-auto" src="/imgs/cover-tag.png" />
         <span class="absolute top-0 h-full w-full flex items-center ml-6px">VIP尊享</span>
       </div>
@@ -12,10 +12,10 @@
       <div class="h-12px"></div>
       <div class="flex-col flex justify-between h-full items-end">
         <div class="w-full text-size-14px text-[#000] font-normal">
-          这里是轮播图推荐内容标题这里是轮播图推荐内容标题
+           {{item.title}}
         </div>
 
-        <div class="text-[#B8B8B8] text-size-14px font-medium">2803浏览</div>
+        <div class="text-[#B8B8B8] text-size-14px font-medium">{{item.viewNum}} 浏览</div>
       </div>
       <div class="h-14px"></div>
     </div>
@@ -23,7 +23,18 @@
 </template>
 
 <script>
-export default {};
+export default {
+
+  props:{
+      item:{
+        type:Object,
+        default(){
+          return {}
+        }
+      }
+  }
+
+};
 </script>
 
 <style></style>

+ 62 - 21
src/pc/pages/article-detail/article-detail.vue

@@ -70,41 +70,46 @@
                 {{ $t("文明上网,理性发言!") }}
               </div>
             </div>
-            <div class="text-size-14px text-primary">123{{ $t("条评论") }}</div>
+            <div class="text-size-14px text-primary">{{article.commentNum}}{{ $t("条评论") }}</div>
           </div>
           <el-input
             class="!bg-[#F7F7F7] h-100px mb-20px"
             type="textarea"
             :rows="2"
             :placeholder="$t('我来说两句')"
-            v-model="textarea"
+            v-model="comment"
           >
           </el-input>
           <div class="flex justify-end mb-14px">
-            <el-button type="primary" class="text-white h-30px !py-0" round
+            <el-button type="primary" class="text-white h-30px !py-0" @click="handleComment" round
               >发布</el-button
             >
           </div>
-          <div class="text-size-20px mb-16px">全部评论</div>
-          <ui-devider></ui-devider>
-          <div v-for="item in 4" :key="item">
-            <div class="flex items-start py-30px">
-              <img class="w-60px h-60px round" src="/imgs/avatar.png" />
-              <div class="mt-8px ml-14px">
-                <div class="flex mb-14px items-center">
-                  <div class="font-extralight text-size-16px mr-30px">用户名</div>
-                  <div class="text-size-14px text-[#B8B8B8]">2022-08-26 06:53</div>
-                </div>
-                <div class="text-[#686868] leading-20px text-size-14px">
-                  评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容
+
+          <template v-if="comments.length">
+            <div class="text-size-20px mb-16px">全部评论</div>
+            <ui-devider></ui-devider>
+            <div v-for="comment in comments" :key="item">
+              <div class="flex items-start py-30px">
+                <img class="w-60px h-60px rounded-full" :src="comment.refUserAvatarUrl" />
+                <div class="mt-8px ml-14px">
+                  <div class="flex mb-14px items-center">
+                    <div class="font-extralight text-size-16px mr-30px">{{comment.refUserName}}</div>
+                    <div class="text-size-14px text-[#B8B8B8]">{{comment.createTimeStr}}</div>
+                  </div>
+                  <div class="text-[#686868] leading-20px text-size-14px">
+                    {{comment.content}}
+                  </div>
                 </div>
               </div>
+              <ui-devider></ui-devider>
             </div>
-            <ui-devider></ui-devider>
-          </div>
-          <div class="flex justify-center">
-            <el-button type="text" class="!text-[#686868]">查看更多评论</el-button>
-          </div>
+            <div class="flex justify-center">
+              <el-button v-if="!commentLast" @click="handleLoadComments(++commentPageNum)" type="text" class="!text-[#686868]">查看更多评论</el-button>
+            </div>
+          </template>
+
+
         </ui-shadow-box>
       </div>
 
@@ -280,6 +285,37 @@ export default {
       var url =document.getElementById("share-link");
       url.select(); // 选择对象
       document.execCommand("Copy"); // 执行浏览器复制命令
+    },
+    async handleComment(){
+
+      let resp = await this.$http.post(this.$api.cms.comment,this.$qs.stringify({refArticle:this.article.code,content:this.comment}))
+
+      if(resp.data.status === 200){
+          this.$message.success(this.$t('评论成功'));
+          this.handleLoadData();
+          this.handleLoadComments();
+          this.comment = '';
+      }else{
+        this.$message.warning(this.$t(resp.data.desc));
+      }
+
+    },
+    async handleLoadComments(pageNum){
+
+      if(!pageNum){
+          pageNum = 1;
+      }
+
+      let resp = await this.$http.post(this.$api.cms.listComments,this.$qs.stringify({refArticle:this.$route.query.code,pageNum:pageNum}))
+
+      if(resp.data.status === 200){
+         if(pageNum === 1){
+           this.comments = resp.data.data.cmsArtComments;
+         }else{
+            this.comments = this.comments.concat(resp.data.data.cmsArtComments);
+            this.commentLast = (!resp.data.data.cmsArtComments.length)
+         }
+      }
     }
   },
   computed:{
@@ -289,13 +325,18 @@ export default {
   },
   async created() {
      this.handleLoadData();
+     this.handleLoadComments();
   },
   data() {
     return {
       exportVisible: false,
       subscriped: true,
       html: ``,
-      article:{}
+      article:{},
+      comments:[],
+      comment:'',
+      commentPageNum:1,
+      commentLast:false
     };
   },
 };

+ 2 - 27
src/pc/pages/home/home.vue

@@ -31,33 +31,7 @@
                 </div>
             </div>
             <div class="right w-320px">
-                <div class="px-20px bg-white">
-                    <div class="h-17px"></div>
-                    <div class="relative inline-flex mb-6.5px">
-                        <img src="/imgs/hot.png" class="w-24px h-auto mr-4px"/>
-                        <div class="font-thin text-[#000] text-size-20px">{{ $t("热榜文章") }}</div>
-
-                        <div
-                                class="w-full h-3px absolute left-0 bottom-[-7.5px] bg-primary rounded-full"
-                        ></div>
-                    </div>
-                    <ui-devider></ui-devider>
-                    <div class="h-21px"></div>
-                    <ui-swiper
-                            class="mb-20px"
-                            :items="[
-              { url: '/imgs/article_cover1.png', title: '这是标题' },
-              { url: '/imgs/article_cover1.png', title: '这是标题' },
-            ]"
-                            titleClass="swiper-title"
-                    ></ui-swiper>
-                    <ui-devider></ui-devider>
-
-                    <div v-for="item in 9" :key="item">
-                        <ui-small-article></ui-small-article>
-                        <ui-devider></ui-devider>
-                    </div>
-                </div>
+                <ui-hot-article></ui-hot-article>
                 <div class="h-20px"></div>
                 <div class="px-20px bg-white">
                     <div class="h-17px"></div>
@@ -105,6 +79,7 @@
 
 <script>
     export default {
+        components: {},
         data() {
             return {
                 banner1: [