From de22dd70ffdef60b6b59705214cfc02ebb858900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=B6=9B?= <1909118034@qq.com> Date: Wed, 30 Oct 2024 23:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/train.js | 11 ++++ pages/home/home.vue | 89 +++++++++++++++++++--------- pages/mine/history.vue | 53 +++++++++++++---- pages/mine/mine.vue | 21 +------ pages/news/news-topic-cate.vue | 38 +++++++++--- static/img/demo/chuangye-select.png | Bin 0 -> 702 bytes static/img/demo/chuangye.png | Bin 0 -> 718 bytes 7 files changed, 146 insertions(+), 66 deletions(-) create mode 100644 static/img/demo/chuangye-select.png create mode 100644 static/img/demo/chuangye.png 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 0000000000000000000000000000000000000000..b12d03038aebfb7d15c44bb28f39c97f1cc89eda GIT binary patch literal 702 zcmV;v0zv(WP)Px%cu7P-RA@u(THAHPFbus86J&zIB!x|204N(!HlQ#7bP`~arW0g>#zlExCm}R) ztkY8(f7`O|m14c3&}A*-ArefX@eGAALsSHf2nuIx!&k<++E(R!co~n8;OKnb9E|oP*x|7BUyKus>0$+i`eH0FO3um0m z8uu0e0Ja;s0MMx-J^^&F>OThH;IEA?#v2Cje|e5jfBT5FnK$vbO+>E`iOx1q4WC ziR>-FqDx@&V_M)ZRb(X#beK;GI7d5?RyUE-X)~*J95%PR)zhv@Gg{@d0s3Wtdhngb z{+?897E?~=(}`v=AFzkbB!K_xfVB2H{h7oJI`X=~jF>WXH1@C0#iW(v$-ho#=vaBo k>i+u-PX+$&#@}Px%h)G02RA@u(THR5@FbuZpL4ZksO~?>+uTRjYUfm%mlMp5$>`|XVzBni*fl9HD zzvL}3*^gi9AS&hzJaTM~&7@GUtiaDr3xnDMN_}SZkk^QV2kK?>AEI?RL960Jv>IH^!KY z;smU<_iz4tg9ib?^>Vr7YQBfjT8pw!rbroV3s3^a820`l4O?sRTf!hv8)L3HR$v1l z?sG84RGh=c))E42HhQKA$Z#<^)e=CFMtj1jG@b6v)ryChlG%fmoRR zcmcS$lA1Wpkeg8JwtT?AkH^t6T5Fw_+z2Jq=Mqd>Ypg6oizaz0=iF$!hTdCPr9@J8hclgX7x8kz zB{6aj`LZSxhtZ_;&T@B1m2yh6OiTa~w_3aP-oHp&iqulAJZuzWr@KC-(>I9#*G)>S zp9z%EDo5sQ0gkpxteq`TLaQ8^vjsTXDzWy@THrU`$leEyQ|418+~X9Pw3`TNvs5x{ zKIPC{Ytm*kwACPvIk5*nY3!d1pZZ}JQ9Vm?-Cr90&Bi