时间:2019-04-29 来源:小程序工厂
wx.downloadFile({
url: e.currentTarget.dataset.pdf,
header: {},
success: function(res) {
var filePath = res.tempFilePath;
console.log(res);
if (res.statusCode == 404) {
wx.showToast({
title: '获取文件失败',
icon: 'success',
duration: 2000
})
} else {
wx.openDocument({
filePath: filePath,
fileType: 'pdf',
success: function(res) {
console.log(res);
wx.showToast({
title: "打开成功",
icon: 'success',
duration: 2000
})
},
fail: function(res) {
wx.showToast({
title: "打开失败",
icon: 'success',
duration: 2000
})
},
complete: function(res) {
console.log(res);
}
})
}
},
fail: function(res) {
console.log('文件下载失败');
},
complete: function(res) {},
})
fail(res){
console.log(res)
}
看看呢