downloadfill(ind) {
var wxflie = uni.getFileSystemManager()
this.$api.request({
data: {
method: "userform.downloadplan",
token: this.$db.get('token'),
form_id:ind,
client:2,
type: 4,
customer_id: this.routeID,
},
success: res => {
if (res.status) {
uni.downloadFile({
url: res.data.url, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
wxflie.saveFile({
tempFilePath: res.tempFilePath,
filePath:`${wx.env.USER_DATA_PATH}/a.pdf`,
success: function (res1) {
console.log(res1,888888888)
uni.openDocument({
filePath:res1.savedFilePath,
showMenu:true,
success: function (res) {
console.log('打开文档成功');
}
})
}
});
}
}
});
} else {
uni.showToast({
title: res.msg,
duration: 2000,
icon: 'none',
});
}
}
});
},
原理: 下载文件 uni.downloadFile --> 打开文件 uni.openDocument ----->在查看文件页面保存文件