123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <template>
- <view class="container">
- <u-empty
- mode="data"
- v-if="courses.length === 0"
- iconSize="120"
- textSize="58"
- text="暂无数据"
- >
- </u-empty>
- <view class="course-list">
- <view v-for="(course,index) in courses" :key="course.id">
- <view class="course-item">
- <view class="course-item-image">
- <image class="course-image" :src="course.imgUrl" mode="aspectFill"></image>
- </view>
- <view class="course-item-content">
- <view class="course-title">
- <text>{{ course.courseName }}</text>
- </view>
- <view class="course-type">{{ course.courseType }}</view>
- <view class="course-date">
- <u-icon name="clock" size="28"></u-icon>
- {{ getDateWeek(course.viewDate) }}
- </view>
- </view>
- </view>
- <u-line />
- </view>
- </view>
- <u-loadmore :status="status" v-if="courses.length !== 0 && status!=='nomore'"/>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad, onReachBottom
- } from '@dcloudio/uni-app'
- import {
- loadCourseHistory
- } from '@/api/edu.js'
- function getDateWeek(val) {
- const date = new Date(val);
- const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
- const year = date.getFullYear();
- const month = date.getMonth() + 1; // 注意:月份从0开始
- const day = date.getDate();
- const dayOfWeek = daysOfWeek[date.getUTCDay()];
- // const result = `${year}年${month}月${day}日(星期${dayOfWeek})`
- return `${year}年${month}月${day}日(星期${dayOfWeek})`
- }
- const form = ref({
- pageNumber: 1,
- pageSize: 20
- })
- const status = ref('loadmore')
-
- const total = ref(0)
- const courses = ref([]);
- const initCourse = () => {
- if(status.value==='nomore'){
- return
- }
- status.value === 'loading'
- loadCourseHistory(form.value).then(res=>{
- if(res && res?.code===0){
- total.value = res.count;
- if(form.value.pageNumber===1){
- courses.value = res.data
- }else{
- courses.value = [...courses.value, ...res.data]
- }
- if(courses.value.length === res.count){
- status.value = 'nomore'
- }else{
- status.value = 'loadmore'
- }
-
- }else{
- status.value = 'loadmore'
- }
- })
- }
- onLoad(() => {
- form.value.pageNumber = 1
- initCourse();
- // console.log('onLoad')
- })
-
- onReachBottom(()=>{
- // 加载
- initCourse()
- })
- </script>
- <style lang="scss" scoped>
- .container {
- height: 100vh;
- width: 100vw;
- background-color: #fff;
- padding: 0 20rpx env(safe-area-inset-bottom, 0);
- }
- .course-item {
- margin: 20rpx 0;
- display: flex;
- overflow: hidden;
- .course-item-image {
- width: 200rpx;
- height: 260rpx;
- flex: 0 0 auto;
- margin-right: 20rpx;
- .course-image {
- width: 100%;
- }
- }
- .course-item-content {
- flex: 1;
- position: relative;
- view {
- margin-bottom: 15rpx;
- }
- .course-title {
- font-weight: bold;
- margin-right: 10px;
- font-size: 28rpx;
- color: #000;
- }
- .course-type,
- .course-teacher,
- .course-date,
- .course-price {
- font-size: 30rpx;
- color: #000;
- }
- .course-price {
- color: #fe0000;
- letter-spacing: 2rpx;
- }
- .button::after {
- content: none;
- /* 移除内容 */
- }
- .button {
- position: absolute;
- right: 0;
- bottom: 0;
- min-width: 80px;
- padding: 0 40rpx;
- white-space: nowrap;
- height: 45rpx;
- line-height: 45rpx;
- font-size: 22rpx;
- /* padding: 0; */
- border-radius: 50rpx;
- color: white;
- border: none;
- }
- .free {
- background-color: #006af4;
- }
- .purchase {
- background-color: #fe0000;
- }
- .member-free {
- background-color: transparent;
- background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
- background-size: cover;
- background-repeat: no-repeat;
- color: #000;
- height: initial;
- padding: 6rpx 0 3rpx;
- border-radius: 0;
- }
- .replay {
- background-color: #006af4;
- }
- .purchased {
- background-color: #006af4;
- }
- }
- }
- </style>
|