HotNews2.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. 'imgnum': 0,
  35. 'textnum': 8,
  36. 'level': 5,
  37. 'placeid': 0,
  38. 'id': 0
  39. },
  40. });
  41. if (mkdata.code == 200) {
  42. hotNewsList.value = mkdata.data.text;
  43. } else {
  44. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  45. console.log("错误位置:获取热点精选")
  46. console.log("后端错误反馈:", mkdata.message)
  47. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  48. }
  49. }
  50. getPageData();
  51. </script>
  52. <style lang="less" scoped>
  53. .hotNews {
  54. width: 270px;
  55. height: 597px;
  56. border-top: 2px solid #dd7d18;
  57. margin-top: 40px;
  58. //标题
  59. .hotNews_title {
  60. width: 100px;
  61. height: 40px;
  62. line-height: 40px;
  63. font-family: Microsoft YaHei, Microsoft YaHei;
  64. font-weight: bold;
  65. margin: 20px 0 15px;
  66. font-size: 20px;
  67. color: #333333;
  68. }
  69. //新闻列表
  70. .hotNews_message {
  71. width: 270px;
  72. .hotNews_messageList {
  73. width: 270px;
  74. height: 64px;
  75. line-height: 64px;
  76. border-bottom: 1px solid #E4E4E4;
  77. font-weight: 400;
  78. font-size: 18px;
  79. color: #333333;
  80. ;
  81. white-space: nowrap;
  82. overflow: hidden;
  83. text-overflow: ellipsis;
  84. a {
  85. color: #333333;
  86. }
  87. .number {
  88. color: #999999;
  89. margin-right: 13px;
  90. font-family: DingTalk JinBuTi, DingTalk JinBuTi;
  91. }
  92. }
  93. .hotNews_messageList:nth-child(1) {
  94. .number {
  95. color: #dd7d18;
  96. }
  97. }
  98. .hotNews_messageList:nth-child(2) {
  99. .number {
  100. color: #dd7d18;
  101. }
  102. }
  103. .hotNews_messageList:nth-child(3) {
  104. .number {
  105. color: #dd7d18;
  106. }
  107. }
  108. .hotNews_messageList:hover {
  109. color: #dd7d18;
  110. a {
  111. color: #dd7d18;
  112. }
  113. }
  114. }
  115. }
  116. </style>