<thead id="rrjt3"></thead>
      <progress id="rrjt3"><dfn id="rrjt3"></dfn></progress>

      <em id="rrjt3"></em>

        <address id="rrjt3"><ins id="rrjt3"><dfn id="rrjt3"></dfn></ins></address>
          <i id="rrjt3"></i>

        小程序獲得openid實例

        時間:2019-03-25 20:52:21 類型:微信小程序
        字號:    
        小程序獲得openid實例
        App({
          onLaunch: function () {
            var _this = this;
            wx.login({
              //獲取code
              success: function (res) {
                //得到openid 開始
                wx.request({
                  url: 'https://api.weixin.qq.com/sns/jscode2session',
                  data: {
                    appid: _this.globalData.appid,
                    secret:_this.globalData.appsecret,
                    js_code:res.code,
                    grant_type:'authorization_code'
                  },
                  method:'GET',
                  header: {
                    'content-type': 'application/json'
                  },
                  success: function (res) {
                    console.log(res.data);
                    var openid = res.data.openid; //返回openid
                  }
                })
                //得到openid結束
              }
            })
            //用戶登陸結束
          },
          globalData: {
            appid:'wx99777c04115e0238',
            appsecret:'4c0f48c8003550b399aab023424sdf',
           
          }
        })
        黄网站免费