收藏
回答

h5不能用wx.login获取code来获取openid吗?要怎么获取openid?

  wx.ready(function () {
      wx.checkJsApi({
        jsApiList: ["requestFacialVerify"],
        success: function(res) {
          console.log("授权结果:", res);
          // 应该输出:{ checkResult: { requestFacialVerify: true }, errMsg: "checkJsApi:ok" }
        }
      });
      wx.getLocation({
          // type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
          success: function (res) {
              const response= JSON.parse((JSON.stringify(res)));
              that.latitude = response.latitude; // 纬度,浮点数,范围为90 ~ -90
              that.longitude = response.longitude; // 经度,浮点数,范围为180 ~ -180。
          }
      })
      wx.login({
        success: function (res) {
          alert('login执行成功')
          this.code = res.code
          console.log('code' + res.code)
         that.getWxCode2Session(res.code, appid)
        }
      })
    // that.doWxVerifyFace(appid)
    that.doWxFacialVerifyFace(this.verifyId)
  })
  wx.error(function (res) {
    that.$toast("config验证失败:" + JSON.stringify(res))
  })
},


最后一次编辑于  04-10
回答关注问题邀请回答
收藏

2 个回答

  • 智能回答 智能回答 本次回答由AI生成
    04-10
    有用
  • Hlxuan.
    Hlxuan.
    04-10

    目前jssdk没有wx.login这个接口哦。

    如果你有已完成微信认证的服务号,可以通过网页授权能力获取用户openid:https://developers.weixin.qq.com/doc/service/guide/h5/auth.html

    04-10
    有用
    回复
登录 后发表内容