HotNews2.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="hotNews">
  3. <div class="hotNews_title">
  4. 热点精选
  5. <em></em>
  6. </div>
  7. <div class="top_top">
  8. <div class="hotNews_photo_text">
  9. <div class="photo_left" v-for="(item, index) in hotNewsListImg">
  10. <NuxtLink :to="item.linkurl" v-show="item.islink == 1" :title="item.title">
  11. <img :src="item.imgurl" alt="">
  12. <div class="hotNews_text">{{ item.title }}</div>
  13. </NuxtLink>
  14. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`">
  15. <img :src="item.imgurl" alt="">
  16. <div class="hotNews_text">{{ item.title }}</div>
  17. </NuxtLink>
  18. </div>
  19. </div>
  20. </div>
  21. <ul class="hotNews_message">
  22. <li class="hotNews_messageList" v-for="(item, index) in hotNewsList" :key="index">
  23. <NuxtLink :to="item.linkurl" v-show="item.islink == 1" :title="item.title">
  24. {{ item.title }}
  25. </NuxtLink>
  26. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" v-if="item.islink == 0" :title="item.title">
  27. {{ item.title }}
  28. </NuxtLink>
  29. </li>
  30. </ul>
  31. </div>
  32. </template>
  33. <script setup>
  34. const hotNewsListImg = ref([])
  35. const hotNewsList = ref([])
  36. async function getPageData() {
  37. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  38. method: 'GET',
  39. query: {
  40. 'imgnum':2,
  41. 'textnum': 7,
  42. 'level': 5,
  43. 'id': 0,
  44. 'placeid': 0,
  45. },
  46. });
  47. if (mkdata.code == 200) {
  48. hotNewsList.value = mkdata.data.text;
  49. hotNewsListImg.value = mkdata.data.img;
  50. } else {
  51. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  52. console.log("错误位置:获取热点精选")
  53. console.log("后端错误反馈:", mkdata.message)
  54. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  55. }
  56. }
  57. getPageData();
  58. </script>
  59. <style lang="less" scoped>
  60. .hotNews {
  61. width: 350px;
  62. //标题
  63. .hotNews_title {
  64. width: 100px;
  65. height: 40px;
  66. line-height: 40px;
  67. font-family: Microsoft YaHei, Microsoft YaHei;
  68. font-weight: 400;
  69. margin: 20px 0;
  70. font-size: 20px;
  71. color: #333333;
  72. position: relative;
  73. em {
  74. display: inline-block;
  75. width: 8px;
  76. height: 8px;
  77. border-radius: 4px;
  78. background-color: #a01c0e;
  79. position: absolute;
  80. top: 6px;
  81. right: 8px;
  82. }
  83. }
  84. //图片文字
  85. .top_top {
  86. width: 350px;
  87. height: 165px;
  88. position: relative;
  89. .hotNews_photo_text {
  90. display: flex;
  91. justify-content: space-between;
  92. margin-top: 10px;
  93. img {
  94. width: 165px;
  95. height: 96px;
  96. }
  97. .hotNews_text {
  98. width: 165px;
  99. display: -webkit-box;
  100. -webkit-box-orient: vertical;
  101. -webkit-line-clamp: 2;
  102. overflow: hidden;
  103. text-overflow: ellipsis;
  104. word-break: break-all;
  105. font-family: Microsoft YaHei, Microsoft YaHei;
  106. font-weight: 400;
  107. font-size: 18px;
  108. color: #333333;
  109. margin-top: 15px;
  110. }
  111. .hotNews_text:hover {
  112. color: #a01c0e;
  113. }
  114. }
  115. }
  116. //新闻列表
  117. .hotNews_message {
  118. width: 350px;
  119. margin-top: 25px;
  120. .hotNews_messageList {
  121. width: 350px;
  122. white-space: nowrap;
  123. overflow: hidden;
  124. text-overflow: ellipsis;
  125. font-family: Microsoft YaHei, Microsoft YaHei;
  126. font-weight: 400;
  127. font-size: 18px;
  128. color: #333333;
  129. margin-bottom: 30px;
  130. a {
  131. color: #333333;
  132. }
  133. }
  134. .hotNews_messageList:hover {
  135. color: #a01c0e;
  136. a {
  137. color: #a01c0e;
  138. }
  139. }
  140. }
  141. }
  142. </style>