Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • 判断用户是否已经授权

判断用户是否已经授权

//查看是否授权
         wx.getSetting({
           success: function(res) {
             if (res.authSetting['scope.userInfo']) {
               console.log("用户授权了");
               console.log(res);
                     wx.getUserInfo({
                         success: res => {
                             console.log("用户授权信息",res)
                         app.globalData.userInfo = res.userInfo
                         //业务代码
                         }
                     })
             } else {
               //用户没有授权
               console.log("用户没有授权");
             }
             console.log("res.authSetting",res.authSetting)
             if (res.authSetting['scope.userLocation']) {
                 console.log("用户已经授权地理位置");
               } else {
                 console.log("用户没有授权地理位置");
             }
         }
      });
 // 授权结束
Edit this page
最近更新: 2025/12/2 01:46
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人