新用户进来小程序的时候 怎么没有授权弹窗了
发布于 5 年前 作者 jiewen 6303 次浏览 来自 问答

新用户第一次进来小程序   怎么没有授权弹窗了

wx.getSetting({

success: res => {

console.log(res.authSetting[‘scope.userInfo’])

if (res.authSetting[‘scope.userInfo’]) {

// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框

wx.getUserInfo({

success: res => {

// 可以将 res 发送给后台解码出 unionId

this.globalData.userInfo = res.userInfo

//console.log(res.userInfo);

// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回

// 所以此处加入 callback 以防止这种情况

if (this.userInfoReadyCallback) {

this.userInfoReadyCallback(res)

}

}

})

}else{

}

},

fail:res=>{

console.log(“fail”);

}

})

1 回复

wx.getUserInfo()自动弹出用户信息授权提示框的功能已经关掉了,现在需要用button(<button open-type=“getUserInfo”>登录</button>)去引导用户授权

而且只关闭了用户信息授权的自动弹出框功能,用户位置授权的没有关掉

回到顶部