index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="lli-index-page">
  3. <btnMenuVue></btnMenuVue>
  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 @click="getXiaowu()"> 获取校务数据 </view>
  23. </view>
  24. </template>
  25. <script setup>
  26. import {
  27. ref,
  28. reactive
  29. } from "vue";
  30. import {
  31. onLoad
  32. } from "@dcloudio/uni-app"
  33. import * as httpApi from "@/api/common.js"
  34. import btnMenuVue from "@/components/btnMenu.vue";
  35. const banners = ref('');
  36. const data = reactive({
  37. xinwen: [],
  38. xinwenTotal: 0,
  39. gonggao: [],
  40. gonggaoTotal: 0,
  41. xiaowu: [],
  42. xiaowuTotal:0,
  43. isGonggao: true,
  44. })
  45. onLoad(() => {
  46. pageInit();
  47. })
  48. function handleBannerSelect(item) {
  49. if (item.url) {
  50. window.location.href = item.url;
  51. }
  52. }
  53. function changeGonggao() {
  54. if (this.isGonggao) {
  55. return true
  56. }
  57. data.isGonggao = true;
  58. getGonggao()
  59. }
  60. function changeXiaowu() {
  61. if (!this.isGonggao) {
  62. return true
  63. }
  64. data.isGonggao = false;
  65. getXiaowu()
  66. }
  67. function getGonggao() {
  68. httpApi.getCommonXinwenTongzhiList().then(res => {
  69. data.gonggao = res.data.data;
  70. data.gonggaoTotal = res.data.total;
  71. })
  72. }
  73. function getXiaowu() {
  74. httpApi.getCommonXinwenXiaowuList().then(res => {
  75. data.xiaowu = res.data.data;
  76. data.xiaowuTotal = res.data.total;
  77. })
  78. }
  79. function pageInit() {
  80. Promise.all([
  81. httpApi.getCommonBanners({
  82. size: 1000
  83. }),
  84. httpApi.getCommonXinwenYuanxiaoList({
  85. page: 1,
  86. size: 3
  87. }),
  88. httpApi.getCommonXinwenTongzhiList({
  89. page: 1,
  90. size: 5
  91. })
  92. ]).then(([res1, res2, res3]) => {
  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. })
  99. }
  100. </script>
  101. <style lang="scss">
  102. </style>