微信小程序保存图片到相册授权被拒绝后重新拉取授权
生活随笔
收集整理的這篇文章主要介紹了
微信小程序保存图片到相册授权被拒绝后重新拉取授权
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
saveimg: function() {var that = this;wx.showLoading({title: '保存中',})wx.downloadFile({url: that.data.haibaoimg,success: function(res) {var imgpath = res.tempFilePath;if (res.statusCode == 200) {wx.getSetting({success(res) {//第一次進(jìn)來res.authSetting['scope.writePhotosAlbum']為undefined if (res.authSetting['scope.writePhotosAlbum'] != undefined && res.authSetting['scope.writePhotosAlbum'] == false) {//顯示自定義彈框,第一次進(jìn)來不顯示自定義that.setData({userauth: true});wx.hideLoading();} else {wx.saveImageToPhotosAlbum({filePath: imgpath,success: function(res) {wx.hideLoading();wx.showToast({title: '保存成功!'})},fail: function(res) {wx.hideLoading();wx.showToast({title: '保存失敗!'})}})}}})}}})},
自定義彈框:
<view class="userauth" wx:if="{{userauth}}"><view class="auth_content"><view class="authtitle">提示</view><view class="authtext">允許保存圖片或視頻到你的相冊(cè)?</view><view class="authfooter"><view bindtap="closeauth">取消</view><view>/*利用button調(diào)用設(shè)置*/<button plain="{{true}}" hover-class="none" open-type='openSetting' bindopensetting="getseetting">確定</button></view></view></view></view>監(jiān)聽打開設(shè)置用戶是否打開了授權(quán)
getseetting: function(res) {if (res.detail.authSetting['scope.writePhotosAlbum'] == true) {this.saveimg();} else {wx.showToast({title: '保存到相冊(cè)授權(quán)未打開!',icon: 'none'})}this.setData({userauth: false});},?
總結(jié)
以上是生活随笔為你收集整理的微信小程序保存图片到相册授权被拒绝后重新拉取授权的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: uniapp 修改全局字体
- 下一篇: java助记词_JAVA生成BTC地址以