HotNews2.vue 4.4 KB

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