收藏
回答

最新版的开发工具在授权拒绝后有bug?

框架类型 问题类型 操作系统 工具版本
小程序 Bug Windows 1.03.2009301
Page({


  /**
   * 页面的初始数据
   */
  data: {


  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options{


  },


  /**
   * 选择地址的wx 小程序原生方法wxwx.chooseAddress
   * 实际流程:
   * 1. 获取用户对小程序各类权限 wx.getSetting({})
   *  scope 的的授权状态 authSetting.scope.address
   * 2. 授权状态分析
   *  2.1 地址已授权(authSetting.scope.address = true),直接调用获取地址的原生方法
   *  2.2 地址从未经历过授权(authSetting.scope.address = undefined),直接调用获取地址的原生方法
   *  2.3 地址未授权 (authSetting.scope.address = false)
   *    此时需要让用户自行打开用户授权页面,设置授权状态后,重新获取地址
   * 
   */
  handleChooseAddress() {
    wx.getSetting({
      success: (result) => {
        console.log(result);
        const  scopeAddress = result.authSetting["scope.address"];
        if(scopeAddress===true || scopeAddress===undefined) {
          wx.chooseAddress({
            success: (result1) => {
              console.log(result1);
            },
            fail: (err) => {
              console.log(err);
            }
          });
        } else {
          wx.openSetting({
            success: (result2) => {
              wx.chooseAddress({
                success: (result3) => {
                  console.log(result3);
                }
              })
            }
          })
        }
      },
      fail: (err) => {
        console.log(err);
      }
    });
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {


  }
})



index.wxml

<view class="cart_delivery_address">
  <view class="dilivery_address_btn">
    <button type="primary" plain bindtap="handleChooseAddress">选择收货地址</button>
  </view>
</view>
<view class="cart_goods_list">
  购物车商品清单
</view>


<view class="cart_btm">
  购物车底部
</view>


console

log writeFile err writeFile:fail no such file or directory http://usr/miniprogramLog/log1
index.js:33 {errMsg: "getSetting:ok", authSetting: {…}}errMsg: "getSetting:ok"authSetting: {scope.address: true, scope.invoice: true, scope.invoiceTitle: true}__proto__: Object
index.js:41 {errMsg: "chooseAddress:fail auth deny"}
VM350 WAService.js:2 log writeFile err writeFile:fail no such file or directory http://usr/miniprogramLog/log1
index.js:33 {errMsg: "getSetting:ok", authSetting: {…}}
index.js:41 {errMsg: "chooseAddress:fail auth deny"}
index.js:33 {errMsg: "getSetting:ok", authSetting: {…}}
index.js:41 {errMsg: "chooseAddress:fail auth deny"}
index.js:33 {errMsg: "getSetting:ok", authSetting: {…}}
index.js:33 {errMsg: "getSetting:ok", authSetting: {…}}
index.js:41 {errMsg: "chooseAddress:fail auth deny"}
index.js:41 {errMsg: "chooseAddress:fail auth deny"}
index.js:33 {errMsg: "getSetting:ok", authSetting: {…}}
VM350 WAService.js:2 log writeFile err writeFile:fail no such file or directory http://usr/miniprogramLog/log1
index.js:41 {errMsg: "chooseAddress:fail auth deny"}


预期是在用户不授权后,如果二次点击,引导用户重新授权。

实际调试时,点击了清除缓存,console一直打印的是authSetting 有值,而且一直为true

导致无法走到else


不知道要通过什么方式清除掉缓存的authSetting,欢迎各位大佬指正


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

2 个回答

登录 后发表内容
问题标签