123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <view class="lli-index-page">
-
- <MtaNavbar></MtaNavbar>
-
- <view class="uni-margin-wrap">
- <swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="5000">
- <swiper-item v-for="item in banners" :key="item.id" @click="handleBannerSelect(item)">
- <image :src="item.pic"></image>
- </swiper-item>
- </swiper>
- </view>
- <view>
- 新闻:{{data.xinwen}}
- </view>
- <br />
- <view>
- 公告: {{data.gonggao}}
- </view>
- <br />
- <view>
- 校务: {{data.xiaowu}}
- </view>
-
- <view @click="getXiaowu()"> 获取校务数据 </view>
- </view>
- </template>
- <script setup>
- import {
- ref,
- reactive
- } from "vue";
- import {
- onLoad
- } from "@dcloudio/uni-app"
- import * as httpApi from "@/api/common.js"
- import MtaNavbar from "@/components/MtaNavbar/MtaNavbar.vue";
-
-
- const banners = ref('');
- const data = reactive({
- xinwen: [],
- xinwenTotal: 0,
- gonggao: [],
- gonggaoTotal: 0,
- xiaowu: [],
- xiaowuTotal:0,
-
- isGonggao: true,
- })
- onLoad(() => {
- pageInit();
- })
- function handleBannerSelect(item) {
- if (item.url) {
- window.location.href = item.url;
- }
- }
-
- function changeGonggao() {
- if (this.isGonggao) {
- return true
- }
- data.isGonggao = true;
- getGonggao()
- }
-
- function changeXiaowu() {
- if (!this.isGonggao) {
- return true
- }
- data.isGonggao = false;
- getXiaowu()
- }
-
- function getGonggao() {
- httpApi.getCommonXinwenTongzhiList().then(res => {
- data.gonggao = res.data.data;
- data.gonggaoTotal = res.data.total;
- })
- }
-
- function getXiaowu() {
- httpApi.getCommonXinwenXiaowuList().then(res => {
- data.xiaowu = res.data.data;
- data.xiaowuTotal = res.data.total;
- })
- }
-
- function pageInit() {
- Promise.all([
- httpApi.getCommonBanners({
- size: 1000
- }),
- httpApi.getCommonXinwenYuanxiaoList({
- page: 1,
- size: 3
- }),
- httpApi.getCommonXinwenTongzhiList({
- page: 1,
- size: 5
- })
- ]).then(([res1, res2, res3]) => {
- banners.value = res1.data.data;
-
- data.xinwen = res2.data.data;
- data.xinwenTotal = res2.data.total;
-
- data.gonggao = res3.data.data;
- data.gonggaoTotal = res3.data.total;
- })
- }
- </script>
- <style lang="scss">
- </style>
|