/**
* 下载文件并预览
*/
downloadFile:function(e){
var index = e.currentTarget.dataset.index;//获取当前长按图片下标
let url=this.data.files[index]['path'];
wx.downloadFile({
url: url,
header: {},
success: function(res) {
var filePath = res.tempFilePath;
wx.openDocument({
filePath: filePath,
success: function (res){
console.log('打开文档成功')
},
fail: function (res){
console.log(res);
},
complete:function (res){
console.log(res);
}
})
},
fail: function(res) {
console.log('文件下载失败');
},
complete: function(res) {},
})
},
|