guhongwei 5 年 前
コミット
b3d726417e

+ 1 - 1
src/components/detail.vue

@@ -70,7 +70,7 @@ export default {
 }
 .main {
   min-height: 1060px;
-  margin: 50px 0 0 0;
+  margin: 50px 0 20 0;
   overflow: hidden;
 }
 .mainList {

+ 7 - 4
src/layout/detail/detail.vue

@@ -16,15 +16,17 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="info">
-          <el-col :span="24" class="image">
-            <el-image style="width:769px;height:443px;" :src="detailInfo.url"></el-image>
+          <el-col :span="24" class="image" v-if="detailInfo.pic">
+            <el-image style="width:769px;height:443px;" :src="detailInfo.pic"></el-image>
           </el-col>
           <el-col :span="24" class="title">
             <p>{{ detailInfo.title }}</p>
           </el-col>
-          <el-col :span="24" class="date"> 发布时间:{{ detailInfo.date }} </el-col>
+          <el-col :span="24" class="date">
+            发布时间: {{ detailInfo.meta && detailInfo.meta.createdAt ? new Date(detailInfo.meta.createdAt).toLocaleDateString() : '' || '' }}</el-col
+          >
           <el-col :span="24" class="content">
-            <p>{{ detailInfo.content }}</p>
+            <p v-html="detailInfo.content"></p>
           </el-col>
         </el-col>
       </el-col>
@@ -75,6 +77,7 @@ p {
 }
 .info {
   text-align: center;
+  margin: 20px 0 0 0;
 }
 .info .image {
   margin: 20px 0;

+ 1 - 3
src/layout/index/news.vue

@@ -16,7 +16,6 @@
           <el-col :span="11" class="block">
             <el-carousel :interval="5000" arrow="always" ref="shubiao">
               <el-carousel-item v-for="(item, index) in infoList" :key="index" :name="`${index}`">
-                <!-- @click="$router.push({ path: `/info/detail?id=${item.id}` })" -->
                 <el-link :underline="false" @click="$router.push({ path: `/detail?id=${item.id}` })">
                   <el-image style="width:369px;height:242px;" :src="item.pic"></el-image>
                   <el-col :span="24" class="cont">
@@ -34,10 +33,9 @@
               :class="newListActive(item)"
               v-for="(item, index) in infoList"
               :key="index"
-              @click="$router.push({ path: `/detail?id=${tag.id}` })"
+              @click.native="$router.push({ path: `/detail?id=${item.id}` })"
             >
               <span class="shu"></span>
-              <!-- @click="$router.push({ path: `/info/detail?id=${tag.id}` })" -->
               <span class="title">{{ item.title }}</span>
               <span class="time">{{ item.publish_time }}</span>
             </el-col>

+ 1 - 1
src/layout/index/notice.vue

@@ -13,7 +13,7 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="info">
-          <el-col :span="24" class="list" v-for="(item, index) in infoList" :key="index" @click="$router.push({ path: `/info/detail?id=${tag.id}` })">
+          <el-col :span="24" class="list" v-for="(item, index) in infoList" :key="index" @click.native="$router.push({ path: `/detail?id=${item.id}` })">
             <span class="shu"></span>
             <span class="title">{{ item.title }}</span>
           </el-col>

+ 2 - 2
src/views/detail.vue

@@ -43,11 +43,11 @@ export default {
     ...mapActions(['getNews']),
     async search() {
       //1直接拿着参数发送请求
-      let result = await this.getNews({ data: { id: this.$route.query.id } });
+      let result = await this.getNews({ type: 'fetch', data: { id: this.$route.query.id } });
       if (`${result.errcode}` === '0') {
         //给this=>vue的实例下在中的list属性,赋予result.data的值
         console.log(result.data);
-        this.$set(this, `info`, result.data);
+        this.$set(this, `detailInfo`, result.data);
       } else {
         this.$message.error(result.errmsg ? result.errmsg : 'error');
       }