| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view class="center">
- <scroll-view scroll-y="true" class="list">
- <view v-for="(item,index) in courseList" :key="index" class="listBox" @click="nav(index)">
- <view class="type">待完成</view>
- <view class="top flex">
- <image src="../../static/img/indexMycourse.png"></image>
- <view class="font">
- <view class="title">奥数能力提升班</view>
- <view class="time">{{item.start_time}}</view>
- </view>
- </view>
- <view class="main">
- <view class="left">
- <view class="font">授课科目: {{item.subject}}</view>
- <view class="font">班主任:{{ bzr }}</view>
- </view>
- <view class="right">
- <view class="font">授课老师: {{item.teacher}}</view>
- <view class="font">电话:</view>
- </view>
- </view>
- <view class="button">作业上传</view>
- </view>
- <uni-load-more :status="loadingType"></uni-load-more>
- </scroll-view>
- </view>
- </template>
- <script>
- import { getCourse } from '@/api/course.js';
- import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
- import { saveUrl, interceptor } from '@/utils/loginUtils.js';
- import { mapState, mapMutations } from 'vuex';
- import { my } from '@/api/user.js';
- export default {
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
- },
- components: {
- uniLoadMore
- },
- data() {
- return {
- page: 1,
- limit: 10,
- loadingType: 'more',
- courseList: [
-
- ],
- bzr: '',
- phone:'',
- }
- },
- onLoad() {
- if (this.hasLogin) {
- console.log(this.userInfo)
- this.loadData();
- this.data();
- }else{
- uni.showModal({
- title: '登录',
- content: '您未登录,是否马上登陆?',
- success: e => {
- console.log(e)
- if (e.confirm) {
- console.log("1111")
- interceptor();
- }
- },
- fail: e => {
- console.log(e);
- }
- });
- return;
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- this.loadData('refresh');
- },
- //监听页面是否滚动到底部加载更多
- onReachBottom() {
- this.loadData();
- },
- methods: {
- async loadData(type = 'add', loading) {
- let obj = this;
- if (type === 'add') {
- if (obj.loadingType === 'nomore') {
- return;
- }
- obj.loadingType = 'loading';
- } else {
- obj.loadingType = 'more';
- }
- if (type === 'refresh') {
- // 清空数组
- obj.courseList = [];
- obj.page = 1
- }
- //获取课程
- getCourse({
- page: obj.page,
- limit: obj.limit
- }).then(e => {
-
- obj.courseList = obj.courseList.concat(e.data.data);
- console.log(obj.courseList);
- //判断是否还有下一页,有是more 没有是nomore
- if (obj.limit==e.data.data.length) {
- obj.page++
- obj.loadingType='more'
- } else{
- obj.loadingType='nomore'
- }
- if (type === 'refresh') {
- if (loading == 1) {
- uni.hideLoading();
- } else {
- uni.stopPullDownRefresh();
- }
- }
- })
- },
- data(){
- my({}).then(({data}) => {
- this.bzr = data.manage
- })
- },
- nav(index){
- uni.navigateTo({
- url: '/pages/homework/setHomework?id=' + this.courseList[index].id
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page,
- .center {
- width: 100%;
- height: 100%;
- background-color: #f8f8f8;
- }
- .listBox {
- position: relative;
- padding-left: 28rpx;
- padding-top: 42rpx;
- margin: 0 auto;
- margin: 20rpx;
- padding-bottom: 20rpx;
- background: #FFFFFF;
- box-shadow: 0px 5rpx 24rpx 0px rgba(4, 0, 0, 0.06);
- border-radius: 15rpx;
- .type {
- position: absolute;
- top: 38rpx;
- right: 32rpx;
- width: 97rpx;
- height: 38rpx;
- text-align: center;
- background: #FFDEDF;
- border-radius: 5rpx;
- font-size: 22rpx;
- font-weight: 500;
- color: #FF5850;
- line-height: 38rpx;
- }
- .top {
- justify-content: start;
- margin-bottom: 34rpx;
- image {
- width: 76rpx;
- height: 60rpx;
- }
- .font {
- margin-left: 10rpx;
- .title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333333;
- }
- .time {
- font-size: 24rpx;
- font-weight: 400;
- color: #808080;
- }
- }
- }
- .main {
- display: flex;
- justify-content: start;
- .left {
- width: 50%;
- .font{
- font-size: 28rpx;
- font-weight: 500;
- color: #808080;
- }
- }
- .right {
- padding-left: 10rpx;
- .font{
- font-size: 28rpx;
- font-weight: 500;
- color: #808080;
- }
- }
- }
- .button {
- margin-top: 40rpx;
- margin-left: 500rpx;
- width: 145rpx;
- height: 48rpx;
- border: 1rpx solid #FF8219;
- border-radius: 24rpx;
- font-size: 26rpx;
- font-weight: 500;
- color: #FF8219;
- text-align: center;
- line-height: 48rpx;
- }
- }
- </style>
|