9.1 夜晚更新
This commit is contained in:
+112
-40
@@ -9,14 +9,20 @@
|
||||
height="140rpx"
|
||||
:border="false"
|
||||
backgroundColor="#eeeeee"
|
||||
></uni-nav-bar>
|
||||
>
|
||||
<template v-slot:right>
|
||||
<view class="nav-right" @click="testLoadMore">
|
||||
<text style="font-size: 24rpx; color: #8B2316;">测试加载</text>
|
||||
</view>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
|
||||
<view class="courseware-container">
|
||||
|
||||
<!-- 排序和筛选栏 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" @click="toggleSort">
|
||||
<text class="filter-text">{{sort==2?'最新':'最热'}}</text>
|
||||
<text class="filter-text">{{sort==0?'最新':'最热'}}</text>
|
||||
<view class="newbox">
|
||||
<up-image :src="upImg" width="20rpx" height="26rpx" ></up-image>
|
||||
</view>
|
||||
@@ -47,17 +53,24 @@
|
||||
<view class="pdf-icon">📄</view>
|
||||
</view>
|
||||
<view class="item-content">
|
||||
<view class="item-title">{{ item.title }}</view>
|
||||
<view class="item-author">{{ item.author }}</view>
|
||||
<view class="item-title">{{item.title}}</view>
|
||||
<view class="info">
|
||||
<view >{{ item.providername }}</view>
|
||||
<view class="item-author">{{ item.hospitalname }}</view>
|
||||
</view>
|
||||
<view class="item-stats">
|
||||
<view class="views">
|
||||
<uni-icons type="eye" size="30rpx" color="#999"></uni-icons>
|
||||
<text class="view-count">{{ item.views }}人阅读</text>
|
||||
<text class="view-count">{{ item.readnum }}人阅读</text>
|
||||
</view>
|
||||
|
||||
<view class="price">
|
||||
<up-image :src="downLoadImg" width="32rpx" height="32rpx" ></up-image>
|
||||
<text class="price-value">{{ item.price }}</text>
|
||||
<view class="priceImg">
|
||||
<up-image :src="downLoadImg" width="32rpx" height="32rpx" ></up-image>
|
||||
</view>
|
||||
<text class="price-value" v-if="item.price>0"><text class="money-unit">¥</text>{{ item.price>item.discount?fromatPrice(item.discount):fromatPrice(item.price) }}</text>
|
||||
<text class="yuanjia" v-if="item.price>0 && item.price>item.discount">原价<text class="jiaprice">{{fromatPrice(item.price/100)}}</text></text>
|
||||
<text v-else class="free">免费</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -106,7 +119,7 @@
|
||||
import downLoadImg from "@/static/wdxz.png"
|
||||
import api from '@/api/api.js';
|
||||
const isFilterActive=ref(false)
|
||||
const sort = ref(2);
|
||||
const sort = ref(0); // 默认最新排序
|
||||
// 响应式数据
|
||||
const refreshing = ref(false);
|
||||
const loading = ref(false);
|
||||
@@ -136,7 +149,10 @@
|
||||
};
|
||||
|
||||
const toggleSort = () => {
|
||||
sort.value=sort.value==1?2:1
|
||||
sort.value = sort.value === 0 ? 1 : 0;
|
||||
console.log('切换排序:', sort.value);
|
||||
// 切换排序后重新加载数据
|
||||
loadData(true);
|
||||
};
|
||||
|
||||
|
||||
@@ -184,22 +200,24 @@
|
||||
|
||||
// 上拉加载更多
|
||||
const onLoadMore = async () => {
|
||||
console.log('加载更多')
|
||||
if (loading.value || noMore.value) return;
|
||||
console.log('=== onLoadMore 触发 ===');
|
||||
console.log('当前状态:', {
|
||||
loading: loading.value,
|
||||
noMore: noMore.value,
|
||||
page: page.value,
|
||||
listLength: coursewareList.value.length
|
||||
});
|
||||
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
// 加载下一页数据
|
||||
await loadData(false);
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'error'
|
||||
if (loading.value || noMore.value) {
|
||||
console.log('条件不满足,跳过加载:', {
|
||||
loading: loading.value,
|
||||
noMore: noMore.value
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('条件满足,开始加载更多数据');
|
||||
await loadData(false);
|
||||
};
|
||||
|
||||
// 加载数据
|
||||
@@ -219,7 +237,6 @@
|
||||
// 调用API获取课件列表
|
||||
const res = await api.ganDanFileByKeyWords({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
sort: sort.value,
|
||||
// 可以根据需要添加其他筛选参数
|
||||
keywords: '',
|
||||
@@ -237,7 +254,7 @@
|
||||
// 解析API返回的数据结构
|
||||
if (res.data && res.data.list) {
|
||||
newItems = res.data.list;
|
||||
totalCount = res.data.total || res.data.totalRow || 0;
|
||||
totalCount = res.data.totalRow;
|
||||
console.log('使用 res.data.list 结构');
|
||||
} else if (res.data && Array.isArray(res.data)) {
|
||||
newItems = res.data;
|
||||
@@ -265,8 +282,11 @@
|
||||
noMore.value = true;
|
||||
console.log('没有更多数据了');
|
||||
} else {
|
||||
page.value++;
|
||||
console.log(`还有更多数据,下一页: ${page.value}`);
|
||||
// 只有在加载更多模式下才递增页码
|
||||
if (!isRefresh) {
|
||||
page.value=page.value+1;
|
||||
console.log(`还有更多数据,下一页: ${page.value}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.error('API返回的数据不是数组格式:', newItems);
|
||||
@@ -332,11 +352,39 @@
|
||||
hideFilterPopup();
|
||||
// 这里可以根据选中的标签进行数据筛选
|
||||
};
|
||||
const fromatPrice=(price)=>{
|
||||
if(price<1){
|
||||
return price.toFixed(2)
|
||||
}else{
|
||||
return price.toFixed(1)
|
||||
}
|
||||
}
|
||||
onShow(() => {
|
||||
// 页面显示时加载数据
|
||||
console.log('页面显示,开始加载课件数据');
|
||||
loadData(true);
|
||||
});
|
||||
|
||||
// 测试加载更多功能
|
||||
const testLoadMore = () => {
|
||||
console.log('=== 手动测试加载更多 ===');
|
||||
console.log('当前状态:', {
|
||||
loading: loading.value,
|
||||
noMore: noMore.value,
|
||||
page: page.value,
|
||||
listLength: coursewareList.value.length
|
||||
});
|
||||
|
||||
if (!loading.value && !noMore.value) {
|
||||
onLoadMore();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `加载中: ${loading.value}, 无更多: ${noMore.value}`,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
// 变量定义
|
||||
@@ -438,15 +486,16 @@
|
||||
top:240rpx;
|
||||
flex: 1;
|
||||
bottom:0;
|
||||
width:100%;
|
||||
left:30rpx;
|
||||
right:30rpx;
|
||||
padding-top: 20rpx;
|
||||
margin: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
|
||||
width:auto;
|
||||
.courseware-item {
|
||||
background-color: $white;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
padding: 30rpx 0;
|
||||
margin-bottom: 20rpx;
|
||||
@include shadow;
|
||||
display: flex;
|
||||
@@ -464,18 +513,23 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
|
||||
.item-title {
|
||||
.item-title{
|
||||
font-size: 32rpx;
|
||||
color: $text-primary;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
color:#333;
|
||||
}
|
||||
.info{
|
||||
display: flex;
|
||||
font-size: 26rpx;
|
||||
color:#666;
|
||||
}
|
||||
|
||||
|
||||
.item-author {
|
||||
font-size: 28rpx;
|
||||
color: $text-secondary;
|
||||
line-height: 1.3;
|
||||
margin-left: 10rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 200rpx; /* 限制最大宽度 */
|
||||
}
|
||||
|
||||
.item-stats {
|
||||
@@ -518,10 +572,28 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.free{
|
||||
font-size: 26rpx;
|
||||
color:#999;
|
||||
}
|
||||
.yuanjia{
|
||||
font-size: 26rpx;
|
||||
margin-left: 10rpx;
|
||||
color:#999;
|
||||
.jiaprice{
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
.priceImg{
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
.price-value {
|
||||
font-size: 32rpx;
|
||||
font-size: 26rpx;
|
||||
color: $primary-color;
|
||||
font-weight: bold;
|
||||
|
||||
.money-unit{
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user