From 482655a819dfb37014ee586bca00ef949681ea06 Mon Sep 17 00:00:00 2001 From: LLL <15374889135@163.com> Date: Sun, 18 May 2025 19:02:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/coach/my/teaching_management.vue | 95 ++++++++++++++++---- pages/coach/my/teaching_management_info.vue | 96 +++++++++++++++++++-- 2 files changed, 168 insertions(+), 23 deletions(-) diff --git a/pages/coach/my/teaching_management.vue b/pages/coach/my/teaching_management.vue index 9eed149..f8aa8bb 100644 --- a/pages/coach/my/teaching_management.vue +++ b/pages/coach/my/teaching_management.vue @@ -1,12 +1,17 @@ @@ -16,6 +21,7 @@ data() { return { arrayList: [], + tabsList: [], tableTypeName: { '1': "课程教学大纲", '2': "跳绳教案库", @@ -46,27 +52,75 @@ '27': "互动游戏", '28': "套圈游戏", '29': "鼓励方式" - } + }, + tabsListArr: [], + searchArr: { + table_type: undefined, + page: 1, + limit: 10 + }, + loading: false, + noMoreData: false, + initId: undefined } }, onLoad() { - this.init() + this.getTabs() }, methods: { - init() { - apiRoute.teachingResearchList().then(res => { + getTabs() { + this.tabsListArr = [] + this.tabsList = [] + apiRoute.teachingResearchLookType().then(res => { if (res.code == 1) { - this.arrayList = res.data.data + res.data.forEach(item => { + let arr = { + value: item, + lebal: this.tableTypeName[item] + } + this.tabsListArr.push(arr) + this.tabsList.push(this.tableTypeName[item]) + }) + if (this.tabsListArr.length > 0) { + this.initId = this.tabsListArr[0].value + this.init() + } } }) }, + change(e) { + const item = this.tabsListArr.find(item => item.lebal == e.name); + const id = item ? item.value : 0 + this.initId = id + this.arrayList = [] + this.searchArr.page = 1 + this.init() + }, getTableType(text) { return this.tableTypeName[text] }, info(id) { console.log(id) uni.navigateTo({ - url: '/pages/coach/my/teaching_management_info?id=' + id + url: '/pages/coach/my/teaching_management_info?id=' + id + }) + }, + onReachBottom() { + if (this.noMoreData || this.loading) return; + this.searchArr.page += 1 + this.init(); + }, + init(id) { + this.searchArr.table_type = this.initId + apiRoute.teachingResearchList(this.searchArr).then(res => { + this.loading = true + if (res.code == 1) { + this.arrayList.push(...res.data.data) + if(res.last_page <= this.searchArr.page){ + this.noMoreData = true; + } + this.loading = false + } }) } } @@ -74,24 +128,29 @@ + \ No newline at end of file diff --git a/pages/coach/my/teaching_management_info.vue b/pages/coach/my/teaching_management_info.vue index a236bc5..171cd05 100644 --- a/pages/coach/my/teaching_management_info.vue +++ b/pages/coach/my/teaching_management_info.vue @@ -6,6 +6,23 @@ {{arrayInfo.update_time}} + + + + + + + + + + + 素材文件 + + @@ -16,7 +33,7 @@ data() { return { articleId: undefined, - arrayInfo: [] + arrayInfo: [], } }, onLoad(options) { @@ -32,19 +49,73 @@ } }) }, + clickPreviewImage(url) { + uni.previewImage({ + urls: [url], // 支持多张图预览 + current: url, // 当前显示的图片链接 + success: () => { + console.log('预览成功'); + }, + fail: (err) => { + console.error('预览失败', err); + } + }); + }, + async previewFile(url) { + try { + // 1. 下载文件到本地 + const { + tempFilePath + } = await this.downloadFile(url); + + // 2. 打开文件 + await uni.openDocument({ + filePath: tempFilePath, + showMenu: true, + success: () => { + console.log('打开文档成功'); + } + }); + } catch (err) { + uni.showToast({ + title: '预览失败', + icon: 'none' + }); + console.error('预览失败:', err); + } + }, + + downloadFile(url) { + return new Promise((resolve, reject) => { + uni.downloadFile({ + url, + success: (res) => { + if (res.statusCode === 200) { + resolve(res); + } else { + reject(new Error('下载失败')); + } + }, + fail: (err) => { + reject(err); + } + }); + }); + } } } + + .url_style { + margin-top: 20px; + text-align: center; + } + + .url_image_style { + padding: 20rpx; + text-align: center; + } + + .url_file_style{ + padding: 20rpx; + } + \ No newline at end of file