收藏
回答

用户登录时提示undefined is not an object?

在测试版进行小程序测试时一个测试账号发生登录错误导致无法使用微信登陆,但其他账号是正常的

手机型号iphone 12 pro ios14.3

微信版本8.0.0

基础库版本2.15.0[502]

otherlogin:function(e){
    let that = this;
    // 获取用户信息
    wx.getSetting({
      success(res) {
        if (res.authSetting['scope.userInfo']) {
          wx.getUserInfo({
            success(res) {
              console.log(res)
              that.setData({
                nickName:res.userInfo.nickName,
                avatarUrl:res.userInfo.avatarUrl
              })
              // 登录
              wx.login({
                success:(res)=>{
                // console.log(res)
                // 请求后台登录存储token
                  wx.request({
                    url: app.globalData.URL+'/api/user/third',
                    method:'GET',
                    data:{
                      'platform':'微信',
                      'code':res.code
                    },
                    header:{"content-type":"application/json"},
                    success:(res)=>{
                      console.log(res)
                      wx.setStorageSync('token', res.data.data.userinfo.token)
                      if(res.data.data.status==1){
                        wx.request({
                          url: app.globalData.URL+'/api/user/profile',
                          method:'GET',
                          data:{
                            'avatar':that.data.avatarUrl,
                            'nickname':that.data.nickName
                          },
                          header:{"content-type":"application/json",'token':res.data.data.userinfo.token},
                          success:(res)=>{
                            wx.reLaunch({
                              url'../index/index',
                            })
                          }
                        })
                      }else if(res.data.data.status==0){
                        wx.navigateTo({
                          url'../choseposition/choseposition',
                        })
                      }
                    }
                  })
                }
              })
            },
            fail(res) {
              console.log("获取用户信息失败", res)
            }
          })
        } else {
          console.log("未授权=====")
          that.showSettingToast("请授权")
        }
      },
      fail(res){
        console.log(res)
      }
    })
    
  },
回答关注问题邀请回答
收藏

3 个回答

  • 风禾
    风禾
    01-29

    怎么看都是你们数据的问题

    01-29
    有用 1
    回复
  • 跨商通
    跨商通
    01-29

    undifined的调试只需要console.log(111,xxx),勤快点多写几句吧。

    01-29
    有用
    回复
  • 默
    01-29

    查下接口

    01-29
    有用
    回复
登录 后发表内容
问题标签