微信小程序授权与授权设置面板

1 其他授权与授权设置面板

https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html

在wxml中

<button      bind:tap="onAuthLocation">授权位置</button>

在 app.json中

{

        "pages": [     

                "pages/index/index",

                   "pages/logs/logs",

                     "pages/movie/movie",

                  "pages/about/about"

           ],

"window": {

                      "backgroundTextStyle": "light",

                       "navigationBarBackgroundColor": "#fff",

                    "navigationBarTitleText": "WeChat",

                        "navigationBarTextStyle": "black",     

                       "backgroundColor": "#ff00ff",

                     "enablePullDownRefresh": true 

         }, 

       "tabBar": {

                "list": [

                                {

                                     "text": "首页",

                               "pagePath": "pages/index/index",

                                   "selectedIconPath": "common/pj.png",

                                  "iconPath": "common/cake.png"

                          },

                         {         

                      "text": "日志",

                        "pagePath": "pages/logs/logs",

                               "iconPath": "common/juli.png",

                         "selectedIconPath": "common/sng.png"

                       }

                    ],

                           "color": "#707070",

                    "selectedColor": "#1296db"

                 },

                 "permission": {

                         "scope.userLocation": {

                            "desc": "你的位置信息将用于小程序位置接口的效果展示"

                            }

                      }

         }

 

在wxjs中

onAuthLocation:function(){

    wx.authorize({

          scope:"scope.userLocation",

            success:msg=>{         

                    console.log(msg,"location succ")

       },

         fail:e=>{

                    console.log(e,"location fail")

         }

    })

}

scope.userLocation   获取用户当前的定位信息

scope.userLocation   地理位置

scope.address  通讯地址

scope.werun     微信运动步数

scope.record     录音功能

scope.writePhotosAlbum   保存到相册

 scope.camera   获取用户的照相权限

*******************************************************************************************************************************

获取定位信息

在wxml中

<button bind:tap="onGetLocation">授权位置位置</button>

在wxjs中

     onGetLocation:function(){

              wx.authorize({

                     scope:"scope.userLocation",

                  success:msg=>{//成功获取到定位权限

                                 console.log(msg,"scope.userLocation succ")

                               wx.getLocation({       //获取定位信息

                                          success:function(info){

                                            console.log(info,"info")

                                       },

                                   fail:function(e){          

                                         console.log(e,"e")

                                 }

                     })

          },

         fail:e=>{

                 console.log(e,"scope.userLocation fail")

        }

     })

}

****************************************************************************************

获取授权设置信息

  1 在wxml里面

<button bind:tap="onGetSetting">获取授权信息</button>

2 在wxjs里面  获取用户配置信息  是否有开启定位权限,  个人信息权限

onGetSetting:function(){

         wx.getSetting({

                 success:msg=>{          

                         console.log(msg,"succ")

                    console.log(msg.authSetting,"succ")

            },

           fail:e=>{

                             console.log(e,"fail")

                               }

              })

}

***************************************************************************************************

手动设置,必须有某个权限,用户又不允许的情况下,

1wxml里面

<button bind:tap="onGoToSetting">去到设置页面</button>

2 wxjs里面  只能获取已经请求过的设置

onGoToSetting:function(){

         wx.openSetting({

                       success:msg=>{

                               console.log(msg,"设置完成")          

                        },

                   })

}

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值