很多页面
This commit is contained in:
@@ -37,11 +37,11 @@
|
||||
<view class="summary-bar">
|
||||
<view class="summary-item">
|
||||
<up-image :src="downLoadImg" width="36rpx" height="36rpx" ></up-image>
|
||||
<text class="summary-text">: {{ downloadCount }}</text>
|
||||
<text class="summary-text">{{ activeTab === 'download' ? '下载账户' : '分享账户' }}: {{ downloadCount }}</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<up-image :src="moneyImg" width="36rpx" height="36rpx" ></up-image>
|
||||
<text class="summary-text">: {{ totalAmount }}</text>
|
||||
<text class="summary-text">{{ activeTab === 'download' ? '文件数量' : '分享文件' }}: {{ totalAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -55,12 +55,21 @@
|
||||
@scrolltolower="onLoadMore"
|
||||
:lower-threshold="100"
|
||||
>
|
||||
<!-- 空状态 -->
|
||||
<view v-if="coursewareList.length === 0 && !loading" class="empty-state">
|
||||
<text>{{ activeTab === 'download' ? '暂无下载数据' : '暂无分享数据' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="courseware-item" v-for="(item, index) in coursewareList" :key="index" @click="onItemClick(item)">
|
||||
<view class="item-content">
|
||||
<view class="courseware-name">
|
||||
<text class="label">课件名称:</text>
|
||||
<text class="value">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="courseware-provider" v-if="item.providername">
|
||||
<text class="label">{{ activeTab === 'download' ? '提供者' : '下载者' }}:</text>
|
||||
<text class="value">{{ item.providername }}</text>
|
||||
</view>
|
||||
<view class="courseware-time">
|
||||
<text class="label">时间:</text>
|
||||
<text class="value">{{ item.time }}</text>
|
||||
@@ -78,7 +87,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 没有更多数据提示 -->
|
||||
<view v-if="noMore" class="no-more">
|
||||
<view v-if="noMore && coursewareList.length > 0" class="no-more">
|
||||
<text>没有更多数据了</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -86,7 +95,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import api from '@/api/api';
|
||||
import downLoadImg from "@/static/course_download.png"
|
||||
import moneyImg from "@/static/course_yuan.png"
|
||||
const activeTab = ref('download');
|
||||
@@ -98,28 +108,11 @@ const pageSize = ref(10);
|
||||
const downloadCount = ref(4);
|
||||
const totalAmount = ref('20.00');
|
||||
|
||||
const coursewareList = ref([
|
||||
{
|
||||
name: '慢性病毒性肝炎患者干扰素治疗不良反应临床处理专家共识',
|
||||
time: '2025-02-21',
|
||||
status: '已支付'
|
||||
},
|
||||
{
|
||||
name: '慢乙肝抗病毒治疗-把握时机正确选择',
|
||||
time: '2024-11-27',
|
||||
status: '已支付'
|
||||
},
|
||||
{
|
||||
name: '肝病相关血小板减少症临床管理中国专家共识(2023)解读',
|
||||
time: '2024-10-06',
|
||||
status: '已支付'
|
||||
},
|
||||
{
|
||||
name: '俞云松:耐药阳性菌感染诊疗思路(CHINET数据云)',
|
||||
time: '2022-10-24',
|
||||
status: '已支付'
|
||||
}
|
||||
]);
|
||||
const coursewareList = ref([]);
|
||||
|
||||
onMounted(() => {
|
||||
onRefresh();
|
||||
});
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack();
|
||||
@@ -131,37 +124,173 @@ const switchTab = (tab) => {
|
||||
page.value = 1;
|
||||
noMore.value = false;
|
||||
// 这里可以根据标签加载不同数据
|
||||
onRefresh();
|
||||
};
|
||||
|
||||
const onItemClick = (item) => {
|
||||
uni.showToast({ title: `点击了: ${item.name}`, icon: 'none' });
|
||||
// 这里可以根据需要跳转到详情页或执行下载操作
|
||||
console.log('点击课件:', item);
|
||||
|
||||
if (activeTab.value === 'download') {
|
||||
// 下载标签页的处理逻辑
|
||||
if (item.download_path) {
|
||||
uni.downloadFile({
|
||||
url: item.download_path,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
uni.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
success: () => {
|
||||
console.log('打开文档成功');
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('打开文档失败:', err);
|
||||
uni.showToast({ title: '无法打开此文件', icon: 'none' });
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('下载失败:', err);
|
||||
uni.showToast({ title: '下载失败', icon: 'none' });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({ title: `点击了下载课件: ${item.name}`, icon: 'none' });
|
||||
}
|
||||
} else {
|
||||
// 分享标签页的处理逻辑
|
||||
uni.showToast({ title: `点击了分享课件: ${item.name}`, icon: 'none' });
|
||||
// 这里可以添加分享相关的操作,比如查看分享详情、重新分享等
|
||||
}
|
||||
};
|
||||
|
||||
const onRefresh = () => {
|
||||
refreshing.value = true;
|
||||
page.value = 1;
|
||||
noMore.value = false;
|
||||
|
||||
setTimeout(() => {
|
||||
refreshing.value = false;
|
||||
uni.showToast({ title: '刷新完成', icon: 'success' });
|
||||
}, 1000);
|
||||
if (activeTab.value === 'download') {
|
||||
api.getGandanfileMyDownload({ page: page.value }).then(res => {
|
||||
console.log(res);
|
||||
if (res.code === 200 && res.data) {
|
||||
const data = res.data.list;
|
||||
// 更新摘要信息
|
||||
downloadCount.value = res.data.downloadTotalAccount || 0;
|
||||
totalAmount.value = res.data.downloadFileCount || 0;
|
||||
|
||||
// 处理课件列表数据
|
||||
coursewareList.value = data.list.map(item => ({
|
||||
name: item.title || '未知课件',
|
||||
time: item.create_date ? item.create_date.split(' ')[0] : '',
|
||||
status: item.order_status === 'paid' ? '已支付' : '未支付',
|
||||
uuid: item.uuid,
|
||||
order_id: item.order_id,
|
||||
type: item.type,
|
||||
providername: item.providername
|
||||
}));
|
||||
|
||||
// 判断是否还有更多数据
|
||||
noMore.value = data.pageNumber >= data.totalPage;
|
||||
}
|
||||
refreshing.value = false;
|
||||
}).catch(err => {
|
||||
console.error('获取下载列表失败:', err);
|
||||
refreshing.value = false;
|
||||
});
|
||||
} else {
|
||||
api.getGandanfileMyShare({ page: page.value }).then(res => {
|
||||
console.log(res);
|
||||
if (res.code === 200 && res.data) {
|
||||
const data = res.data.list;
|
||||
// 更新摘要信息 - 分享数据使用不同的字段
|
||||
downloadCount.value = res.data.shareTotalAccount || 0;
|
||||
totalAmount.value = res.data.shareloadFileCount || 0;
|
||||
|
||||
// 处理分享列表数据
|
||||
coursewareList.value = data.list.map(item => ({
|
||||
name: item.title || '未知课件',
|
||||
time: item.create_date ? item.create_date.split(' ')[0] : '',
|
||||
status: '已分享', // 分享数据没有支付状态,统一显示为已分享
|
||||
uuid: item.uuid,
|
||||
order_id: item.order_id,
|
||||
type: item.type,
|
||||
providername: item.downloadername, // 分享数据中下载者名称对应提供者
|
||||
downloadername: item.downloadername
|
||||
}));
|
||||
|
||||
// 判断是否还有更多数据
|
||||
noMore.value = data.pageNumber >= data.totalPage;
|
||||
}
|
||||
refreshing.value = false;
|
||||
}).catch(err => {
|
||||
console.error('获取分享列表失败:', err);
|
||||
refreshing.value = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onLoadMore = () => {
|
||||
if (loading.value || noMore.value) return;
|
||||
|
||||
loading.value = true;
|
||||
page.value++;
|
||||
|
||||
setTimeout(() => {
|
||||
if (page.value < 3) {
|
||||
page.value++;
|
||||
uni.showToast({ title: '加载完成', icon: 'success' });
|
||||
} else {
|
||||
noMore.value = true;
|
||||
}
|
||||
loading.value = false;
|
||||
}, 1000);
|
||||
if (activeTab.value === 'download') {
|
||||
api.getGandanfileMyDownload({ page: page.value }).then(res => {
|
||||
console.log(res);
|
||||
if (res.code === 200 && res.data) {
|
||||
const data = res.data.list;
|
||||
// 追加新数据到列表
|
||||
const newList = data.list.map(item => ({
|
||||
name: item.title || '未知课件',
|
||||
time: item.create_date ? item.create_date.split(' ')[0] : '',
|
||||
status: item.order_status === 'paid' ? '已支付' : '未支付',
|
||||
uuid: item.uuid,
|
||||
order_id: item.order_id,
|
||||
type: item.type,
|
||||
providername: item.providername
|
||||
}));
|
||||
|
||||
coursewareList.value = [...coursewareList.value, ...newList];
|
||||
|
||||
// 判断是否还有更多数据
|
||||
noMore.value = data.pageNumber >= data.totalPage;
|
||||
}
|
||||
loading.value = false;
|
||||
}).catch(err => {
|
||||
console.error('加载更多下载列表失败:', err);
|
||||
page.value--; // 恢复页码
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
api.getGandanfileMyShare({ page: page.value }).then(res => {
|
||||
console.log(res);
|
||||
if (res.code === 200 && res.data) {
|
||||
const data = res.data.list;
|
||||
// 追加新数据到列表
|
||||
const newList = data.list.map(item => ({
|
||||
name: item.title || '未知课件',
|
||||
time: item.create_date ? item.create_date.split(' ')[0] : '',
|
||||
status: '已分享', // 分享数据没有支付状态,统一显示为已分享
|
||||
uuid: item.uuid,
|
||||
order_id: item.order_id,
|
||||
type: item.type,
|
||||
providername: item.downloadername, // 分享数据中下载者名称对应提供者
|
||||
downloadername: item.downloadername
|
||||
}));
|
||||
|
||||
coursewareList.value = [...coursewareList.value, ...newList];
|
||||
|
||||
// 判断是否还有更多数据
|
||||
noMore.value = data.pageNumber >= data.totalPage;
|
||||
}
|
||||
loading.value = false;
|
||||
}).catch(err => {
|
||||
console.error('加载更多分享列表失败:', err);
|
||||
page.value--; // 恢复页码
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -240,6 +369,7 @@ const onLoadMore = () => {
|
||||
border-bottom:2rpx solid #eee;
|
||||
.item-content {
|
||||
.courseware-name,
|
||||
.courseware-provider,
|
||||
.courseware-time,
|
||||
.courseware-status {
|
||||
display: flex;
|
||||
@@ -269,10 +399,15 @@ const onLoadMore = () => {
|
||||
}
|
||||
}
|
||||
|
||||
.loading-more, .no-more {
|
||||
.loading-more, .no-more, .empty-state {
|
||||
text-align: center;
|
||||
padding: 30rpx;
|
||||
color: #999999;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 100rpx 30rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user