|
|
@@ -34,38 +34,40 @@
|
|
|
console.log('触底');
|
|
|
},
|
|
|
saveImg() {
|
|
|
- let that = this
|
|
|
- //获取授权列表,查看是否授权写入相册权限
|
|
|
- uni.getSetting({
|
|
|
- success(res) {
|
|
|
- if (!res.authSetting['scope.writePhotosAlbum']) {
|
|
|
- uni.authorize({
|
|
|
- scope: 'scope.writePhotosAlbum',
|
|
|
- success() {
|
|
|
- that.saveimgtoAlbum(that.codeImg)
|
|
|
+ uni.downloadFile({
|
|
|
+ url: this.codeImg,
|
|
|
+ success: downloadResult => {
|
|
|
+ if (downloadResult.statusCode === 200) {
|
|
|
+ // 下载成功,保存图片到系统相册
|
|
|
+ uni.saveImageToPhotosAlbum({
|
|
|
+ filePath: downloadResult.tempFilePath,
|
|
|
+ success: () => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '图片保存成功'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '图片保存失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
} else {
|
|
|
- that.saveimgtoAlbum(that.codeImg)
|
|
|
+ uni.showToast({
|
|
|
+ title: '图片下载失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- saveimgtoAlbum(imgurl) {
|
|
|
- let that = this
|
|
|
- uni.chooseImage({
|
|
|
- count: 1,
|
|
|
- sourceType: ['camera'],
|
|
|
- success: function(res) {
|
|
|
- uni.saveImageToPhotosAlbum({
|
|
|
- filePath: imgurl,
|
|
|
- success: function() {
|
|
|
- tools.success("保存成功")
|
|
|
- }
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '图片下载失败',
|
|
|
+ icon: 'none'
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|