1 //下载发票图片 2 downLoadPic: function (e) { 3 var that = this; 4 console.log(e); 5 var types = that.getFileType(e); 6 console.log(types); 7 wx.downloadFile({ //下载 8 url: e, //服务器上的pdf地址 9 filePath: wx.env.USER_DATA_PATH + "/invoice" + "." + types, //自定义文件地址 10 success: function (res) { 11 var filePath = res.filePath; 12 wx.openDocument({ //打开 13 showMenu: true, 14 filePath: filePath, 15 success: function (res) {} 16 }); 17 } 18 }) 19 }, 20 // 21 getFileType: function (filePath) { 22 var startIndex = filePath.lastIndexOf("."); 23 if (startIndex != -1) 24 return filePath.substring(startIndex + 1, filePath.length).toLowerCase(); 25 else return ""; 26 },
微信小程序 下载文件
内容版权声明:除非注明,否则皆为本站原创文章。