Right.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. new: {}
  35. }
  36. },
  37. components: {
  38. Page
  39. },
  40. mounted () {
  41. this.loadPageNews()
  42. },
  43. computed: {
  44. // new () {
  45. // return this.$store.state.newsData.newsPage.allNews
  46. // },
  47. news_show () {
  48. if (this.new.data) {
  49. return this.new.data.content
  50. }
  51. },
  52. totalCount () {
  53. if (this.new.data) {
  54. return this.new.data.count
  55. }
  56. }
  57. },
  58. filters: {
  59. date: function (input) {
  60. const d = new Date(input)
  61. const year = d.getFullYear()
  62. const monthTemp = d.getMonth() + 1
  63. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  64. const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours() + ' '
  65. const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes() + ' '
  66. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  67. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  68. }
  69. },
  70. methods: {
  71. listenPage: function (changedPage) {
  72. this.nowPage = changedPage
  73. this.loadPageNews()
  74. },
  75. loadPageNews: function () {
  76. this.$http.get('/api/news/created', {params: { page: this.nowPage, pageSize: this.pageSize }})
  77. .then(response => {
  78. this.new = response
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped>
  85. .news-content{
  86. padding-left: 0;
  87. float: right;
  88. width: 75%;
  89. padding-bottom: 15px;
  90. }
  91. .news-content .news{
  92. margin-bottom: 15px;
  93. }
  94. .news-content h4{
  95. border-bottom: #e8e8e8 1px solid;
  96. line-height: 40px;
  97. margin: 0;
  98. font-weight: normal;
  99. font-size: 18px;
  100. }
  101. .news-content h4 span.label{
  102. font-size: 12px;
  103. padding: 5px 2px;
  104. margin-right: 8px;
  105. }
  106. .news-content h4 span.label-primary{
  107. background: #5078cb;
  108. }
  109. .news {
  110. display: table;
  111. }
  112. .new {
  113. display: table-row;
  114. }
  115. .new >div{
  116. display: table-cell;
  117. vertical-align: middle;
  118. border-bottom: 1px dashed #ccc;
  119. }
  120. .thumbnail-news {
  121. width: 160px;
  122. height: 100px;
  123. overflow: hidden;
  124. margin: 20px 0 20px;
  125. }
  126. .thumbnail-news img {
  127. width: 160px;
  128. height: 100px;
  129. vertical-align: middle;
  130. border: 0;
  131. }
  132. .news-list {
  133. padding: 10px 10px 10px 20px;
  134. }
  135. .new h5 {
  136. font-size: 16px;
  137. font-weight: 600;
  138. }
  139. .news .new h5 a {
  140. color: #323232;
  141. font-weight: normal;
  142. }
  143. .news .new h5 a:hover {
  144. color: #5078cb;
  145. text-decoration: underline !important;
  146. }
  147. .news-list >p{
  148. line-height: 25px;
  149. }
  150. .news-list .pull-right i {
  151. margin-right: 10px;
  152. }
  153. .news-content a{
  154. cursor: pointer;
  155. }
  156. </style>