return new Promise(function(resolve, reject) {
wx.downloadFile({
url: conf.url + `${url}${data ? “?” + JSON.stringify(data) : “”}`,
header: {
‘Cookie’: ‘JSESSIONID=’ + getApp().globalData.jsessionid
},
success: function(res) {
if (res.statusCode === 200) {
console.log(res);
wx.saveFile({
tempFilePath: res.tempFilePath,
success(res){
console.log(res);
wx.openDocument({
filePath: res.savedFilePath,
success: function (res) {
console.log(‘打开文档成功’)
},
fail(res){
console.log(res);
}
})
},
fail(res){
console.log(“下载失败”)
}
})
resolve(res)
} else {
reject(res)
}
},
fail: function(res) {
reject(res);
},
complete: function(res) {
if (complete) complete(res)
},
})
})