HotNews2.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="title">
  3. <h4>
  4. 热点精选
  5. </h4>
  6. </div>
  7. <!-- 列表 -->
  8. <ul class="rightList">
  9. <li v-for="item in hotNewsList">
  10. <NuxtLink :to="item.linkurl" v-show="item.islink == 1" :title="item.title">
  11. <img class="hotNewsImg" :src="item.imgurl">
  12. <p>{{ item.title }}</p>
  13. </NuxtLink>
  14. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" v-if="item.islink == 0" :title="item.title">
  15. <img class="hotNewsImg" :src="item.imgurl">
  16. <p>{{ item.title }}</p>
  17. </NuxtLink>
  18. </li>
  19. </ul>
  20. </template>
  21. <script setup>
  22. const hotNewsList = ref([])
  23. async function getPageData() {
  24. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  25. method: 'GET',
  26. query: {
  27. 'pageSize': 30,
  28. 'level': 5,
  29. 'placeid': 0,
  30. 'id': 0
  31. },
  32. });
  33. if (mkdata.code == 200) {
  34. for(let item of mkdata.data){
  35. if(item.imgurl){
  36. hotNewsList.value.push(item)
  37. if(hotNewsList.value.length == 5){
  38. break;
  39. }
  40. }
  41. }
  42. // hotNewsList.value = mkdata.data;
  43. } else {
  44. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  45. console.log("错误位置:获取热点精选")
  46. console.log("后端错误反馈:", mkdata.message)
  47. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  48. }
  49. }
  50. getPageData();
  51. </script>
  52. <style lang="less" scoped>
  53. .title {
  54. width: 380px;
  55. height: 40px;
  56. line-height: 40px;
  57. border-top: 1px solid #139602;
  58. border-bottom: 1px solid #e7e7e7;
  59. background-color: #fbfbfb;
  60. >h4 {
  61. font-family: Microsoft YaHei, Microsoft YaHei;
  62. font-weight: 400;
  63. margin-left: 20px;
  64. font-size: 20px;
  65. color: #000000;
  66. text-align: left;
  67. font-style: normal;
  68. text-transform: none;
  69. >span {
  70. float: right;
  71. font-family: Microsoft YaHei, Microsoft YaHei;
  72. font-weight: 400;
  73. font-size: 14px;
  74. margin-right: 10px;
  75. color: #999999;
  76. text-align: left;
  77. font-style: normal;
  78. text-transform: none;
  79. }
  80. }
  81. }
  82. .rightList {
  83. height: 556px;
  84. padding-top: 20px;
  85. background-color: #fbfbfb;
  86. >li {
  87. width: 380px;
  88. height: 100px;
  89. margin-bottom: 10px;
  90. margin-left: 15px;
  91. // background-color: #a5caa0;
  92. a {
  93. display: block;
  94. }
  95. >img {
  96. width: 150px;
  97. height: 100px;
  98. border-radius: 4px;
  99. }
  100. p {
  101. float: left;
  102. width: 220px;
  103. height: 100px;
  104. display: -webkit-box;
  105. -webkit-box-orient: vertical;
  106. -webkit-line-clamp: 3;
  107. overflow: hidden;
  108. text-overflow: ellipsis;
  109. word-break: break-all;
  110. font-family: PingFang SC, PingFang SC;
  111. font-weight: 400;
  112. font-size: 16px;
  113. color: #333333;
  114. line-height: 29px;
  115. // border-bottom: 1px solid #e7e7e7;
  116. padding-left: 12px;
  117. padding-right: 10px;
  118. padding-bottom: 10px;
  119. padding-top: 8px;
  120. box-sizing: border-box;
  121. }
  122. }
  123. >li:hover {
  124. p {
  125. //box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.1);
  126. color: #139602;
  127. }
  128. }
  129. }
  130. .hotNewsImg {
  131. float: left;
  132. width: 150px;
  133. height: 100px;
  134. border-radius: 4px;
  135. }
  136. </style>