search
HomeWeChat AppletMini Program DevelopmentSolution 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=&#39;primary&#39;  size=&#39;mini&#39;  open-type="openSetting"   bindopensetting=&#39;handleSetting&#39;   >
去授权</button>;
4、在打开
handleSetting: function (e) {
    let that = this;    // 对用户的设置进行判断,如果没有授权,即使用户返回到保存页面,显示的也是“去授权”按钮;同意授权之后才显示保存按钮
    if (!e.detail.authSetting[&#39;scope.writePhotosAlbum&#39;]) {
      wx.showModal({
        title: &#39;警告&#39;,
        content: &#39;若不打开授权,则无法将图片保存在相册中!&#39;,
        showCancel: false
      })
      that.setData({
        saveImgBtnHidden: false,
        openSettingBtnHidden: true
      })
    } else {
      wx.showModal({
        title: &#39;提示&#39;,
        content: &#39;您已授权,赶紧将图片保存在相册中吧!&#39;,
        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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

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

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools