HotNews2.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. 'imgnum': 2,
  41. 'textnum': 7,
  42. 'level': 5,
  43. 'placeid': 0,
  44. 'id': 0
  45. },
  46. });
  47. console.log('mkdata', mkdata)
  48. if (mkdata.code == 200) {
  49. hotNewsList.value = mkdata.data.text;
  50. hotNewsListImg.value = mkdata.data.img;
  51. } else {
  52. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  53. console.log("错误位置:获取热点精选")
  54. console.log("后端错误反馈:", mkdata.message)
  55. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  56. }
  57. }
  58. getPageData();
  59. // async function getPageData1() {
  60. // const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  61. // method: 'GET',
  62. // query: {
  63. // 'imgmun': 2,
  64. // 'pageSize': 0,
  65. // 'level': 5,
  66. // 'placeid': 1,
  67. // 'id': 0
  68. // },
  69. // });
  70. // if (mkdata.code == 200) {
  71. // hotNewsListImg.value = mkdata.data.img;
  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. .top_top {
  108. width: 350px;
  109. height: 165px;
  110. position: relative;
  111. .hotNews_photo_text {
  112. display: flex;
  113. justify-content: space-between;
  114. margin-top: 10px;
  115. img {
  116. width: 165px;
  117. height: 96px;
  118. }
  119. .hotNews_text {
  120. width: 165px;
  121. display: -webkit-box;
  122. -webkit-box-orient: vertical;
  123. -webkit-line-clamp: 2;
  124. overflow: hidden;
  125. text-overflow: ellipsis;
  126. word-break: break-all;
  127. font-family: Microsoft YaHei, Microsoft YaHei;
  128. font-weight: 400;
  129. font-size: 18px;
  130. color: #333333;
  131. margin-top: 15px;
  132. }
  133. .hotNews_text:hover {
  134. color: #a01c0e;
  135. }
  136. }
  137. }
  138. //新闻列表
  139. .hotNews_message {
  140. width: 350px;
  141. margin-top: 25px;
  142. .hotNews_messageList {
  143. width: 350px;
  144. white-space: nowrap;
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. font-family: Microsoft YaHei, Microsoft YaHei;
  148. font-weight: 400;
  149. font-size: 18px;
  150. color: #333333;
  151. margin-bottom: 30px;
  152. a {
  153. color: #333333;
  154. }
  155. }
  156. .hotNews_messageList:hover {
  157. color: #a01c0e;
  158. a {
  159. color: #a01c0e;
  160. }
  161. }
  162. }
  163. }
  164. </style>