安卓手机最新版本的微信,小程序wx.login登录失败
发布于 6 年前 作者 xiongxiuying 2314 次浏览 来自 问答

我发布的食为天餐饮小程序,之前一直是通过苹果手机来测试的,苹果手机一点问题没有。但是安卓手机经朋友和亲人一测试发现有问题。

  1. 凡是用安卓手机扫描微信小程序的二维码,微信显示的页面就是获取不到用户信息。页面出现假死的现象。

  2. 苹果手机最新版本的微信扫描二维码,就没有问题,能够成功获取用户信息

  3. 我通过在苹果测试成功的用户账号,登录安卓手机的微信之后,再扫描二维码,也出现假死的问题。 这个排除了账号的问题(开发者账号,检验者账号或关注账号等因素)

凡是出现假死的情况,我们这边后台都没有请求过来,后台服务器均没有日志。

出问题页面的js代码如下:

获取用户信息代码:

getUserInfo: function (cb, force) {

    var that = this

    if (this.globalData.userInfo && !force) {

      typeof cb == “function” && cb(this.globalData.userInfo)

    } else {

      //调用登录接口

      …

      wx.login({

        fail: function (res) {

          console.error(res)

        },

        complete: function (res) {

          //console.log(res)

        },

        success: function (res) {

          //console.log(res)

          if (res.code) {

            //发起网络请求

            wx.request({

              url: http_host + ‘/wxapp/swt/wx-login.do’,

              data: { code: res.code },

              method: ‘POST’,

              success: function (res2) {

                console.log(res2)

                if (res2.data.code == 0) {

                  // success

                  …

                  // get user info

                  wx.getUserInfo({

                    success: function (res3) {

                      that.globalData.userInfo = res3.userInfo

                      …

                    typeof cb == “function” && cb(that.globalData.userInfo)

                    }

                  })

                } else {

                  console.error(res2.data.msg)

                }

              },

              fail: function (error_result) {

                // fail

                console.error(error_result)

              },

              complete: function (complete_result) {

                // complete

                console.debug(complete_result)

              }

            })

          } else {

            console.error(‘获取用户登录态失败!’ + res.errMsg)

          }

        }

      })

    }

  },

onLoad: function (options) {

    var that = this

    //调用应用实例的方法获取全局数据

    that.getUserInfo(function (userInfo) {

      …

    }, true),

globalData: {

    userInfo: null,

  }

回到顶部