HotNews2.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. 'pageSize': 7,
  41. 'level': 5,
  42. 'placeid': 0,
  43. 'id': 0
  44. },
  45. });
  46. if (mkdata.code == 200) {
  47. hotNewsList.value = mkdata.data;
  48. } else {
  49. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  50. console.log("错误位置:获取热点精选")
  51. console.log("后端错误反馈:", mkdata.message)
  52. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  53. }
  54. }
  55. getPageData();
  56. async function getPageData1() {
  57. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  58. method: 'GET',
  59. query: {
  60. 'pageSize': 30,
  61. 'level': 5,
  62. 'placeid': 1,
  63. 'id': 0
  64. },
  65. });
  66. if (mkdata.code == 200) {
  67. for (let item of mkdata.data) {
  68. if (item.imgurl) {
  69. if (hotNewsListImg.value.length < 2) {
  70. hotNewsListImg.value.push(item)
  71. }
  72. }
  73. }
  74. } else {
  75. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  76. console.log("错误位置:获取热点精选")
  77. console.log("后端错误反馈:", mkdata.message)
  78. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  79. }
  80. }
  81. getPageData1();
  82. </script>
  83. <style lang="less" scoped>
  84. .hotNews {
  85. width: 350px;
  86. //标题
  87. .hotNews_title {
  88. width: 100px;
  89. height: 40px;
  90. line-height: 40px;
  91. font-family: Microsoft YaHei, Microsoft YaHei;
  92. font-weight: 400;
  93. margin: 20px 0;
  94. font-size: 20px;
  95. color: #333333;
  96. position: relative;
  97. em {
  98. display: inline-block;
  99. width: 8px;
  100. height: 8px;
  101. border-radius: 4px;
  102. background-color: #a01c0e;
  103. position: absolute;
  104. top: 6px;
  105. right: 8px;
  106. }
  107. }
  108. //图片文字
  109. .top_top {
  110. width: 350px;
  111. height: 165px;
  112. position: relative;
  113. .hotNews_photo_text {
  114. display: flex;
  115. justify-content: space-between;
  116. margin-top: 10px;
  117. img {
  118. width: 165px;
  119. height: 96px;
  120. }
  121. .hotNews_text {
  122. width: 165px;
  123. display: -webkit-box;
  124. -webkit-box-orient: vertical;
  125. -webkit-line-clamp: 2;
  126. overflow: hidden;
  127. text-overflow: ellipsis;
  128. word-break: break-all;
  129. font-family: Microsoft YaHei, Microsoft YaHei;
  130. font-weight: 400;
  131. font-size: 18px;
  132. color: #333333;
  133. margin-top: 15px;
  134. }
  135. .hotNews_text:hover {
  136. color: #a01c0e;
  137. }
  138. }
  139. }
  140. //新闻列表
  141. .hotNews_message {
  142. width: 350px;
  143. margin-top: 25px;
  144. .hotNews_messageList {
  145. width: 350px;
  146. white-space: nowrap;
  147. overflow: hidden;
  148. text-overflow: ellipsis;
  149. font-family: Microsoft YaHei, Microsoft YaHei;
  150. font-weight: 400;
  151. font-size: 18px;
  152. color: #333333;
  153. margin-bottom: 30px;
  154. a {
  155. color: #333333;
  156. }
  157. }
  158. .hotNews_messageList:hover {
  159. color: #a01c0e;
  160. a {
  161. color: #a01c0e;
  162. }
  163. }
  164. }
  165. }
  166. </style>