PageMessage.vue 11 KB

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