export async function saveVideo(url: string) {
showLoading("保存中");
let httpsUrl = url.replace("http:", "https:");
getAuthorize()
.then(() => {
const data = Date.now();
let filePath = uni.env.USER_DATA_PATH + "/" + "video_" + data + ".mp4";
uni
.downloadFile({ url: httpsUrl, filePath })
.then(() => {
uni.saveVideoToPhotosAlbum({
filePath,
success: () => {
showToast("保存成功", "success");
},
fail: () => {
showToast("保存视频失败", "none");
}
});
})
.catch((err) => {
console.log("视频下载失败信息", err);
showToast("下载视频资源失败", "none");
});
})
.catch(() => {
uni.showModal({
title: "提示",
content: "获取权限失败,将无法保存到相册",
showCancel: false
});
});
}