HotNews2.vue 4.8 KB

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