Right.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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-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
  45. },
  46. totalCount () {
  47. return this.new.data.count
  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: 0;
  73. float: right;
  74. width: 75%;
  75. padding-bottom: 15px;
  76. }
  77. .news-content .news{
  78. margin-bottom: 15px;
  79. }
  80. .news-content h4{
  81. border-bottom: #e8e8e8 1px solid;
  82. line-height: 40px;
  83. margin: 0;
  84. font-weight: normal;
  85. font-size: 18px;
  86. }
  87. .news-content h4 span.label{
  88. font-size: 12px;
  89. padding: 5px 2px;
  90. margin-right: 8px;
  91. }
  92. .news-content h4 span.label-primary{
  93. background: #5078cb;
  94. }
  95. .news {
  96. display: table;
  97. }
  98. .new {
  99. display: table-row;
  100. }
  101. .new >div{
  102. display: table-cell;
  103. vertical-align: middle;
  104. border-bottom: 1px dashed #ccc;
  105. }
  106. .thumbnail-news {
  107. width: 160px;
  108. height: 100px;
  109. overflow: hidden;
  110. margin: 20px 0 20px;
  111. }
  112. .thumbnail-news img {
  113. width: 160px;
  114. height: 100px;
  115. vertical-align: middle;
  116. border: 0;
  117. }
  118. .news-list {
  119. padding: 10px 10px 10px 20px;
  120. }
  121. .new h5 {
  122. font-size: 16px;
  123. font-weight: 600;
  124. }
  125. .news .new h5 a {
  126. color: #323232;
  127. font-weight: normal;
  128. }
  129. .news .new h5 a:hover {
  130. color: #5078cb;
  131. text-decoration: underline !important;
  132. }
  133. .news-list >p{
  134. line-height: 25px;
  135. }
  136. .news-list .pull-right i {
  137. margin-right: 10px;
  138. }
  139. .news-content a{
  140. cursor: pointer;
  141. }
  142. </style>