feat(ship): 修改发货单据下载与分享逻辑
- 将保存到相册改为下载文件并打开文档预览 - 增加分享时的文件名设置 - 注释掉原有的文件系统保存逻辑
This commit is contained in:
parent
835cc21315
commit
0ba8ef0a83
@ -1269,32 +1269,47 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
|
|
||||||
if (data && data.path) {
|
if (data && data.path) {
|
||||||
setShipDocument(data.path);
|
setShipDocument(data.path);
|
||||||
// 保存到系统相册
|
// 下载文件
|
||||||
Taro.downloadFile({
|
Taro.downloadFile({
|
||||||
url: data.path,
|
url: data.path,
|
||||||
}).then((downloadRes) => {
|
}).then((downloadRes) => {
|
||||||
if (downloadRes.tempFilePath) {
|
if (downloadRes.tempFilePath) {
|
||||||
Taro.saveImageToPhotosAlbum({
|
Taro.openDocument({
|
||||||
filePath: downloadRes.tempFilePath,
|
filePath: downloadRes.tempFilePath,
|
||||||
complete: (res) => {
|
showMenu: true,
|
||||||
console.log("saveImageToPhotosAlbum", res);
|
success: function () {
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "发货单据已保存到相册,您可以将生成的PDF发送给好友",
|
title: "发货单据已下载成功,您可以将生成的PDF发送给好友",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
// Taro.getFileSystemManager().mkdir({
|
||||||
console.log("e", e);
|
// dirPath: `${Taro.env.USER_DATA_PATH}/${shipOrderVO?.dealerName}/发货单据`,
|
||||||
Taro.showToast({
|
// recursive: true,
|
||||||
title: "保存失败",
|
// });
|
||||||
icon: "none",
|
//
|
||||||
duration: 3000,
|
// // 保存到文件系统
|
||||||
});
|
// Taro.getFileSystemManager().saveFile({
|
||||||
});
|
// tempFilePath: downloadRes.tempFilePath,
|
||||||
|
// filePath: `${Taro.env.USER_DATA_PATH}/${shipOrderVO?.dealerName}/发货单据/${shipOrderVO?.vehicleNo}_${shipOrderVO?.dealerName}_发货单据_${shipOrderVO?.orderSn}.pdf`,
|
||||||
|
// success: function () {
|
||||||
|
// Taro.showToast({
|
||||||
|
// title: "发货单据已保存到本地,您可以将生成的PDF发送给好友",
|
||||||
|
// icon: "none",
|
||||||
|
// duration: 3000,
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// fail: function (err) {
|
||||||
|
// console.log("保存失败", err);
|
||||||
|
// Taro.showToast({
|
||||||
|
// title: "保存失败",
|
||||||
|
// icon: "none",
|
||||||
|
// duration: 3000,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1426,6 +1441,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
// 下载完成后转发
|
// 下载完成后转发
|
||||||
Taro.shareFileMessage({
|
Taro.shareFileMessage({
|
||||||
filePath: downloadRes.tempFilePath,
|
filePath: downloadRes.tempFilePath,
|
||||||
|
fileName: `${shipOrderVO?.vehicleNo}_${shipOrderVO?.dealerName}_发货单据_${shipOrderVO?.orderSn}.pdf`,
|
||||||
complete: (res) => {
|
complete: (res) => {
|
||||||
console.log("complete", res);
|
console.log("complete", res);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user