tapDownLoadAttachment: function (e) {
var sFilePath = e.currentTarget.dataset.filepath;
console.log(“下载附件路径” + sFilePath);
utilJs.openLoadingToast();
wx.downloadFile({
url: sFilePath, //仅为示例,并非真实的资源
success: function (res) {
console.log(‘downloadFile–success下载附件成功!’ + JSON.stringify(res));
var filePath = res.tempFilePath;
if (filePath != null) {
wx.openDocument({
filePath: filePath,
success: function (res) {
utilJs.closeLoadingToast();
console.log(‘openDocument–success打开附件成功!’ + JSON.stringify(res));
},
complete: function (res) {
console.log(‘openDocument–complete打开附件完成!’ + JSON.stringify(res));
wx.saveFile({
tempFilePath: filePath,
success: function (res) {
var savedFilePath = res.savedFilePath;
utilJs.openDialog(‘success’, ‘附件保存成功!’);
console.log(‘saveFile-success附件保存成功!’ + JSON.stringify(res));
},
fail: function (res) {
console.log(‘saveFile-fail附件保存失败’ + JSON.stringify(res));
}
});
},
fail: function (res) {
console.log(‘openDocument-fail打开附件失败’ + JSON.stringify(res));
}
});
} else {
utilJs.openDialog(‘warning’, ‘附件获取失败!’);
}
},
fail: function (res) {
console.log(‘downloadFile-fail下载附件失败’ + JSON.stringify(res));
}
})