9.1 夜晚更新

This commit is contained in:
zoujiandong
2025-09-01 19:01:30 +08:00
parent 92bfc36d51
commit 1cc611d68d
5 changed files with 341 additions and 404 deletions
+112 -40
View File
@@ -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;
}
}
}
}
+7 -2
View File
@@ -263,6 +263,7 @@
import delImg from "@/static/delete_paper.png"
import api from '@/api/api.js'
import docUrl from "@/utils/docUrl.js"
import navTo from '../../utils/navTo';
const total=ref(0);
const tab=ref('zhinan')
// 响应式数据
@@ -317,7 +318,9 @@
keywords.value=selectedTags[i].DES
}
navTo({
url:'/pages_app/zhinanList/zhinanList?keywords='+encodeURIComponent(keywords.value)
})
}
isFilterActive.value=true;
@@ -366,7 +369,9 @@
// 加载指南标签列表
const loadGuideTags = async () => {
try {
const res = await api.guideTag({});
const res = await api.guideTag({
type:3
});
console.log('指南标签API响应:', res);
if(res && res.code === 200 && res.data) {
// 将API返回的标签数据转换为筛选标签格式
+196 -93
View File
@@ -10,115 +10,149 @@
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="guidelines-list">
<view
class="guideline-item"
v-for="(item, index) in guidelinesList"
:key="item.uuid || index"
>
<!-- 指南信息 -->
<view class="item-content">
<view class="item-title">{{ item.title }}</view>
<view class="item-bottom">
<view class="item-date">{{ formatDate(item.releaseTime) }}</view>
<!-- 操作按钮 -->
<view class="item-action">
<view
v-if="item.can_download"
class="download-btn"
@click="downloadGuideline(item)"
>
<up-icon name="download" color="#8D2316" size="28"></up-icon>
</view>
<view
v-else
class="view-btn"
@click="viewGuideline(item)"
>
查看
<!-- 使用scroll-view实现列表 -->
<scroll-view
class="guidelines-scroll-view"
scroll-y="true"
:refresher-enabled="true"
:refresher-triggered="isRefreshing"
@refresherrefresh="onRefresh"
@scrolltolower="onScrollToLower"
:show-scrollbar="false"
>
<!-- 指南列表 -->
<view class="guidelines-list">
<view
class="guideline-item"
v-for="(item, index) in guidelinesList"
:key="item.uuid || index"
>
<!-- 指南信息 -->
<view class="item-content">
<view class="item-title">{{ item.title }}</view>
<view class="item-bottom">
<view class="item-date">{{ formatDate(item.releaseTime) }}</view>
<!-- 操作按钮 -->
<view class="item-action">
<view
v-if="item.can_download"
class="download-btn"
@click="downloadGuideline(item)"
>
<up-icon name="download" color="#8D2316" size="28"></up-icon>
</view>
<view
v-else
class="view-btn"
@click="viewGuideline(item)"
>
查看
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 加载状态 -->
<view class="loading-status">
<view v-if="isLoading && currentPage === 1" class="loading">
<uni-load-more status="loading" :content-text="loadingText"></uni-load-more>
<!-- 加载更多状态 -->
<view class="load-more-status">
<view v-if="loadMoreStatus === 'loading'" class="loading">
<uni-icons type="spinner-cycle" size="20" color="#999"></uni-icons>
<text>加载中...</text>
</view>
<view v-else-if="loadMoreStatus === 'more'" class="more">
<text>上拉加载更多</text>
</view>
<view v-else-if="loadMoreStatus === 'noMore'" class="no-more">
<text>没有更多数据了</text>
</view>
</view>
<view v-else-if="hasMoreData && !isLoading" class="load-more" @click="loadMoreData">
<uni-load-more status="more" :content-text="loadingText"></uni-load-more>
<!-- 无数据提示 -->
<view class="no-data" v-if="guidelinesList.length === 0 && !isLoading">
<uni-icons type="info" size="60" color="#999"></uni-icons>
<text>暂无诊疗指南数据</text>
</view>
<view v-else-if="!hasMoreData && guidelinesList.length > 0" class="no-more">
<uni-load-more status="noMore" :content-text="loadingText"></uni-load-more>
</view>
</view>
<!-- 无数据提示 -->
<view class="no-data" v-if="guidelinesList.length === 0 && !isLoading">
<uni-icons type="info" size="60" color="#999"></uni-icons>
<text>暂无诊疗指南数据</text>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, onMounted} from 'vue'
import api from '@/api/api.js'
import { onShow, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
import { onShow,onLoad } from "@dcloudio/uni-app";
// 响应式数据
const guidelinesList = ref([])
const isLoading = ref(false)
const hasMoreData = ref(true)
const currentPage = ref(1)
const pageSize = ref(20)
const pageSize = ref(10)
const isRefreshing = ref(false)
const keywords=ref('');
const loadMoreStatus = ref('more') // 'loading', 'more', 'noMore'
// 加载文本配置
const loadingText = {
contentdown: '上拉显示更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了'
}
// 页面加载
onMounted(() => {
loadGuidelinesList()
onLoad((options)=>{
console.log(options)
keywords.value=decodeURIComponent(options.keywords);
console.log(keywords.value);
})
onShow(() => {
// 页面显示时可以刷新数据
loadGuidelinesList()
})
// 下拉刷新
onPullDownRefresh(() => {
refreshData()
})
// 上拉加载更多
onReachBottom(() => {
if (hasMoreData.value && !isLoading.value) {
loadMoreData()
// 页面显示时,如果列表为空则加载数据
if (guidelinesList.value.length === 0) {
loadGuidelinesList(true)
}
})
// scroll-view 下拉刷新
const onRefresh = async () => {
console.log('scroll-view 下拉刷新触发');
isRefreshing.value = true;
await refreshData();
isRefreshing.value = false;
};
// scroll-view 滚动到底部
const onScrollToLower = () => {
console.log('=== onScrollToLower 触发 ===');
console.log('当前状态:', {
loadMoreStatus: loadMoreStatus.value,
isRefreshing: isRefreshing.value,
currentPage: currentPage.value,
listLength: guidelinesList.value.length,
hasMoreData: hasMoreData.value,
isLoading: isLoading.value
});
if (loadMoreStatus.value === 'more' && !isRefreshing.value && !isLoading.value) {
console.log('条件满足,开始加载更多数据');
loadMoreData();
} else {
console.log('条件不满足,跳过加载:', {
loadMoreStatus: loadMoreStatus.value,
isRefreshing: isRefreshing.value,
isLoading: isLoading.value
});
}
};
// 刷新数据
const refreshData = async () => {
if (isRefreshing.value) return
try {
isRefreshing.value = true
currentPage.value = 1
hasMoreData.value = true
loadMoreStatus.value = 'more'
await loadGuidelinesList()
await loadGuidelinesList(true)
uni.showToast({
title: '刷新成功',
@@ -130,42 +164,59 @@ const refreshData = async () => {
title: '刷新失败',
icon: 'none'
})
} finally {
isRefreshing.value = false
uni.stopPullDownRefresh()
}
}
// 加载指南列表
const loadGuidelinesList = async (isLoadMore = false) => {
const loadGuidelinesList = async (isRefresh = false) => {
console.log('=== loadGuidelinesList 开始 ===');
console.log('当前参数:', { isRefresh, page: currentPage.value, keywords: keywords.value });
if (isLoading.value) return
try {
isLoading.value = true
loadMoreStatus.value = 'loading'
const params = {
page: currentPage.value,
pageSize: pageSize.value,
type: 1, // 诊疗指南类型
keywords: ''
sort:2,
keywords:keywords.value
}
const res = await api.searchLibraryU(params)
console.log('指南列表响应:', res)
if (res.code === 200 && res.data) {
const newData = res.data
const newData = res.data.list || res.data
if (isLoadMore) {
guidelinesList.value = [...guidelinesList.value, ...newData]
} else {
if (isRefresh) {
guidelinesList.value = newData
console.log('刷新模式:替换列表数据');
} else {
guidelinesList.value = [...guidelinesList.value, ...newData]
console.log('加载更多:追加数据到列表');
}
// 判断是否还有更多数据
hasMoreData.value = newData.length === pageSize.value
if (newData.length < pageSize.value) {
loadMoreStatus.value = 'noMore'
hasMoreData.value = false
console.log('没有更多数据了');
} else {
loadMoreStatus.value = 'more'
hasMoreData.value = true
// 只有在加载更多模式下才递增页码
if (!isRefresh) {
currentPage.value++
console.log(`还有更多数据,下一页: ${currentPage.value}`);
}
}
} else {
console.error('加载指南列表失败:', res.message)
loadMoreStatus.value = 'noMore'
uni.showToast({
title: res.message || '加载失败',
icon: 'none'
@@ -173,20 +224,36 @@ const loadGuidelinesList = async (isLoadMore = false) => {
}
} catch (error) {
console.error('加载指南列表异常:', error)
loadMoreStatus.value = 'noMore'
uni.showToast({
title: '网络异常,请重试',
icon: 'none'
})
} finally {
isLoading.value = false
console.log('=== loadGuidelinesList 结束 ===');
console.log('最终状态:', {
loadMoreStatus: loadMoreStatus.value,
page: currentPage.value,
listLength: guidelinesList.value.length
});
}
}
// 加载更多数据
const loadMoreData = () => {
console.log('=== loadMoreData 被调用 ===');
console.log('检查条件:', {
hasMoreData: hasMoreData.value,
isLoading: isLoading.value,
currentPage: currentPage.value
});
if (hasMoreData.value && !isLoading.value) {
currentPage.value++
loadGuidelinesList(true)
console.log('条件满足,开始加载更多数据');
loadGuidelinesList(false);
} else {
console.log('条件不满足,跳过加载更多');
}
}
@@ -236,6 +303,28 @@ const goBack = () => {
uni.navigateBack()
}
// 测试加载更多功能
const testLoadMore = () => {
console.log('=== 手动测试加载更多 ===');
console.log('当前状态:', {
loadMoreStatus: loadMoreStatus.value,
hasMoreData: hasMoreData.value,
isLoading: isLoading.value,
currentPage: currentPage.value,
listLength: guidelinesList.value.length
});
if (loadMoreStatus.value === 'more' && !isLoading.value) {
loadMoreData();
} else {
uni.showToast({
title: `状态: ${loadMoreStatus.value}, 加载中: ${isLoading.value}`,
icon: 'none',
duration: 2000
});
}
}
// 格式化日期
const formatDate = (dateString) => {
if (!dateString) return ''
@@ -264,7 +353,12 @@ $white: #ffffff;
.zhinan-list-page {
background-color: $bg-color;
min-height: 100vh;
height: 100vh;
}
.guidelines-scroll-view {
height: calc(100vh - 140rpx);
background-color: $bg-color;
}
// 指南列表
@@ -291,6 +385,11 @@ $white: #ffffff;
line-height: 1.5;
margin-bottom: 16rpx;
font-weight: 500;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
.item-bottom {
@@ -341,18 +440,22 @@ $white: #ffffff;
}
}
// 加载状态
.loading-status {
// 加载更多状态
.load-more-status {
padding: 20rpx 0;
text-align: center;
.loading, .load-more, .no-more {
.loading, .more, .no-more {
display: flex;
align-items: center;
justify-content: center;
gap: 10rpx;
padding: 20rpx 0;
font-size: 26rpx;
color: $text-light;
}
}
// 无数据提示
.no-data {
display: flex;