Left.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="hot-news col-md-3">
  3. <h4>
  4. <span>hot</span>热门文章
  5. </h4>
  6. <div>
  7. <ol class="list-unstyled">
  8. <li v-for="item in news_show" v-bind="item">
  9. <h5>
  10. <nuxt-link :to="'/news/'+item.id" :title=item.title
  11. v-text=item.title></nuxt-link>
  12. </h5>
  13. <div class="hot-time">
  14. <span class="text-num">{{item.created | date}}</span>
  15. <span class="pull-right text-num" style="font-size: 12px">
  16. <i class="fa fa-eye" style="margin-left: 15px;"></i>{{item.viewCount}}
  17. </span>
  18. </div>
  19. <p class="text-muted summary" v-text=item.summary></p>
  20. </li>
  21. </ol>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. data () {
  28. return {
  29. new: {}
  30. }
  31. },
  32. mounted () {
  33. this.$http.get('/api/news/viewCount')
  34. .then(response => {
  35. this.new = response
  36. })
  37. },
  38. computed: {
  39. // new () {
  40. // return this.$store.state.newsData.hotNews.hotNews
  41. // },
  42. news_show () {
  43. // console.log(this.new.data)
  44. if (this.new.data) {
  45. return this.new.data.content
  46. }
  47. }
  48. },
  49. filters: {
  50. date: function (input) {
  51. const d = new Date(input)
  52. const year = d.getFullYear()
  53. const monthTemp = d.getMonth() + 1
  54. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  55. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  56. return year + '-' + month + '-' + day
  57. }
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. .hot-news{
  63. border: 1px solid #e8e8e8;
  64. width:260px;
  65. padding: 0;
  66. }
  67. .hot-news h4{
  68. background: #ecf2fd;
  69. width: 100%;
  70. height: 40px;
  71. line-height: 40px;
  72. font-size: 18px!important;
  73. margin: 0;
  74. font-weight: normal;
  75. }
  76. .hot-news h4 span{
  77. background: #feb900;
  78. width: 30px;
  79. height: 40px;
  80. display: inline-block;
  81. position: relative;
  82. text-align: right;
  83. color: #fff;
  84. margin-right: 40px;
  85. font-size: 12px;
  86. line-height: 40px;
  87. float: left;
  88. }
  89. .hot-news h4 span:before{
  90. content: '';
  91. position: absolute;
  92. right: -20px;
  93. top: 0;
  94. width: 0;
  95. height: 0;
  96. border-width: 20px 0 20px 20px;
  97. border-style: solid;
  98. border-color: transparent transparent transparent #feb900;
  99. }
  100. .hot-news ol{
  101. padding-top: 0px;
  102. padding-right: 15px;
  103. padding-bottom: 0px;
  104. padding-left: 15px;
  105. }
  106. .hot-news ol li{
  107. border-bottom: #e8e8e8 1px dotted;
  108. }
  109. .hot-news li h5 {
  110. margin-top: 20px;
  111. margin-bottom: 0;
  112. padding: 5px 0;
  113. width: 100%;
  114. overflow: hidden;
  115. text-overflow: ellipsis;
  116. white-space: nowrap;
  117. font-size: 16px;
  118. color: #666666;
  119. line-height: 20px;
  120. font-weight: 600;
  121. }
  122. .hot-news li h5 a {
  123. font-weight: normal;
  124. color: #323232;
  125. }
  126. .hot-news li h5 a:hover{
  127. color: #5078cb;
  128. text-decoration: underline !important;
  129. }
  130. .hot-time{
  131. line-height: 30px;
  132. }
  133. .hot-time span{
  134. font-size: 14px;
  135. color: #999;
  136. }
  137. li{
  138. display: list-item;
  139. text-align: -webkit-match-parent;
  140. }
  141. .list-unstyled{
  142. list-style: none;
  143. }
  144. .hot-news li p{
  145. font-size: 12px;
  146. line-height: 20px;
  147. height: 40px;
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. }
  151. .fa {
  152. margin-right: 5px;
  153. }
  154. </style>