授权相册失效
发布于 5 年前 作者 maoxia 11581 次浏览 来自 问答

<view class=‘authorize’ wx:if="{{isShowToast}}" catchtap=‘hiddenAuthorization’>

<view class=‘authorize-frame’>

<view class=“cell-title”>温馨提示</view>

<view class=“cell-content”>下载图片保存到相册,需要允许访问相册,请去授权完成访问</view>

<button open-type=“openSetting” type=‘warn’ bindopensetting=“handleSetting” class=‘btn’>去授权</button>

</view>

</view>

//下载套图按钮

she_download(e) {

console.log(e)

var that = this

that.__wxSetting()

},

//判断是否授权,已授权执行下载事件,未授权弹出授权弹框

__wxSetting() {

let that = this

// 检测设置中是否允许保存到相册中去

wx.getSetting({

success(res) {

console.log(res)

// 第一,直接调取保存,系统会自动调取授权

if (!res.authSetting[‘scope.writePhotosAlbum’]) { // 不授权

that.setData({

isShowToast: true

})

} else { // 授权

that.__saveImage()

}

}

})

},

//授权按钮

handleSetting(event) {

let that = this

// 对用户的设置进行判断,如果没有授权,显示的也是“去授权”按钮;

that.setData({

isShowToast: false

})

if (!event.detail.authSetting[‘scope.writePhotosAlbum’]) {

wx.showModal({

title: ‘温馨提示’,

content: ‘若不打开授权,则无法将图片保存在相册中’,

showCancel: false

})

} else {

wx.showToast({

icon: ‘success’,

title: ‘授权成功’,

success(res) {

that.__saveImage()

}

})

}

},

//下载图片跟保存到相册

__saveImage() {

wx.showLoading({

title: ‘下载中…’,

});

}

考虑到wx.authorize点击拒绝的时候授权不在提示弹框,自写一个弹框,点击授权button 没有相册授权信息?这是什么原因造成的?

2 回复

我也是差不多的问题 到了手机授权系统页面 什么都没有 奇怪

1,我也遇到同样的问题。

<button open-type="openSetting" [@tap](/user/tap)="authorize">重新授权</button>


authorize内方法


wx.getSetting({

  success(res) {

   if (!res.authSetting['scope.writePhotosAlbum']) { // 未授权
    wx.openSetting({
     success(ress) {
     if (ress.authSetting['scope.writePhotosAlbum']) { // 拉取授权
         
     }
     },

     fail(err) {


     }
    })
    }
}
})

2,拉取授权后出现下面截图,没有相册选项。其他机型正常,目前只有“华为 荣耀 note10”才会有此情况。

3,下面截图拉取授权正常情况。

回到顶部