HotNews.vue 5.0 KB

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