123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <view class="container">
- <u-empty
- mode="data"
- v-if="courses.length === 0"
- iconSize="120"
- textSize="58"
- text="暂无数据"
- >
- </u-empty>
- <view class="course-list" style="margin-bottom: 20rpx;">
- <view class="list-box">
- <view class="list-item-box" v-for="item in courses" :key="item.id" @click="toCourse(item)">
- <view class="info-box">
- <view class="title">
- {{item.title}}
- </view>
- <view class="text">
- 【{{item.typeName}}】
- </view>
- </view>
- <view class="suffix-box">
- <view class="button">
- 查看
- </view>
- </view>
- </view>
- </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 {
- query
- } from '@/api/collect.js'
- // 日期格式:xxxx年xx月xx日(星期x)
- 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({
- "keyword": "",
- "type": "2",
- "pageNumber": 1,
- "pageSize": 30
- })
- const status = ref('loadmore')
- const count = ref(0)
- const courses = ref([]);
- const initCourse = () => {
- if(status.value === 'nomore'){
- return;
- }
- status.value = 'loading'
- query(form.value).then(res=>{
- if(res && res?.code ===0){
- count.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'
- }
-
- form.value.pageNumber = form.value.pageNumber + 1
- }else{
- status.value = 'loadmore'
- }
- })
- }
- const toCourse = (item)=>{
- uni.navigateTo({
- url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${item.id}&name=${item.title}`
- });
- }
- onLoad(() => {
- form.value.pageNumber = 1;
- initCourse();
- })
- 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;
- }
- }
- }
-
- .list-box {
- .list-item-box {
- padding: 20rpx 10rpx;
- border-bottom: 5rpx solid #E6E6E6;
- display: flex;
- &:active {
- background-color: $uni-bg-color-hover;
- }
- .icon-box {
- width: 3%;
- padding-top: 10rpx;
- .icon {
- width: 10rpx;
- height: 10rpx;
- background-color: $uni-color-primary;
- border-radius: 50%;
- }
- }
- .info-box {
- width: 82%;
- .title {
- font-size: $uni-title-font-size-2;
- font-weight: bold;
- margin-bottom: 5rpx;
- @include text-overflow()
- }
- .text {
- line-height: 40rpx;
- font-size: $uni-font-size-2;
- font-weight: bold;
- }
- }
- .suffix-box {
- width: 15%;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .button {
- color: $uni-text-color-inverse;
- padding: 5rpx 18rpx;
- border-radius: $uni-card-border-radius;
- background-color: $uni-color-primary;
- font-size: $uni-font-size-3;
- letter-spacing: 3rpx;
- }
- }
- }
- }
- </style>
|