/** * 检查授权 */ checkWerunAuthorize:function(){ let that = this; wx.getSetting({ success(res) { if (!res.authSetting[‘scope.werun‘]) { wx.authorize({ scope: ‘scope.werun‘, success() { // 用户已经同意小程序使用功能 that.getWeRunData(); }, fail: res => { console.log(res); console.log("当初用户拒绝,再次发起授权") wx.showModal({ title: ‘提示‘, content: ‘需要您授权获取您的微信步数‘, showCancel: false, success: modalSuccess => { wx.openSetting({ success(settingdata) { if (settingdata.authSetting[‘scope.werun‘]) { wx.showModal({ title: ‘提示‘, content: ‘获取权限成功,再次点击获取‘, showCancel: false, }) } else { wx.showModal({ title: ‘提示‘, content: ‘获取权限失败,将无法获取您的微信步数‘, showCancel: false, }) } }, fail(failData) { console.log("failData", failData) }, complete(finishData) { console.log("finishData", finishData) } }) } }) } }) }else{ console.log(5); that.getWeRunData(); //已经获得权限可以,进行相关操作 } } }); }