Home > Article > WeChat Applet > Solution to authorized photo album in mini program (with code)
The content of this article is about the solution to authorized photo albums in the mini program (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Solutions to authorizing photo albums in mini programs:
1. First use wx.getSetting() to obtain the user's authorization. An authorization or authorization interface will pop up, where you need to decide whether to refuse. and allowed judgment.
2. If allowed, do the logic directly.
3. If rejected, you have to display the authorized button
<button type='primary' size='mini' open-type="openSetting" bindopensetting='handleSetting' > 去授权</button>;
4、在打开 handleSetting: function (e) { let that = this; // 对用户的设置进行判断,如果没有授权,即使用户返回到保存页面,显示的也是“去授权”按钮;同意授权之后才显示保存按钮 if (!e.detail.authSetting['scope.writePhotosAlbum']) { wx.showModal({ title: '警告', content: '若不打开授权,则无法将图片保存在相册中!', showCancel: false }) that.setData({ saveImgBtnHidden: false, openSettingBtnHidden: true }) } else { wx.showModal({ title: '提示', content: '您已授权,赶紧将图片保存在相册中吧!', showCancel: false }) that.setData({ saveImgBtnHidden: true, openSettingBtnHidden: false }) } },
Related recommendations:
How to clear the default styles of buttons and scroll bars in mini programs (code)
WeChat applet example code: pull up and load more implementation methods
The above is the detailed content of Solution to authorized photo album in mini program (with code). For more information, please follow other related articles on the PHP Chinese website!