微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

微信小程序 下载文件

 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,1)">自定义文件地址
10 success:  (res) {
11 var filePath = res.filePath;
12 wx.opendocument({ 打开
13 showMenu: true,14 filePath: filePath,1)">15 success:  (res) {}
16 });
17 }
18 })
19 },1)">20 //
21 getFileType:  (filePath) {
22 var startIndex = filePath.lastIndexOf(".");
23 if (startIndex != -1)
24 return filePath.substring(startIndex + 125 else return ""26 },

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐