uni.downloadFile({
url: 'https://baomi-pub-1306020494.cos.ap-beijing.myqcloud.com/shouQuanWeiTuoShu.docx', // 仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
// 分享文件
wx.shareFileMessage({
filePath: res.tempFilePath,
fileName: '授权委托书.docx',
success () {
that.$toast('文件下载成功')
},
fail: console.error
})
// 下载图片到相册
// uni.getSetting({
// success: (set) => {
// const auth = set.authSetting['scope.writePhotosAlbum']
// if (auth === false) { // 已申请授权,但用户已拒绝
// uni.showModal({
// title: '授权提示',
// content: '请前往设置页打开保存图片到相册权限',
// showCancel: false
// })
// } else if (!auth) { // 未申请授权,唤起授权
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
// success: function () {
// uni.saveImageToPhotosAlbum({ // 保存图片到系统相册。
// filePath: res.tempFilePath,
// success: function (red) {
// that.$toast('文件已保存到相册')
// }
// })
// }
// })
// } else {
// uni.saveImageToPhotosAlbum({ // 保存图片到系统相册。
// filePath: res.tempFilePath,
// success: function (red) {
// that.$toast('文件已保存到相册')
// }
// })
// }
// }
// })
}
}
小程序分享好友文件下载图片到相册
最新推荐文章于 2022-04-29 15:05:47 发布