PageMessage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <!-- 资讯 -->
  2. <template>
  3. <div class="message">
  4. <div class="inner">
  5. <!-- 大标题 -->
  6. <div class="bigTitle">
  7. <div class="inner" v-for="(item, index) in headlinelist" :key="index">
  8. <img src="../../static/images/toutiao.png" alt="" class="left">
  9. <!-- <h1 class="left">{{ item.title }}</h1> -->
  10. <!-- <a>{{ item.title }}</a> -->
  11. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  12. <h1 class="left">{{ item.title }}</h1>
  13. </NuxtLink>
  14. </div>
  15. </div>
  16. <!-- 大标题下的列表 -->
  17. <HomeBigTitleList></HomeBigTitleList>
  18. <div class="messageLeft">
  19. <!-- 轮播图 -->
  20. <HomeBigSwiper></HomeBigSwiper>
  21. <!-- 小图列表 -->
  22. <ul class="smallList">
  23. <li v-for="(item, index) in recommendImage" :key="index">
  24. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  25. <img :src="item.imgurl" alt="">
  26. <p>{{ item.title }}</p>
  27. </NuxtLink>
  28. </li>
  29. </ul>
  30. </div>
  31. <div class="messageRight">
  32. <!-- 列表 -->
  33. <div class="hotTop">
  34. <h3>
  35. 热点资讯
  36. <!-- <span>查看更多</span> -->
  37. </h3>
  38. <ul>
  39. <li v-for="(item, index) in hotNewsList" :key="index">
  40. <strong>{{ index + 1 }}</strong>
  41. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">{{ item.title }}</NuxtLink>
  42. </li>
  43. </ul>
  44. </div>
  45. <div class="suggest">
  46. <h3>
  47. 资讯推荐
  48. <!-- <span>查看更多</span> -->
  49. </h3>
  50. <ul>
  51. <li v-for="(item, index) in messageList" :key="index">
  52. <em></em>
  53. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">{{ item.title }}</NuxtLink>
  54. </li>
  55. </ul>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script setup>
  62. import { NuxtLink } from "#components";
  63. import { ref, onMounted } from "vue"
  64. const nuxtApp = useNuxtApp();
  65. const axios = nuxtApp.$axios;
  66. //大头条
  67. const headlinelist = useState("headlinelist", () => "");
  68. const headline = async () => {
  69. try {
  70. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${1}&level=${1}&placeid=${0}`);
  71. console.log('大标题', response.data);
  72. headlinelist.value = response.data;
  73. } catch (error) {
  74. console.error(error);
  75. }
  76. }
  77. //获取推荐图
  78. const recommendImage = useState("recommendImage", () => "");
  79. const recommendList = async () => {
  80. try {
  81. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${3}&level=${3}&placeid=${0}`);
  82. // console.log(response.data);
  83. recommendImage.value = response.data;
  84. } catch (error) {
  85. console.error(error);
  86. }
  87. }
  88. //热点资讯
  89. const hotNewsList = useState("hotNews", () => "");
  90. const hotNews = async () => {
  91. try {
  92. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${6}&level=${4}&placeid=${0}`);
  93. console.log('hotNewsList', response.data);
  94. hotNewsList.value = response.data;
  95. } catch (error) {
  96. console.error(error);
  97. }
  98. }
  99. //资讯推荐
  100. const messageList = useState("messagelist", () => "");
  101. const message = async () => {
  102. try {
  103. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${6}&level=${5}&placeid=${0}`);
  104. // console.log(response.data);
  105. messageList.value = response.data;
  106. } catch (error) {
  107. console.error(error);
  108. }
  109. }
  110. onMounted(() => {
  111. // 头条
  112. headline()
  113. //推荐图
  114. recommendList()
  115. // 热点资讯
  116. hotNews()
  117. //资讯推荐
  118. message()
  119. })
  120. </script>
  121. <style lang="less" scoped>
  122. // 大标题
  123. .bigTitle {
  124. width: 100%;
  125. height: 70px;
  126. margin-top: 38px;
  127. img {
  128. width: 57px;
  129. height: 52px;
  130. margin: 6px 17px 9px 97px;
  131. vertical-align: middle;
  132. }
  133. h1 {
  134. width: 1025px;
  135. height: 70px;
  136. font-family: PingFang SC, PingFang SC;
  137. font-weight: 600;
  138. font-size: 50px;
  139. // font-size: 38px;
  140. margin-bottom: 25px;
  141. white-space: nowrap;
  142. /* 防止文本换行 */
  143. overflow: hidden;
  144. /* 隐藏溢出的内容 */
  145. text-overflow: ellipsis;
  146. color: #028E21;
  147. line-height: 59px;
  148. text-align: left;
  149. font-style: normal;
  150. text-transform: none;
  151. }
  152. }
  153. // 资讯
  154. .message {
  155. width: 100%;
  156. height: 750px;
  157. .messageLeft,
  158. .messageRight {
  159. float: left;
  160. }
  161. // 左侧
  162. .messageLeft {
  163. // 轮播图
  164. >img {
  165. width: 790px;
  166. height: 440px;
  167. }
  168. // 轮播图下小图列表
  169. .smallList {
  170. width: 790px;
  171. height: 140px;
  172. margin-top: 16px;
  173. >li {
  174. width: 250px;
  175. height: 140px;
  176. float: left;
  177. padding-right: 20px;
  178. position: relative;
  179. // background-color: #f5f5f5;
  180. img {
  181. width: 250px;
  182. height: 140px;
  183. }
  184. p {
  185. position: absolute;
  186. bottom: 0;
  187. left: 0;
  188. width: 250px;
  189. height: 30px;
  190. white-space: nowrap;
  191. overflow: hidden;
  192. text-overflow: ellipsis;
  193. line-height: 30px;
  194. padding-left: 4px;
  195. box-sizing: border-box;
  196. font-family: PingFang SC, PingFang SC;
  197. font-weight: 500;
  198. font-size: 16px;
  199. color: #FFFFFF;
  200. text-align: left;
  201. font-style: normal;
  202. text-transform: none;
  203. background: rgba(0, 0, 0, 0.5);
  204. border-radius: 0px 0px 2px 2px;
  205. }
  206. }
  207. >li:nth-child(3) {
  208. padding-right: 0px;
  209. }
  210. }
  211. }
  212. // 右侧
  213. .messageRight {
  214. width: 380px;
  215. height: 600px;
  216. margin-left: 30px;
  217. .hotTop,
  218. .suggest {
  219. width: 380px;
  220. height: 283px;
  221. >h3 {
  222. height: 36px;
  223. font-family: Source Han Sans, Source Han Sans;
  224. font-weight: bold;
  225. font-size: 24px;
  226. color: #000000;
  227. line-height: 28px;
  228. text-align: left;
  229. font-style: normal;
  230. text-transform: none;
  231. border-bottom: 1px solid #139602;
  232. >span {
  233. float: right;
  234. width: 56px;
  235. height: 20px;
  236. line-height: 24px;
  237. font-family: PingFang SC, PingFang SC;
  238. font-weight: 400;
  239. font-size: 14px;
  240. color: #999999;
  241. font-style: normal;
  242. text-transform: none;
  243. }
  244. }
  245. ul {
  246. >li {
  247. height: 25px;
  248. padding-top: 16px;
  249. >strong {
  250. display: inline-block;
  251. width: 24px;
  252. height: 24px;
  253. line-height: 24px;
  254. background-color: #cecece;
  255. padding-left: 6px;
  256. box-sizing: border-box;
  257. font-family: Source Han Sans, Source Han Sans;
  258. font-weight: 500;
  259. font-size: 18px;
  260. color: #FFFFFF;
  261. font-style: normal;
  262. text-transform: none;
  263. vertical-align: -2px;
  264. }
  265. &:nth-child(1)>strong {
  266. background-color: #00C524;
  267. }
  268. &:nth-child(2)>strong {
  269. background-color: #FFDF27;
  270. }
  271. &:nth-child(3)>strong {
  272. background-color: #F3C57F;
  273. }
  274. >em {
  275. display: inline-block;
  276. width: 6px;
  277. height: 6px;
  278. border-radius: 10px;
  279. border: 2px solid #8CBA86;
  280. vertical-align: -1px;
  281. }
  282. >a,
  283. >span {
  284. display: inline-block;
  285. width: 330px;
  286. height: 25px;
  287. font-family: PingFang SC, PingFang SC;
  288. font-weight: 500;
  289. font-size: 18px;
  290. color: #333333;
  291. line-height: 21px;
  292. text-align: left;
  293. font-style: normal;
  294. text-transform: none;
  295. padding-left: 9px;
  296. white-space: nowrap;
  297. overflow: hidden;
  298. text-overflow: ellipsis;
  299. vertical-align: middle;
  300. }
  301. >a:hover,
  302. >span:hover {
  303. color: #139609;
  304. }
  305. }
  306. }
  307. }
  308. .suggest {
  309. margin-top: 32px;
  310. }
  311. }
  312. }
  313. </style>