123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <template>
- <view class="content">
- <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
- :is-scroll="false"></u-tabs-swiper>
- <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
- <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
- <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
- :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
- @refresherrestore="onRestore">
- <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="10px" borderRadius="40" v-for="(site, index2) in item.tableList"
- :key="index2" class="class-card" @click="goToMyClass(site)">
- <view class="class-content" slot="head" style="padding-top: 10px;">
- <view class="student-name">{{site.studentName}}</view>
- <view class="class-name">{{site.studentCode}}</view>
- </view>
- <view class="class-content" slot="head" style="padding-top: 10px;">
- <view class="class-name">{{site.name}}</view>
- </view>
- <view class="class-content" slot="body">
- <view class="class-info-text">
- <u-icon name="clock"></u-icon>
- {{site.classStartDate}} {{site.classStartHours}}
- </view>
- <view class="class-info-text">
- <u-icon name="map"></u-icon>
- {{site.address}}
- </view>
- </view>
- <view class="class-content" slot="foot" style="padding-bottom: 10px;text-align: right;">
- <u-button type="default" shape="circle" :ripple="true" :custom-style="handleDefaultCustomStyle" size="mini"
- :hair-line="false" plain @click.stop="goToLeave(site)" v-if="index1 == 1">请假</u-button>
- <!-- <template v-else>
- <u-button type="warning" shape="circle" :ripple="true" :custom-style="handleCustomStyle" size="mini" @click.stop="goToEvaluate(site)" v-if="site.isEvaluate == 0">评价
- </u-button>
- </template> -->
- </view>
- </u-card>
- <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
- </scroll-view>
- </swiper-item>
- </swiper>
- <u-top-tips ref="uTips"></u-top-tips>
- </view>
- </template>
- <script>
- import {
- mapGetters
- } from 'vuex'
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- export default {
- computed: {
- ...mapGetters([
- 'mainColor',
- 'handleCustomStyle',
- 'handleDefaultCustomStyle',
- ])
- },
- data() {
- return {
- triggered: false,
- tabList: [{
- name: '未开课',
- isOver: false,
- pageIndex: 1,
- tableList: [],
- }, {
- name: '进行中',
- isOver: false,
- pageIndex: 1,
- tableList: [],
- }, {
- name: '已结束',
- isOver: false,
- pageIndex: 1,
- tableList: [],
- }],
- current: 0,
- swiperCurrent: 0,
- }
- },
- onShow() {
- this.tabList = Object.assign(this.$data.tabList, this.$options.data().tabList)
- this.getTableList(0)
- this.getTableList(1)
- this.getTableList(2)
- },
- methods: {
- // tab页面切换
- tabsChange(index) {
- this.swiperCurrent = index;
- },
- // swiper-item左右移动,通知tabs的滑块跟随移动
- transition(e) {
- let dx = e.detail.dx;
- this.$refs.uTabs.setDx(dx);
- },
- // swiper滑动结束,分别设置tabs和swiper的状态
- animationfinish(e) {
- let current = e.detail.current;
- this.$refs.uTabs.setFinishCurrent(current);
- this.swiperCurrent = current;
- this.current = current;
- },
- // 下拉刷新
- onRefresh() {
- if (!this.triggered) {
- this.triggered = true
- this.tabList[this.current].isOver = false
- this.tabList[this.current].pageIndex = 1
- this.tabList[this.current].tableList = []
- this.getTableList(this.current)
- }
- },
- // 重置下拉刷新状态
- onRestore() {
- this.triggered = false
- },
- // 懒加载
- handleLoadMore() {
- if (!this.tabList[this.current].isOver) {
- this.tabList[this.current].pageIndex++
- this.getTableList(this.current)
- }
- },
- // 获取列表数据
- getTableList(index) {
- NET.request(API.getMyClassList, {
- status: index,
- page: this.tabList[index].pageIndex,
- size: 10,
- }, 'POST').then(res => {
- this.triggered = false
- this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
- this.tabList[index].isOver = res.data.row.length != 10
- }).catch(error => {
- this.triggered = false
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- },
- // 跳转请假界面
- goToLeave(site) {
- uni.navigateTo({
- url: '/pagesMember/leaveForm?id=' + site.id + '&studentId=' + site.studentId
- });
- },
- // 跳转评价表单
- goToEvaluate(site) {
- uni.navigateTo({
- url: '/pagesMember/evaluateForm?id=' + site.id
- });
- },
- // 跳转课程详情
- goToMyClass(site) {
- uni.navigateTo({
- url: '/pagesMember/myClassDetail?id=' + site.id
- });
- }
- },
- }
- </script>
- <style>
- page {
- width: 100%;
- height: 100%;
- background-color: #f7f7f7;
- }
- </style>
- <style lang="scss" scoped>
- @import "@/static/css/themes.scss";
- .content {
- width: 100%;
- float: left;
- .swiper-box {
- height: calc(100vh - 34px);
- .swiper-item {
- height: calc(100vh - 34px);
- .scroll-box {
- width: 100%;
- height: calc(100vh - 34px);
- .class-card {
- .class-content {
- padding: 5px 15px;
- u-button {
- margin-left: 10px;
- }
- }
- .student-name {
- height: 20px;
- display: inline-block;
- padding: 0 10px;
- margin-right: 5px;
- background-color: $mainColor;
- border-radius: 10px;
- line-height: 20px;
- color: #FFFFFF;
- }
- .class-name {
- height: 20px;
- display: inline-block;
- font-weight: bold;
- font-size: 14px;
- line-height: 20px;
- }
- .class-info-text {
- color: #999999;
- margin-bottom: 5px;
- /deep/.u-icon {
- margin-right: 5px;
- font-size: 14px;
- color: #000000;
- }
- }
- }
- }
- }
- }
- }
- </style>
|