diff --git a/api/train.js b/api/train.js index 6897c66..dfce1e9 100644 --- a/api/train.js +++ b/api/train.js @@ -59,3 +59,14 @@ export const bannerList = (query) => { }) } +// 记录列表 +export const recordList = (query) => { + return apiResquest({ + url: 'v1/record.list', + method: 'get', + query: query + }) +} + + + diff --git a/pages/home/home.vue b/pages/home/home.vue index 79a408f..bf87025 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -2,7 +2,8 @@ - + { this.swiperList = res.data }) @@ -184,20 +190,41 @@ url: '/pages/news/news-topic-cate?type=' + this.queryParams.type }) }, + + getFileType(url) { + // 从 URL 中提取文件名 + const fileName = url.split('/').pop(); + // 获取文件扩展名 + const fileExtension = fileName.split('.').pop().toLowerCase(); + + // 定义文件类型映射 + const fileTypes = { + 'doc': 'doc', + 'xls': 'xls', + 'ppt': 'ppt', + 'pdf': 'pdf', + 'docx': 'docx', + 'xlsx': 'xlsx', + 'pptx': 'pptx' + }; + // 返回对应的文件类型或 'unknown' + return fileTypes[fileExtension] || 'unknown'; + }, + getPdfInfo(item) { - // pdf文档 + var that = this uni.showLoading({ title: '加载文档中..' }) assetInfo({ id: item.asset_id - }).then(res => { + }).then(Response => { uni.downloadFile({ - url: res.data.pdf_url, + url: Response.data.pdf_url, success: function(res) { uni.openDocument({ filePath: res.tempFilePath, - fileType: 'pdf', + fileType: that.getFileType(Response.data.pdf_url), showMenu: true, success: function(res) { uni.hideLoading() @@ -217,15 +244,21 @@ goTopicDetail(item) { switch (this.queryParams.type) { case 1: + // 招聘 uni.navigateTo({ url: '/pages/home/detail?assets_id=' + item.asset_id }) break; case 2: + // 职业 + this.getPdfInfo(item) + break; + case 4: + // 创业 this.getPdfInfo(item) break; case 3: - // 课程 + // 适应 uni.navigateTo({ url: '/pages/news/course?assets_id=' + item.asset_id }) @@ -271,7 +304,7 @@ height: 180rpx; .left { - width: 80%; + width: 82%; display: flex; align-items: center; // border: solid 1px red; @@ -284,12 +317,12 @@ align-items: center; .images { - width: 65rpx; - height: 65rpx; + width: 60rpx; + height: 60rpx; } .text1 { - font-size: 28rpx; + font-size: 26rpx; color: #000000; margin-top: 10rpx; } @@ -297,14 +330,14 @@ } .right { - width: 20%; - // border:solid 1px blue; + width: 18%; display: flex; justify-content: center; .images1 { - width: 60rpx; - height: 60rpx; + width: 55rpx; + height: 55rpx; + padding-right: 10rpx; } } } diff --git a/pages/mine/history.vue b/pages/mine/history.vue index 3186de4..35e8278 100644 --- a/pages/mine/history.vue +++ b/pages/mine/history.vue @@ -35,7 +35,8 @@ import { groupList, assetList, - assetInfo + assetInfo, + recordList } from '@/api/train.js' export default { components: { @@ -59,17 +60,24 @@ // groupList: [], assetList: [], typeList: [{ - type: 1, - name: '招聘' + type: 3, + name: '适应' }, { type: 2, - name: '技能' + name: '职业' }, { - type: 3, - name: '课程' + type: 4, + name: '创业' + }, + + { + type: 1, + name: '招聘' } + + ], count: 0, status: 'loadmore', @@ -107,7 +115,7 @@ uni.showLoading({ title: '加载中...' }) - var res = await assetList(that.queryParams) + var res = await recordList(that.queryParams) uni.hideLoading() if (res.code == 0) { if (res.data.length < that.queryParams.limit) { @@ -125,20 +133,39 @@ uni.hideLoading() } }, + getFileType(url) { + // 从 URL 中提取文件名 + const fileName = url.split('/').pop(); + // 获取文件扩展名 + const fileExtension = fileName.split('.').pop().toLowerCase(); + + // 定义文件类型映射 + const fileTypes = { + 'doc': 'doc', + 'xls': 'xls', + 'ppt': 'ppt', + 'pdf': 'pdf', + 'docx': 'docx', + 'xlsx': 'xlsx', + 'pptx': 'pptx' + }; + // 返回对应的文件类型或 'unknown' + return fileTypes[fileExtension] || 'unknown'; + }, getPdfInfo(item) { - // pdf文档 + var that = this uni.showLoading({ title: '加载文档中..' }) assetInfo({ id: item.asset_id - }).then(res => { + }).then(Response => { uni.downloadFile({ - url: res.data.pdf_url, + url: Response.data.pdf_url, success: function(res) { uni.openDocument({ filePath: res.tempFilePath, - fileType: 'pdf', + fileType: that.getFileType(Response.data.pdf_url), showMenu: true, success: function(res) { uni.hideLoading() @@ -166,6 +193,10 @@ case 2: this.getPdfInfo(item) break; + case 4: + // 创业 + this.getPdfInfo(item) + break; case 3: // 课程 uni.navigateTo({ diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue index 1fcc921..16b971a 100644 --- a/pages/mine/mine.vue +++ b/pages/mine/mine.vue @@ -26,8 +26,7 @@ --> - - + @@ -88,17 +87,6 @@ icon: 'iconshezhi1', name: '修改资料', url: 'set' - }, - { - icon: 'iconshenhe', - name: '役士兵职业技能培训申请表', - url: 'file2' - - }, - { - icon: 'iconshenhe', - name: '退役士兵教育培训承训机构申请表', - url: 'file1' } ], userInfo: {}, @@ -111,7 +99,6 @@ }, onShow() { this.getUserInfo() - this.getFileGet() }, // 监听导航栏按钮点击 onNavigationBarButtonTap() { @@ -127,13 +114,7 @@ this.swiperList = res.data }) }, - getFileGet() { - fileGet().then(res => { - this.flieList = res.data - - }) - }, getUserInfo() { userInfo().then(res => { this.userInfo = res.data diff --git a/pages/news/news-topic-cate.vue b/pages/news/news-topic-cate.vue index 65d8bbc..3e524e0 100644 --- a/pages/news/news-topic-cate.vue +++ b/pages/news/news-topic-cate.vue @@ -2,7 +2,7 @@ - + @@ -118,20 +118,39 @@ uni.hideLoading() } }, + getFileType(url) { + // 从 URL 中提取文件名 + const fileName = url.split('/').pop(); + // 获取文件扩展名 + const fileExtension = fileName.split('.').pop().toLowerCase(); + + // 定义文件类型映射 + const fileTypes = { + 'doc': 'doc', + 'xls': 'xls', + 'ppt': 'ppt', + 'pdf': 'pdf', + 'docx': 'docx', + 'xlsx': 'xlsx', + 'pptx': 'pptx' + }; + // 返回对应的文件类型或 'unknown' + return fileTypes[fileExtension] || 'unknown'; + }, getPdfInfo(item) { - // pdf文档 + var that = this uni.showLoading({ title: '加载文档中..' }) assetInfo({ id: item.asset_id - }).then(res => { + }).then(Response => { uni.downloadFile({ - url: res.data.pdf_url, + url: Response.data.pdf_url, success: function(res) { uni.openDocument({ filePath: res.tempFilePath, - fileType: 'pdf', + fileType: that.getFileType(Response.data.pdf_url), showMenu: true, success: function(res) { uni.hideLoading() @@ -147,9 +166,9 @@ }); }) }, - + goTopicDetail(item) { - console.log(item,'item'); + console.log(item, 'item'); switch (item.type) { case 1: uni.navigateTo({ @@ -157,6 +176,11 @@ }) break; case 2: + // 职业 + this.getPdfInfo(item) + break; + case 4: + // 创业 this.getPdfInfo(item) break; case 3: diff --git a/static/img/demo/chuangye-select.png b/static/img/demo/chuangye-select.png new file mode 100644 index 0000000..b12d030 Binary files /dev/null and b/static/img/demo/chuangye-select.png differ diff --git a/static/img/demo/chuangye.png b/static/img/demo/chuangye.png new file mode 100644 index 0000000..a97206c Binary files /dev/null and b/static/img/demo/chuangye.png differ