HotNews.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="hotList">
  3. <div class="title">
  4. <h4>
  5. 今日热点
  6. </h4>
  7. </div>
  8. <ul class="messageList">
  9. <li v-for="(item, index) in hotNewsList">
  10. <span>{{ index + 1 }}</span>
  11. <NuxtLink :to="item.linkurl" target="_blank" v-show="item.islink == 1">{{ item.title }}</NuxtLink>
  12. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank" v-if="item.islink == 0">{{ item.title }}
  13. </NuxtLink>
  14. </li>
  15. </ul>
  16. </div>
  17. </template>
  18. <script setup>
  19. //获得axios
  20. const nuxtApp = useNuxtApp();
  21. const axios = nuxtApp.$axios;
  22. import { onMounted } from 'vue'
  23. const hotNewsList = ref([])
  24. //获取详情
  25. const getHotNews = async () => {
  26. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${14}&level=${4}`);
  27. hotNewsList.value = response.data;
  28. }
  29. onMounted(() => {
  30. getHotNews()
  31. })
  32. </script>
  33. <style lang="less" scoped>
  34. .hotList {
  35. background: #fff;
  36. }
  37. .title {
  38. width: 380px;
  39. height: 40px;
  40. line-height: 40px;
  41. // border-top: 1px solid #139602;
  42. border-bottom: 1px solid #e7e7e7;
  43. background-color: #fbfbfb;
  44. >h4 {
  45. font-family: Microsoft YaHei, Microsoft YaHei;
  46. font-weight: 400;
  47. margin-left: 20px;
  48. font-size: 20px;
  49. color: #000000;
  50. text-align: left;
  51. font-style: normal;
  52. text-transform: none;
  53. >span {
  54. float: right;
  55. font-family: Microsoft YaHei, Microsoft YaHei;
  56. font-weight: 400;
  57. font-size: 14px;
  58. margin-right: 10px;
  59. color: #999999;
  60. text-align: left;
  61. font-style: normal;
  62. text-transform: none;
  63. }
  64. }
  65. }
  66. .messageList {
  67. height: 563px;
  68. padding-top: 15px;
  69. margin-bottom: 30px;
  70. background-color: #fbfbfb;
  71. >li {
  72. height: 24px;
  73. margin-bottom: 16px;
  74. white-space: nowrap;
  75. /* 禁止换行 */
  76. overflow: hidden;
  77. /* 隐藏超出部分 */
  78. text-overflow: ellipsis;
  79. /* 超出部分显示省略号 */
  80. >span {
  81. display: inline-block;
  82. width: 24px;
  83. height: 24px;
  84. margin-left: 22px;
  85. line-height: 24px;
  86. vertical-align: middle;
  87. text-align: center;
  88. background-color: #cecece;
  89. font-family: Microsoft YaHei, Microsoft YaHei;
  90. font-weight: 400;
  91. font-size: 18px;
  92. color: #FFFFFF;
  93. text-align: center;
  94. font-style: normal;
  95. text-transform: none;
  96. }
  97. >a {
  98. width: 256px;
  99. height: 21px;
  100. font-family: Microsoft YaHei, Microsoft YaHei;
  101. font-weight: 400;
  102. font-size: 16px;
  103. color: #333333;
  104. line-height: 19px;
  105. text-align: left;
  106. font-style: normal;
  107. text-transform: none;
  108. padding-left: 10px;
  109. }
  110. }
  111. >li:hover>a {
  112. color: #139602;
  113. }
  114. >li:nth-child(1)>span {
  115. background-color: #00c524;
  116. }
  117. >li:nth-child(2)>span {
  118. background-color: #ffdf27;
  119. }
  120. >li:nth-child(3)>span {
  121. background-color: #f3c57f;
  122. }
  123. }
  124. </style>