Files
tra-app/src/pages/learningTasks/components/list-item.vue
T
2025-08-19 13:45:39 +08:00

232 lines
4.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="scroll_div">
<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="scrolltolower" :show-scrollbar='false'>
<view class="item" :class="getStatusClass(index)" v-for="(item,index) in data_list">
<view class="img_div">
<image class="img" src="@/static/images/test/4.png" mode="scaleToFill"></image>
<view class="subscript" v-if="index % 3==0">
进行中
</view>
<view class="subscript" v-if="index % 3==1">
已完成
</view>
<view class="subscript" v-if="index % 3==2">
已超时
</view>
</view>
<view class="right_div">
<view class="title ellipsis-text">
{{item.taskName}}
</view>
<view class="time_div" v-if="item.limitTyp==='02'">
起止时间<text class="blod_color">{{item.startTm?.substr(0, 10)}}{{item.endTm?.substr(0, 10)}}</text>
</view>
<view class="people_progress_div">
<view class="mr-10">
完成人数<text class="">{{item.taskFinishSums ?? 0}}/{{item.taskSums ?? 0}}</text>
</view>
<view>
进度<text class="">2/4门课程</text>
</view>
</view>
</view>
</view>
<uv-load-more v-if="total != 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
</scroll-view>
</view>
</template>
<script setup>
const status = ref('loading') // loadmore - 加载前,loading - 加载中,nomore - 没有数据
const limit = 15
const total = ref(-1)
const page = ref(0)
const data_list = reactive([])
import {
ref,
reactive,
onMounted,
nextTick
} from 'vue'
import {
queryAllTraTaskInfoByUserId,
} from '@/api/learningTasks.js';
const getData = (from = '') => {
if (from == 'first') {
if (total.value !== -1) {
return
}
status.value = 'loading'
total.value = -1
page.value = 1
data_list.length = 0
} else {
if (status.value !== 'loadmore' && status.value !== '') return
status.value = 'loading'
page.value++
}
setTimeout(() => {
queryAllTraTaskInfoByUserId({
state: '01',
page: page.value,
limit: limit
}).then(res => {
total.value = res.total
data_list.push(...res.body)
}).finally(() => {
if (data_list.length >= total.value) {
status.value = 'nomore'
} else {
status.value = 'loadmore'
}
console.log(status.value, '阿斯顿撒');
})
}, 200)
}
const getStatusClass = (index) => {
const remainder = index % 3;
if (remainder === 0) return 'in_progress';
if (remainder === 1) return 'completed';
return 'expired';
};
const scrolltolower = (item) => {
getData()
};
defineExpose({
getData
})
</script>
<style scoped lang="scss">
.scroll_div {
background-color: #F1F5FA;
padding: 22rpx;
}
.scroll-Y {
height: calc(100vh - var(--status-bar-height) - 88rpx - 80rpx - 88rpx - 20rpx - 30rpx);
// height: calc(100vh - var(--status-bar-height) - 54rpx - 88rpx - 20rpx - 44rpx);
background-color: #fff;
border-radius: 16rpx;
}
.scroll-Y {
.item.in_progress {
// 进行中
.subscript {
color: #0066FF;
background-color: #DAF0FF;
}
.blod_color {
color: #0066FF;
}
}
.item.completed {
// 已完成
.subscript {
color: #FFFFFF;
background-color: #33C583 !important;
}
.blod_color {
color: #0066FF;
}
}
.item.expired {
// 已超时
.subscript {
color: #FFFFFF;
background-color: #EF5705;
}
.blod_color {
color: #D70C18;
}
}
}
.scroll-Y .item {
height: 170rpx;
margin: 32rpx 22rpx;
display: flex;
.img_div {
position: relative;
width: 224rpx;
height: 168rpx;
overflow: hidden;
border-radius: 22rpx;
.img {
width: 226rpx;
height: 168rpx;
}
.subscript {
position: absolute;
right: 0;
top: 0;
width: 92rpx;
height: 46rpx;
border-radius: 0px 0px 0px 22rpx;
font-family: PingFangSC;
font-weight: 400;
font-size: 22rpx;
line-height: 32px;
display: flex;
align-items: center;
justify-content: center;
}
}
.right_div {
flex: 1;
overflow: hidden;
margin-left: 24rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.title {
font-family: PingFangSC;
font-size: 30rpx;
font-weight: 600;
color: #333333;
line-height: 44rpx;
}
.time_div {
font-family: PingFangSC;
font-weight: 400;
font-size: 23rpx;
color: #666;
line-height: 23rpx;
flex-wrap: nowrap;
height: 23rpx;
overflow: hidden;
}
.people_progress_div {
display: flex;
font-family: PingFangSC;
font-weight: 400;
font-size: 23rpx;
color: #666;
margin-bottom: 23rpx;
line-height: 23rpx;
flex-wrap: nowrap;
height: 23rpx;
overflow: hidden;
}
}
}
</style>