This commit is contained in:
parent
c54f049409
commit
4c261ce928
|
|
@ -277,22 +277,52 @@ function handleSaveQrcode() {
|
|||
uni.showToast({ title: '二维码未加载', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: qrcodeUrl.value,
|
||||
success: () => { uni.showToast({ title: '保存成功', icon: 'success' }) },
|
||||
fail: (err) => {
|
||||
if (err.errMsg.includes('auth deny')) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '需要您授权保存图片到相册',
|
||||
confirmText: '去设置',
|
||||
success: (res) => { if (res.confirm) uni.openSetting() }
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||
|
||||
/**
|
||||
* 保存图片到相册
|
||||
* 需要先将网络图片下载到本地临时路径,再调用保存接口
|
||||
*/
|
||||
function saveToAlbum(tempFilePath) {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: tempFilePath,
|
||||
success: () => { uni.showToast({ title: '保存成功', icon: 'success' }) },
|
||||
fail: (err) => {
|
||||
if (err.errMsg.includes('auth deny') || err.errMsg.includes('authorize')) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '需要您授权保存图片到相册',
|
||||
confirmText: '去设置',
|
||||
success: (res) => { if (res.confirm) uni.openSetting() }
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 网络图片需要先下载到本地
|
||||
if (qrcodeUrl.value.startsWith('http')) {
|
||||
uni.showLoading({ title: '保存中...' })
|
||||
uni.downloadFile({
|
||||
url: qrcodeUrl.value,
|
||||
success: (res) => {
|
||||
uni.hideLoading()
|
||||
if (res.statusCode === 200) {
|
||||
saveToAlbum(res.tempFilePath)
|
||||
} else {
|
||||
uni.showToast({ title: '下载图片失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '下载图片失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 本地路径直接保存
|
||||
saveToAlbum(qrcodeUrl.value)
|
||||
}
|
||||
}
|
||||
|
||||
function handleShowWithdraw() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user