123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //#ifdef H5
- const BASEURL = ''
- //#endif
- //#ifndef H5
- const BASEURL = getApp().globalData.url
- //#endif
-
- function previepdf(url) {
- uni.showLoading({
- title: '加载中'
- });
- const manage = uni.getFileSystemManager();
- uni.downloadFile({
- url: BASEURL + url,
- success(res) {
- let path = res.tempFilePath;
- // #ifdef MP-WEIXIN
- var savePath = uni.env.USER_DATA_PATH + "/" + fileName
- if (res.statusCode == 200) {
- manage.saveFile({
- tempFilePath: res.tempFilePath,
- filePath: savePath+'.pdf',
- success:function(res){
- uni.openDocument({
- filePath: res.savedFilePath,
- fileType: "pdf",
- success: function (res) {
- uni.hideLoading()
- }
- })
- }
- })
- }
- // #endif
- // #ifndef MP-WEIXIN
- uni.openDocument({
- filePath: path,
- showMenu: true,
- success: function (res) {
- // console.log('打开文档成功');
- }
- });
- // #endif
-
- }
- });
- }
- module.exports = {
- previepdf
- };
|