From 32e229fec327f3d638f6baa591eeaf58df2bbe9d Mon Sep 17 00:00:00 2001 From: fengachen <373943794@qq.com> Date: Tue, 12 Oct 2021 15:19:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=BA=E5=B0=91=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/http/meetingApi.js | 14 ++++++++++ assets/js/preview.js | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 assets/js/http/meetingApi.js create mode 100644 assets/js/preview.js diff --git a/assets/js/http/meetingApi.js b/assets/js/http/meetingApi.js new file mode 100644 index 0000000..efc1df3 --- /dev/null +++ b/assets/js/http/meetingApi.js @@ -0,0 +1,14 @@ +import http from './http.js' +let URL_CONFIG = '/jero-boot/' +const MeetingApi = { + // 会议活动分页 + meetingList: (params) => http.get(`${URL_CONFIG}meeting/payMeeting/pageContract`, params), + // 会议活动详情 + meetingDetail: (params) => http.get(`${URL_CONFIG}meeting/payMeeting/queryById`, params), + // 文件id获取文件信息 + queryFileInfoById:(params) => http.get(`${URL_CONFIG}sys/oss/file/queryById`, params), + // 参会人信息 + queryPersongInfoById:(params) => http.get(`${URL_CONFIG}/meeting/payMeetingSituation/queryById`, params) +} + +export default MeetingApi \ No newline at end of file diff --git a/assets/js/preview.js b/assets/js/preview.js new file mode 100644 index 0000000..b87f942 --- /dev/null +++ b/assets/js/preview.js @@ -0,0 +1,52 @@ +/** + * 预览文件的方法 + * @param fileId 文件id + * @param fileName 文件名称 + */ + + // 文件下载的地址 后期上线需要修改地址 + + const downFileUrl = `http://localhost:3000/jero-boot/sys/common/download/` +// 预览 +export function previewFile(fileId,fileName) { + + // 目前没有在真机调试上试过 不知道要不要改前缀 + // console.log(that.data.pdfFilePath.replace("wxfile", 'http')); + // 文件下载的地址 + const url = downFileUrl + fileId + // 文件类型 目前是通过文件名称去截取 + const fileType = sliceFileTypeByFileName(fileName) + // const fileType = + wx.downloadFile({ + url: url, + success: function (res) { + wx.showToast({ + title: '正在打开', + icon: 'loading', + mask: true, + duration: 1000 + }) + const filePath = res.tempFilePath + wx.openDocument({ + filePath: filePath, + fileType: fileType, + success: function (res) { + console.log('打开文档成功') + wx.hideToast() + } + }) + }, + fail(err) { + console.log(err, '文件打开失败'); + wx.hideToast() + } + }) + } + + // 截取文件类型的方法 + function sliceFileTypeByFileName(fileName){ + // 获取 . 的索引 + let index = fileName.lastIndexOf('.') + // 截取文件类型 + return fileName.slice(index+1) + }