Skip to content
This repository has been archived by the owner on Sep 17, 2020. It is now read-only.

Latest commit

 

History

History

authorize

授权

动态授权

  • .json中引用
{
  "usingComponents": {
    "dynamic":"/components/authorize/dynamic"
  }
}
  • .wxml页面中引用
<!-- bind:组件中的事件名称:组件之间通信从父级传递数据 -->
<dynamic id="authorize" app-name="我涂" bind:bindGetAuthorize="bindGetAuthorize"></dynamic>
  • onReadyjs函数中加入
//获得authorize组件
this.authorize = this.selectComponent("#authorize");
// userInfo,userLocation,userLocationBackground,address
// invoiceTitle,invoice,werun,record,writePhotosAlbum,camera
this.authorize.isAuthorize('record')
  • 在js中加入函数
bindGetAuthorize:function(res){
  console.log(res)
}

用户信息

  • .json中引用
{
  "usingComponents": {
    "userinfo": "/components/authorize/userinfo"
  }
}
  • .wxml页面中引用
<!-- bind:组件中的事件名称:组件之间通信从父级传递数据 -->
<userinfo id="userinfo" bind:bindGetUserInfo="bindGetUserInfo"></userinfo>
  • onReadyjs函数中加入
//获得userinfo组件
this.userinfo = this.selectComponent("#userinfo");
let that = this;
// 查看是否授权
wx.getSetting({
    success: function(res) {
    if (!res.authSetting['scope.userInfo']) {
        that.userinfo.showDialog();
    }
    }
})
  • 在js中加入函数
bindGetUserInfo:function(res){
  console.log(res)
}