Sfoglia il codice sorgente

新闻详情 新闻列表 相关新闻对接

ming 3 anni fa
parent
commit
23d5ead80c
3 ha cambiato i file con 45 aggiunte e 34 eliminazioni
  1. 5 0
      .gitignore
  2. 22 26
      news/index.html
  3. 18 8
      news/read.html

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+
+.history
+
+
+

+ 22 - 26
news/index.html

@@ -171,20 +171,16 @@
 
 
                     <div v-if="!loading" class="page mt-30 mb-30">
-                        <div class="d-flex justify-content-center align-items-end cannot_selected"
-                            style="position:relative">
+                        <div class="d-flex justify-content-center align-items-end cannot_selected" style="position:relative">
                             <div class="page-des align-items-start cannot_selected">共<span> {{
                                     totalPageNum}}</span>页,共<span> {{ totalPageSzie}}</span>条信息</div>
 
                             <a :class="[hasPageTop ? '' : 'disable']" class="previous" @click="toPrevious">上一页</a>
-                            <a v-if="needOmit" :class="[currentPageNum == 1 ? 'active' : '']"
-                                @click="switchPage(1)">1</a>
+                            <a v-if="needOmit" :class="[currentPageNum == 1 ? 'active' : '']" @click="switchPage(1)">1</a>
                             <span v-if="hasLeftOmit">...</span>
-                            <a v-for="item in middlePageNums" :key="item"
-                                :class="[item == currentPageNum ? 'active': '']" @click="switchPage(item)">{{item}}</a>
+                            <a v-for="item in middlePageNums" :key="item" :class="[item == currentPageNum ? 'active': '']" @click="switchPage(item)">{{item}}</a>
                             <span v-if="hasRightOmit">...</span>
-                            <a v-if="needOmit" :class="[currentPageNum == totalPageNum? 'active' : '']"
-                                @click="switchPage(totalPageNum)">{{totalPageNum}}</a>
+                            <a v-if="needOmit" :class="[currentPageNum == totalPageNum? 'active' : '']" @click="switchPage(totalPageNum)">{{totalPageNum}}</a>
                             <a :class="[hasPageNext ? '' : 'disable']" @click="toNext" class="next">下一页</a>
 
                             <div class="page-des2 align-items-end cannot_selected pc">前往第
@@ -217,11 +213,11 @@
     <!--====== Vue js======-->
     <script src="../assets/js/vue.min.js"></script>
     <script>
-        $(function () {
+        $(function() {
             $('#footer').load("../footer.html");
         })
         var news_list = [];
-        var one_page_num = 12;
+        var one_page_num = 6;
         var app = new Vue({
             el: '#app',
             data: {
@@ -236,23 +232,23 @@
                 goPage: 1,
             },
             computed: {
-                hasNews: function () {
+                hasNews: function() {
                     return this.news.length > 0;
                 },
-                hasLeftOmit: function () {
+                hasLeftOmit: function() {
                     return (this.currentPageNum >= 4 && this.needOmit);
                 },
-                hasRightOmit: function () {
+                hasRightOmit: function() {
                     return ((this.middlePageNums[4] + 1) < this.totalPageNum && this.needOmit);
                 },
-                hasPageTop: function () {
+                hasPageTop: function() {
                     return this.currentPageNum > 1;
                 },
-                hasPageNext: function () {
+                hasPageNext: function() {
                     return this.currentPageNum < this.totalPageNum;
                 }
             },
-            mounted: function () {
+            mounted: function() {
                 var self = this;
                 jQuery.ajax({
                     type: 'POST',
@@ -261,12 +257,12 @@
                     data: {
                         type: '1'
                     }
-                }).done(function (res) {
+                }).done(function(res) {
                     if (!res.msg) {
                         return;
                     }
 
-                    res.data.forEach(function (item) {
+                    res.data.forEach(function(item) {
                         news_list.push(item);
                         if (self.news.length < one_page_num) {
                             self.news.push(item);
@@ -283,13 +279,13 @@
                         }
                     }
                     self.loading = false;
-                }).fail(function (err) { });
+                }).fail(function(err) {});
             },
             methods: {
-                oneInnerBox:function(id){
-                    window.location="./read.html?id="+id
+                oneInnerBox: function(id) {
+                    window.location = "./read.html?id=" + id
                 },
-                switchPage: function (page_num) {
+                switchPage: function(page_num) {
                     if (page_num == this.currentPageNum) {
                         return;
                     }
@@ -319,20 +315,20 @@
 
                     this.currentPageNum = page_num;
                 },
-                toPrevious: function () {
+                toPrevious: function() {
                     if (this.currentPageNum == 1) {
                         return;
                     }
                     this.switchPage(this.currentPageNum - 1);
                 },
 
-                toNext: function () {
+                toNext: function() {
                     if (this.currentPageNum == this.totalPageNum) {
                         return;
                     }
                     this.switchPage(this.currentPageNum + 1);
                 },
-                enterPage: function () {
+                enterPage: function() {
                     if (this.goPage <= this.totalPageNum) {
                         // this.currentPageNum = this.goPage
                         // alert(this.currentPageNum)
@@ -344,7 +340,7 @@
                 }
             },
             watch: {
-                currentPageNum: function (val) {
+                currentPageNum: function(val) {
                     this.goPage = val
                 }
             }

+ 18 - 8
news/read.html

@@ -131,10 +131,10 @@
                             </div>
                             <div class="new-read-title2">
                                 <div class="row">
-                                    <div class="col-md-3 col-sm-6 col-6 ">时间:{{articleInfo.time}}</div>
-                                    <div class="col-md-3 col-sm-6 col-6 ">作者:{{articleInfo.publisher}}</div>
-                                    <div class="col-md-3 col-sm-6 col-6  ">点击:缺字段</div>
-                                    <div class="col-md-3 col-sm-6 col-6 ">来源:缺字段</div>
+                                    <div class="col-md-3 col-sm-6 col-6 line-one">时间:{{articleInfo.time}}</div>
+                                    <div class="col-md-3 col-sm-6 col-6 line-one">作者:{{articleInfo.publisher}}</div>
+                                    <div class="col-md-3 col-sm-6 col-6  line-one">点击:{{articleInfo.hits}}</div>
+                                    <div class="col-md-3 col-sm-6 col-6 line-one">来源:{{articleInfo.source}}</div>
                                 </div>
                                 <!-- <span style="margin-left:30px"></span>
                                 <span>作者:{{articleInfo.publisher}}</span>
@@ -160,7 +160,14 @@
                         <div>
                             <div class="title-tag2 pt-60">相关新闻</div>
                             <div class="relNewBox container ">
-                                <a class="justify-content-between d-flex relNewsList" href="">
+
+                                <a class="justify-content-between d-flex relNewsList" :href="'./read.html?id='+item.id" v-for="item in relativeArr" :key="item.id">
+                                    <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
+                                    <div> {{item.time}}</div>
+                                </a>
+
+
+                                <!-- <a class="justify-content-between d-flex relNewsList" href="">
                                     <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> 大数据时代要定“明规则” 保护好用户隐私 </div>
                                     <div>2022-02-12</div>
                                 </a>
@@ -179,7 +186,7 @@
                                 <a class="justify-content-between d-flex relNewsList" href="">
                                     <div><img width="18" height="18" src="../assets/img/news/arrowT.svg">复合年增长率为13.6% 2022年中国将成最大物联网市场</div>
                                     <div>2022-02-12</div>
-                                </a>
+                                </a> -->
                             </div>
                         </div>
                         <!-- 相关新闻end -->
@@ -225,6 +232,7 @@
                 articleInfo: {},
                 previousInfo: {},
                 nextInfo: {},
+                relativeArr: [],
                 ariticle_id: 0
             },
             created: function() {
@@ -254,11 +262,13 @@
                     if (!res.msg) {
                         return;
                     }
-                    console.log('res.content')
+                    // console.log('res.content')
 
-                    console.log(res.content)
+                    // console.log(res.content)
                     self.loading = false;
                     self.articleInfo = res;
+                    self.relativeArr = res.related;
+                    console.log(self.relativeArr)
 
                     if (res.previous != null) {
                         self.previousInfo = res.previous;