1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| wx.downloadFile({ url: "https://xxxxxxx/test.pdf", responseType: "arraybuffer", success: res => { console.log("success", res); const manage = wx.getFileSystemManager(); if (res.statusCode === 200) { let path = wx.env.USER_DATA_PATH + "/test.pdf"; console.log("path",path) manage.saveFile({ tempFilePath: res.tempFilePath, filePath: path, success: function(res) { } }); wx.openDocument({ filePath: path, success: function(res) { console.log('打开文档成功') }, fail: function() { console.log('打开失败'); } }) } }, fail: e => { console.log("error", e); wx.showToast({ title: 'error', }) } });
|