| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view class="center">
- <view class="english">various courses for children</view>
- <scroll-view scroll-y="true" class="list">
- <view v-for="(item,index) in courseList" :key="index" class="listBox" @click="nav(index)">
- <view class="bg"></view>
- <view class="title">暑假培训阅读精品课</view>
- <view class="teacher">授课科目:{{ item.subject}} {{ item.teacher}}</view>
- <view class="bzr">{{ item.bzr }}</view>
- <view class="button">上传作业</view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import { getCourse } from '@/api/course.js'
- export default {
- data() {
- return {
- page: 1,
- limit: 10,
- loadingType: 'more',
- courseList: [
-
- ],
- }
- },
- onLoad() {
- this.loadData();
- },
- //下拉刷新
- 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.length) {
- obj.page++
- obj.loadingType='more'
- } else{
- obj.loadingType='nomore'
- }
- if (type === 'refresh') {
- if (loading == 1) {
- uni.hideLoading();
- } else {
- uni.stopPullDownRefresh();
- }
- }
- })
- },
- 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;
- }
- .english {
- padding-left: 41rpx;
- font-size: 25rpx;
- font-family: Source Han Sans CN;
- font-weight: 400;
- color: #C2C2C2;
- }
- .list {
- height: 1100rpx;
- }
- .listBox {
- position: relative;
- width: 90%;
- height: 250rpx;
- margin: 0 auto;
- margin-top: 34rpx;
- box-shadow: 0rpx 5rpx 16rpx 0rpx rgba(253, 90, 84, 0.48);
- border-radius: 28rpx;
- .bg {
- width: 100%;
- height: 100%;
- position: absolute;
- left: 0;
- top: 0;
- background-color: #4EADFA;;
- border-radius: 28rpx;
- }
- .title {
- position: relative;
- padding-top: 36rpx;
- padding-left: 36rpx;
- font-size: 36rpx;
- font-weight: bold;
- color: #FFFFFF;
- z-index: 1;
- }
- .teacher {
- position: relative;
- margin-top: 56rpx;
- margin-left: 36rpx;
- font-size: 24rpx;
- font-weight: 500;
- color: #FFFFFF;
- z-index: 1;
- }
- .bzr {
- position: relative;
- margin-left: 36rpx;
- font-size: 24rpx;
- font-weight: 500;
- color: #FFFFFF;
- z-index: 1;
- }
- .button {
- position: absolute;
- right: 26rpx;
- bottom: 35rpx;
- width: 160rpx;
- height: 57rpx;
- background: #FFFFFF;
- border-radius: 28rpx;
- text-align: center;
- line-height: 57rpx;
- font-size: 27rpx;
- font-weight: bold;
- color: #FD5954;
- }
- }
- </style>
|