zixun.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <script setup>
  2. import { ref, onMounted } from "vue";
  3. import Banner from "~/components/Banner/index.vue";
  4. import IndexTitle from "~/components/IndexTitle/index.vue";
  5. import IndexNews from "~/components/IndexNews/index.vue";
  6. import YXFooter from "~/components/layouts/Footer.vue";
  7. import * as newsApi from "~/api/news";
  8. import { useRouter } from "vue-router";
  9. const router = useRouter();
  10. const page = ref(1);
  11. const total = ref(0)
  12. //分页器
  13. const handleCurrentChange = (val) => {
  14. page.value = val;
  15. __news__();
  16. };
  17. // 获取精品咨询列表
  18. let newsList = ref([]);
  19. const __news__ = async () => {
  20. try {
  21. const { data } = await newsApi.list({
  22. page: page.value,
  23. limit: 12,
  24. is_page: 1,
  25. is_boutique: 1,
  26. });
  27. newsList.value = data.list;
  28. total.value = data.total
  29. } catch (error) {}
  30. };
  31. onMounted(__news__);
  32. const todetails = (id) => {
  33. router.push({
  34. name: "news",
  35. query: {
  36. id: id,
  37. },
  38. });
  39. };
  40. </script>
  41. <template>
  42. <div class="articles-container">
  43. <div class="title">精选资讯</div>
  44. <div class="content-list flex-row flex-jc-sb">
  45. <template v-for="(item, idx) in newsList" :key="idx">
  46. <IndexNews
  47. @update="todetails(item.id)"
  48. :title="item.title"
  49. :time-ago="item.published_at"
  50. :like-count="item.like_count"
  51. :comment-count="item.comment_count"
  52. :image="item.image"
  53. />
  54. </template>
  55. </div>
  56. <div class="pagination-container">
  57. <el-pagination
  58. background
  59. layout="prev, pager, next"
  60. :total="total"
  61. :page-size="12"
  62. @current-change="handleCurrentChange"
  63. />
  64. </div>
  65. <YXFooter />
  66. </div>
  67. </template>
  68. <style lang="scss" scoped>
  69. @import "~/styles/variable.scss";
  70. .title {
  71. font-family: PingFangSC, PingFang SC;
  72. font-weight: 600;
  73. font-size: 18px;
  74. color: #333333;
  75. line-height: 25px;
  76. text-align: left;
  77. font-style: normal;
  78. margin-bottom: 24px;
  79. }
  80. .articles-container {
  81. .index-title-container {
  82. margin-bottom: 20px;
  83. }
  84. .content-list {
  85. margin-bottom: 30px;
  86. column-gap: 20px;
  87. flex-wrap: wrap;
  88. height: 255px;
  89. overflow: hidden;
  90. }
  91. .article-main {
  92. display: grid;
  93. grid-template-columns: repeat(4, auto);
  94. justify-content: space-between;
  95. row-gap: 30px;
  96. }
  97. }
  98. </style>