wx.downloadFile下载文档链接后,临时文件后缀名变json?
预下载文档链接:https://tt.wo.cn/codeshop-web-zsc/api/common/oss/getBiFile?fileId=2020/08/04/7agkdiv2qaijrp6g45qe9l4sih.docx
文档路径:http://tmp/wxd09bd3b7e8615d34.o6zAJs1nxb9ingS3FdkyhKJfJIrw.Yhjzb0wXa7SPae30557a5d8d32ebfe0d43cf6783f695.json
console.log('预下载文档链接:' + file);
wx.downloadFile({
url: file,
success: function (res) {
const filePath = res.tempFilePath
console.log('文档路径:' + filePath);
wx.openDocument({
filePath: filePath,
showMenu: true,
fileType: fileType,
success: function (rs) {
console.log('打开文档成功')
},
fail: function (r) {
console.log('打开文档失败')
console.log(r)
}, complete: () => {
wx.hideLoading();
}
})
},
fail: function () {
wx.showToast({
title: '文件下载失败',
icon: 'none'
})
}, complete: () => {
// wx.hideLoading();
}
})