HotNews2.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. margin-top: 20px;
  56. //标题
  57. .hotNews_title {
  58. width: 100px;
  59. font-family: Microsoft YaHei, Microsoft YaHei;
  60. font-weight: bold;
  61. margin: 30px 0 10px;
  62. font-size: 20px;
  63. color: #255590;
  64. border-left: #255590 5px solid;
  65. padding-left: 17px;
  66. }
  67. //新闻列表
  68. .hotNews_message {
  69. width: 270px;
  70. .hotNews_messageList {
  71. width: 270px;
  72. height: 64px;
  73. line-height: 64px;
  74. border-bottom: 1px solid #E4E4E4;
  75. font-weight: 400;
  76. font-size: 18px;
  77. color: #333333;
  78. ;
  79. white-space: nowrap;
  80. overflow: hidden;
  81. text-overflow: ellipsis;
  82. a {
  83. color: #333333;
  84. }
  85. .number {
  86. color: #999999;
  87. margin-right: 13px;
  88. font-family: DingTalk JinBuTi, DingTalk JinBuTi;
  89. }
  90. }
  91. .hotNews_messageList:nth-child(1) {
  92. .number {
  93. color: #255590;
  94. }
  95. }
  96. .hotNews_messageList:nth-child(2) {
  97. .number {
  98. color: #255590;
  99. }
  100. }
  101. .hotNews_messageList:nth-child(3) {
  102. .number {
  103. color: #255590;
  104. }
  105. }
  106. .hotNews_messageList:hover {
  107. color: #255590;
  108. a {
  109. color: #255590;
  110. }
  111. }
  112. }
  113. }
  114. </style>