News.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.slice(0, 3)
  48. }
  49. },
  50. news5 () {
  51. if (this.news.data) {
  52. return this.news.data.slice(0, 5)
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .news {
  60. width: 100%;
  61. margin: 0 auto;
  62. height: 280px;
  63. width: 100%;
  64. margin: 0 auto;
  65. background: url("/images/news/news-bg.jpg");
  66. .news-container {
  67. .title {
  68. padding: 20px 0 15px 0;
  69. margin: 0;
  70. }
  71. a {
  72. color: #fff;
  73. &:hover {
  74. color: #feb900;
  75. }
  76. }
  77. .title-list {
  78. width: 450px;
  79. float: left;
  80. .item {
  81. line-height: 25px;
  82. a {
  83. display: inline-block;
  84. width: 100%;
  85. text-overflow: ellipsis;
  86. overflow: hidden;
  87. white-space: nowrap;
  88. }
  89. &:last-child a, .item-last a{
  90. color: #feb900;
  91. }
  92. }
  93. }
  94. .thumbnail-list {
  95. float: right;
  96. .item {
  97. display: inline-block;
  98. position: relative;
  99. margin-left: 15px;
  100. background: #fff;
  101. overflow: hidden;
  102. width: 220px;
  103. height: 190px;
  104. a {
  105. img {
  106. width: 220px;
  107. height: 152px;
  108. }
  109. span {
  110. position: absolute;
  111. left: 0;
  112. right: 0;
  113. bottom: 0;
  114. display: block;
  115. line-height: 38px;
  116. padding: 0 10px;
  117. color: #666;
  118. text-overflow: ellipsis;
  119. overflow: hidden;
  120. white-space: nowrap;
  121. }
  122. &:hover {
  123. img {
  124. transform: scale(1.15);
  125. }
  126. span {
  127. line-height: 28px;
  128. color: #feb900;
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. </style>