Right.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="news-content col-md-9">
  3. <h4><span class="label label-primary">News</span>新闻资讯</h4>
  4. <div class="news" v-if="news_show && news_show.length > 0" v-for="item in news_show">
  5. <div class="new">
  6. <div style="width: 120px;">
  7. <div class="thumbnail-news">
  8. <nuxt-link :to="'/news/'+item.id" :title=item.title>
  9. <img class="content-thumbnail" alt="新闻缩略图" :src=item.thumbnail></nuxt-link>
  10. </div>
  11. </div>
  12. <div class="news-list">
  13. <h5> <nuxt-link :to="'/news/'+item.id" :title=item.title>{{item.title}}</nuxt-link></h5>
  14. <p v-text=item.summary></p>
  15. <div class="text-muted">
  16. <span class="pull-left " >{{item.created | date}}</span>
  17. <span class="pull-right text-num" >
  18. <i class="fa fa-eye" style="margin-left: 15px;"></i>{{item.viewCount}}</span>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <page :total="totalCount" :page-size="pageSize"
  24. :current="nowPage" v-on:childEvent="listenPage"></page>
  25. </div>
  26. </template>
  27. <script>
  28. import Page from '~components/common/page/pageComponent.vue'
  29. export default {
  30. data () {
  31. return {
  32. pageSize: 10,
  33. nowPage: 1
  34. }
  35. },
  36. components: {
  37. Page
  38. },
  39. computed: {
  40. new () {
  41. return this.$store.state.newsData.newsPage.allNews
  42. },
  43. news_show () {
  44. return this.new.data.content ? this.new.data.content : []
  45. },
  46. totalCount () {
  47. return this.new.data.count ? this.new.data.count : 0
  48. }
  49. },
  50. filters: {
  51. date: function (input) {
  52. const d = new Date(input)
  53. const year = d.getFullYear()
  54. const monthTemp = d.getMonth() + 1
  55. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  56. const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours() + ' '
  57. const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes() + ' '
  58. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  59. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  60. }
  61. },
  62. methods: {
  63. listenPage: function (changedPage) {
  64. this.nowPage = changedPage
  65. this.$emit('pageEvent', this.nowPage)
  66. }
  67. }
  68. }
  69. </script>
  70. <style>
  71. .news-content{
  72. padding-left: 20px;
  73. float: right;
  74. width: 75%;
  75. padding-bottom: 15px;
  76. background: #fff;
  77. border-radius:5px;
  78. }
  79. .news-content .news{
  80. margin-bottom: 15px;
  81. }
  82. .news-content h4{
  83. border-bottom: #e8e8e8 1px solid;
  84. line-height: 40px;
  85. margin: 0;
  86. font-weight: normal;
  87. font-size: 18px;
  88. }
  89. .news-content h4 span.label{
  90. font-size: 12px;
  91. padding: 5px 2px;
  92. margin-right: 8px;
  93. }
  94. .news-content h4 span.label-primary{
  95. background: #5078cb;
  96. }
  97. .news {
  98. display: table;
  99. }
  100. .new {
  101. display: table-row;
  102. }
  103. .new >div{
  104. display: table-cell;
  105. vertical-align: middle;
  106. border-bottom: 1px dashed #ccc;
  107. width: 717px;
  108. }
  109. .thumbnail-news {
  110. width: 160px;
  111. height: 100px;
  112. overflow: hidden;
  113. margin: 20px 0 20px;
  114. }
  115. .thumbnail-news img {
  116. width: 160px;
  117. height: 100px;
  118. vertical-align: middle;
  119. border: 0;
  120. }
  121. .news-list {
  122. padding: 10px 10px 10px 20px;
  123. }
  124. .new h5 {
  125. font-size: 16px;
  126. font-weight: 600;
  127. }
  128. .news .new h5 a {
  129. color: #323232;
  130. font-weight: normal;
  131. }
  132. .news .new h5 a:hover {
  133. color: #5078cb;
  134. text-decoration: underline !important;
  135. }
  136. .news-list >p{
  137. line-height: 25px;
  138. }
  139. .news-list .pull-right i {
  140. margin-right: 10px;
  141. }
  142. .news-content a{
  143. cursor: pointer;
  144. }
  145. </style>