index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="lli-index-page">
  3. <MtaNavbar></MtaNavbar>
  4. <view class="uni-margin-wrap">
  5. <swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="5000">
  6. <swiper-item v-for="item in banners" :key="item.id" @click="handleBannerSelect(item)">
  7. <image :src="item.pic"></image>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <view>
  12. 新闻:{{data.xinwen}}
  13. </view>
  14. <br />
  15. <view>
  16. 公告: {{data.gonggao}}
  17. </view>
  18. <br />
  19. <view>
  20. 校务: {{data.xiaowu}}
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import {
  26. ref,
  27. reactive
  28. } from "vue";
  29. import {
  30. onLoad
  31. } from "@dcloudio/uni-app"
  32. import * as httpApi from "@/api/common.js"
  33. import MtaNavbar from "@/components/MtaNavbar/MtaNavbar.vue";
  34. const banners = ref('');
  35. const data = reactive({
  36. xinwen: [],
  37. xinwenTotal: 0,
  38. gonggao: [],
  39. gonggaoTotal: 0,
  40. xiaowu: [],
  41. xiaowuTotal:0,
  42. isGonggao: true,
  43. })
  44. onLoad(() => {
  45. pageInit();
  46. })
  47. function handleBannerSelect(item) {
  48. if (item.url) {
  49. window.location.href = item.url;
  50. }
  51. }
  52. function changeGonggao() {
  53. if (this.isGonggao) {
  54. return true
  55. }
  56. data.isGonggao = true;
  57. getGonggao()
  58. }
  59. function changeXiaowu() {
  60. if (!this.isGonggao) {
  61. return true
  62. }
  63. data.isGonggao = false;
  64. getXiaowu()
  65. }
  66. function getGonggao() {
  67. httpApi.getCommonXinwenTongzhiList().then(res => {
  68. data.gonggao = res.data.data;
  69. data.gonggaoTotal = res.data.total;
  70. })
  71. }
  72. function getXiaowu() {
  73. httpApi.getCommonXinwenXiaowuList().then(res => {
  74. data.xiaowu = res.data.data;
  75. data.xiaowuTotal = res.data.total;
  76. })
  77. }
  78. function pageInit() {
  79. Promise.all([
  80. httpApi.getCommonBanners({
  81. size: 1000
  82. }),
  83. httpApi.getCommonXinwenYuanxiaoList({
  84. page: 1,
  85. size: 3
  86. }),
  87. httpApi.getCommonXinwenTongzhiList({
  88. page: 1,
  89. size: 5
  90. }),
  91. httpApi.getCommonXinwenXiaowuList({page:1,size: 5})
  92. ]).then(([res1, res2, res3,res4]) => {
  93. banners.value = res1.data.data;
  94. data.xinwen = res2.data.data;
  95. data.xinwenTotal = res2.data.total;
  96. data.gonggao = res3.data.data;
  97. data.gonggaoTotal = res3.data.total;
  98. data.xiaowu = res4.data.data;
  99. data.xiaowuTotal = res4.data.total;
  100. })
  101. }
  102. </script>
  103. <style lang="scss">
  104. </style>