News.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="news">
  3. <div class="news-container container">
  4. <h2 class="title">
  5. <nuxt-link to="/news">优软快讯</nuxt-link>
  6. </h2>
  7. <ul class="title-list">
  8. <li v-for="n in news5" class="item">
  9. <nuxt-link :to="`/news/${n.id}`" target="_blank">
  10. {{ n.title }}
  11. </nuxt-link>
  12. </li>
  13. <li class="item item-last"><nuxt-link to="/news">查看更多&gt;&gt;</nuxt-link></li>
  14. </ul>
  15. <ul class="thumbnail-list">
  16. <li v-for="n in news3" class="item">
  17. <nuxt-link :to="`/news/${n.id}`" target="_blank">
  18. <img :src="n.thumbnail">
  19. <span>{{ n.title }}</span>
  20. </nuxt-link>
  21. </li>
  22. </ul>
  23. <div class="clearfix"></div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'news',
  30. // data () {
  31. // return {
  32. // news: {}
  33. // }
  34. // },
  35. // mounted () {
  36. // this.$http.get('/api/news/created', {params: { page: 1, pageSize: 10 }})
  37. // .then(response => {
  38. // this.news = response
  39. // })
  40. // },
  41. computed: {
  42. news () {
  43. return this.$store.state.news.snapshot
  44. },
  45. news3 () {
  46. if (this.news.data) {
  47. return this.news.data.content.slice(0, 3)
  48. }
  49. },
  50. news5 () {
  51. if (this.news.data) {
  52. return this.news.data.content.slice(0, 5)
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .news {
  60. height: 280px;
  61. background: url("/images/news/news-bg.jpg");
  62. .news-container {
  63. .title {
  64. padding: 20px 0 15px 0;
  65. margin: 0;
  66. }
  67. a {
  68. color: #fff;
  69. &:hover {
  70. color: #feb900;
  71. }
  72. }
  73. .title-list {
  74. width: 450px;
  75. float: left;
  76. .item {
  77. line-height: 25px;
  78. a {
  79. display: inline-block;
  80. width: 100%;
  81. text-overflow: ellipsis;
  82. overflow: hidden;
  83. white-space: nowrap;
  84. }
  85. &:last-child a, .item-last a{
  86. color: #feb900;
  87. }
  88. }
  89. }
  90. .thumbnail-list {
  91. float: right;
  92. .item {
  93. display: inline-block;
  94. position: relative;
  95. margin-left: 15px;
  96. background: #fff;
  97. overflow: hidden;
  98. width: 220px;
  99. height: 190px;
  100. a {
  101. img {
  102. width: 220px;
  103. height: 152px;
  104. }
  105. span {
  106. position: absolute;
  107. left: 0;
  108. right: 0;
  109. bottom: 0;
  110. display: block;
  111. line-height: 38px;
  112. padding: 0 10px;
  113. color: #666;
  114. text-overflow: ellipsis;
  115. overflow: hidden;
  116. white-space: nowrap;
  117. }
  118. &:hover {
  119. img {
  120. transform: scale(1.15);
  121. }
  122. span {
  123. line-height: 28px;
  124. color: #feb900;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. </style>