小程序授权请求一般流程

 wx.saveImageToPhotosAlbum({

        // 保存图片

        filePath: this.data.sharePath,

        success: () => {

          wx.showToast({

            title: '保存成功'

          })

          setTimeout(() => {

            this.setData({

              visible: false

            })

            this.triggerEvent('close')

          }, 300)

        },

        fail: () => {

          wx.getSetting({

            success: res => {

              let authSetting = res.authSetting

              console.log(res)

              if (!authSetting['scope.writePhotosAlbum']) {

                wx.showModal({

                  title: '提示',

                  content: '您未开启保存图片到相册的权限,请点击确定去开启权限!',

                  success(res) {

                    if (res.confirm) {

                      wx.openSetting()

                    }

                  }

                })

              }

            }

          })

你可能感兴趣的:(小程序授权请求一般流程)