Right.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. news () {
  41. return this.$store.state.newsPage.allNews
  42. },
  43. news_show () {
  44. return this.news.data.content
  45. },
  46. totalCount () {
  47. return this.news.data.count
  48. }
  49. },
  50. filters: {
  51. date: function (input) {
  52. const d = new Date(input)
  53. const year = d.getFullYear()
  54. const month = d.getMonth() + 1
  55. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  56. const hour = d.getHours()
  57. const minutes = d.getMinutes()
  58. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  59. }
  60. },
  61. methods: {
  62. listenPage: function (changedPage) {
  63. this.nowPage = changedPage
  64. this.$emit('childEvent', this.nowPage)
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .news-content{
  71. padding-left: 0;
  72. float: right;
  73. width: 75%;
  74. margin-top: 10px;
  75. }
  76. .news-content h4{
  77. border-bottom: #e8e8e8 1px solid;
  78. line-height: 40px;
  79. margin: 0;
  80. }
  81. .news-content h4 span.label{
  82. font-size: 12px;
  83. padding: 5px 2px;
  84. margin-right: 8px;
  85. }
  86. .news-content h4 span.label-primary{
  87. background: #5078cb;
  88. }
  89. .news {
  90. display: table;
  91. }
  92. .new {
  93. display: table-row;
  94. }
  95. .new >div{
  96. display: table-cell;
  97. vertical-align: middle;
  98. border-bottom: 1px dashed #ccc;
  99. }
  100. .thumbnail-news {
  101. width: 160px;
  102. height: 100px;
  103. overflow: hidden;
  104. margin: 20px 0 20px;
  105. }
  106. .thumbnail-news img {
  107. width: 160px;
  108. height: 100px;
  109. vertical-align: middle;
  110. border: 0;
  111. }
  112. .news-list {
  113. padding: 10px 10px 10px 20px;
  114. }
  115. .new h5 {
  116. font-size: 16px;
  117. font-weight: 600;
  118. }
  119. .news .new h5 a {
  120. color: #323232;
  121. font-weight: normal;
  122. }
  123. .news-list >p{
  124. line-height: 25px;
  125. }
  126. .news-list .pull-right i {
  127. margin-right: 10px;
  128. }
  129. .news-content a{
  130. cursor: pointer;
  131. }
  132. </style>