HotNews.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="hotList">
  3. <div class="title">
  4. 最新资讯
  5. <em></em>
  6. </div>
  7. <div class="hotList_photo_text" v-for="(item, index) in hotNewsListImg" :key="index">
  8. <NuxtLink :to="item.linkurl" v-if="item.islink == 1" :title="item.title">
  9. <img :src="item.imgurl" alt="">
  10. <span class="jingxuan">精选</span>
  11. <div class="hotlist_text">{{ item.title }}</div>
  12. </NuxtLink>
  13. <NuxtLink :to="`/newsDetail/${item.id}`" v-if="item.islink == 0" :title="item.title">
  14. <img :src="item.imgurl" alt="">
  15. <span class="jingxuan">精选</span>
  16. <div class="hotlist_text">{{ item.title }}</div>
  17. </NuxtLink>
  18. </div>
  19. <ul class="message">
  20. <li class="messageList" v-for="(item, index) in hotNewsList" :key="index">
  21. <NuxtLink :to="item.linkurl" v-if="item.islink == 1" :title="item.title">{{ item.title }}</NuxtLink>
  22. <NuxtLink :to="`/newsDetail/${item.id}`" v-if="item.islink == 0" :title="item.title">
  23. {{ item.title }}
  24. </NuxtLink>
  25. </li>
  26. </ul>
  27. </div>
  28. </template>
  29. <script setup>
  30. const hotNewsList = ref([])
  31. async function getPageData() {
  32. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  33. method: 'GET',
  34. query: {
  35. 'pageSize': 5,
  36. 'level': 4,
  37. 'id': 0,
  38. },
  39. });
  40. if (mkdata.code == 200) {
  41. hotNewsList.value = mkdata.data;
  42. console.log("11111111111111111111111111", hotNewsList.value);
  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. const hotNewsListImg = ref([])
  52. async function getPageData1() {
  53. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  54. method: 'GET',
  55. query: {
  56. 'pageSize': 5,
  57. 'level': 4,
  58. 'id': 0,
  59. },
  60. });
  61. if (mkdata.code == 200) {
  62. for (let item of mkdata.data) {
  63. if (item.imgurl) {
  64. if (hotNewsListImg.value.length < 1) {
  65. hotNewsListImg.value.push(item)
  66. }
  67. }
  68. }
  69. // hotNewsListImg.value = mkdata.data;
  70. } else {
  71. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  72. console.log("错误位置:获取最新资讯")
  73. console.log("后端错误反馈:", mkdata.message)
  74. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  75. }
  76. }
  77. getPageData1();
  78. </script>
  79. <style lang="less" scoped>
  80. .title {
  81. width: 100px;
  82. height: 40px;
  83. line-height: 40px;
  84. font-family: Microsoft YaHei, Microsoft YaHei;
  85. font-weight: 400;
  86. margin: 10px 0;
  87. font-size: 20px;
  88. color: #333333;
  89. position: relative;
  90. em {
  91. display: inline-block;
  92. width: 8px;
  93. height: 8px;
  94. border-radius: 4px;
  95. background-color: #a01c0e;
  96. position: absolute;
  97. top: 6px;
  98. right: 8px;
  99. }
  100. }
  101. .hotList_photo_text {
  102. width: 350px;
  103. height: 280px;
  104. position: relative;
  105. img {
  106. width: 350px;
  107. height: 230px;
  108. }
  109. .jingxuan {
  110. display: inline-block;
  111. width: 50px;
  112. height: 26px;
  113. background-color: #a01c0e;
  114. color: #fff;
  115. text-align: center;
  116. line-height: 26px;
  117. position: absolute;
  118. top: 0px;
  119. right: 10px;
  120. }
  121. .hotlist_text {
  122. width: 350px;
  123. height: 40px;
  124. line-height: 40px;
  125. white-space: nowrap;
  126. overflow: hidden;
  127. text-overflow: ellipsis;
  128. font-family: Microsoft YaHei, Microsoft YaHei;
  129. font-weight: bold;
  130. font-size: 18px;
  131. color: #333333;
  132. margin-top: 8px;
  133. }
  134. }
  135. .message {
  136. width: 350px;
  137. margin-top: 30px;
  138. .messageList {
  139. width: 350px;
  140. white-space: nowrap;
  141. /* 禁止换行 */
  142. overflow: hidden;
  143. /* 隐藏超出部分 */
  144. text-overflow: ellipsis;
  145. /* 超出部分显示省略号 */
  146. font-family: Microsoft YaHei, Microsoft YaHei;
  147. font-weight: 400;
  148. font-size: 18px;
  149. color: #333333;
  150. margin-bottom: 25px;
  151. a {
  152. color: #333333;
  153. }
  154. }
  155. .messageList:first-child {
  156. font-weight: bold;
  157. }
  158. >li:hover>a {
  159. color: #a01c0e;
  160. }
  161. }
  162. </style>