HotNews2.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="hotNews">
  3. <div class="hotNews_title">
  4. 热点精选
  5. </div>
  6. <ul class="hotNews_message">
  7. <li class="hotNews_messageList" v-for="(item, index) in hotNewsList" :key="index">
  8. <span class="number">{{ index + 1 }}</span>
  9. <NuxtLink
  10. :href="getLinkPathDetail(item)"
  11. :title="item.title"
  12. :key="item.id"
  13. :target="item.islink == 1 ? '_blank' : '_self'"
  14. >
  15. <span class="hotlist_text">{{ item.title }}</span>
  16. </NuxtLink>
  17. </li>
  18. </ul>
  19. </div>
  20. </template>
  21. <script setup>
  22. const getLinkPathDetail = (item) => {
  23. if (item.islink == 1) {
  24. return `${item.linkurl}`;
  25. } else {
  26. return `/${item.pinyin}/${item.id}.html`;
  27. }
  28. }
  29. const hotNewsList = ref([])
  30. async function getPageData() {
  31. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  32. method: 'GET',
  33. query: {
  34. 'pageSize': 8,
  35. 'level': 5,
  36. 'placeid': 0,
  37. 'id': 0
  38. },
  39. });
  40. if (mkdata.code == 200) {
  41. hotNewsList.value = mkdata.data;
  42. } else {
  43. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  44. console.log("错误位置:获取热点精选")
  45. console.log("后端错误反馈:", mkdata.message)
  46. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  47. }
  48. }
  49. getPageData();
  50. </script>
  51. <style lang="less" scoped>
  52. .hotNews {
  53. width: 270px;
  54. margin-top: 20px;
  55. //标题
  56. .hotNews_title {
  57. width: 100px;
  58. font-family: Microsoft YaHei, Microsoft YaHei;
  59. font-weight: bold;
  60. margin: 30px 0 10px;
  61. font-size: 20px;
  62. color: #255590;
  63. border-left: #255590 5px solid;
  64. padding-left: 17px;
  65. }
  66. //新闻列表
  67. .hotNews_message {
  68. width: 270px;
  69. .hotNews_messageList {
  70. width: 270px;
  71. height: 64px;
  72. line-height: 64px;
  73. border-bottom: 1px solid #E4E4E4;
  74. font-weight: 400;
  75. font-size: 18px;
  76. color: #333333;
  77. ;
  78. white-space: nowrap;
  79. overflow: hidden;
  80. text-overflow: ellipsis;
  81. a {
  82. color: #333333;
  83. }
  84. .number {
  85. color: #999999;
  86. margin-right: 13px;
  87. font-family: DingTalk JinBuTi, DingTalk JinBuTi;
  88. }
  89. }
  90. .hotNews_messageList:nth-child(1) {
  91. .number {
  92. color: #255590;
  93. }
  94. }
  95. .hotNews_messageList:nth-child(2) {
  96. .number {
  97. color: #255590;
  98. }
  99. }
  100. .hotNews_messageList:nth-child(3) {
  101. .number {
  102. color: #255590;
  103. }
  104. }
  105. .hotNews_messageList:hover {
  106. color: #255590;
  107. a {
  108. color: #255590;
  109. }
  110. }
  111. }
  112. }
  113. </style>