收藏
回答

麦克风首次授权弹出两次

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.authorize 微信iOS客户端 8.0.24 2.25.1

 let that = this

    let options = { scope: 'scope.record', content: '请前往设置页打开麦克风' }

    return new Promise((resolve, reject) => {

      wx.getSetting({

        success: function (res) {

          let auth = res.authSetting['scope.scope']

          console.log(auth);

          if (auth === true{  //已授权

            that.start()

          } else if (auth === undefined{   // 首次授权

            wx.authorize({

              scope: options.scope,

              success() {

                resolve(true)

              },

              fail(res) {

              }

            })

          } else if (!res.authSetting['scope.record']) { //麦克风再次授权

            console.log(169);

            wx.showModal({

              title: '提示',

              content: '您未授权录音功能,是否授权?',

              showCancel: true,

              success: (res) => {

                if (res.confirm{ //确认

                  wx.openSetting({

                    success: (setRes) => {

                      if (settingRes.authSetting[options.scope]) {

                        resolve(true)

                      }

                    },

                    fail: (setRes) => {

                      console.log(setRes);

                    }

                  })

                } else if (res.cancel{ //取消

                  wx.showModal({

                    title: '提示',

                    content: '授权失败',

                    showCancel: false,

                  })

                }

              }

            })

          }

        }

      })

    })


回答关注问题邀请回答
收藏

1 个回答

  • 小卷
    小卷
    2022-08-26

    已解决

    2022-08-26
    有用
    回复 2
    • 🇨🇳番茄西红柿
      🇨🇳番茄西红柿
      2023-11-09
      请问怎么解决的
      2023-11-09
      回复
    • 天蝎座
      天蝎座
      03-04
      同求怎么解决的
      03-04
      回复
登录 后发表内容