


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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools
