安卓7.0.8微信版本进入小程序不执行wx.login()?
发布于 6 年前 作者 jchang 974 次浏览 来自 官方Issues

onLaunch里面的wx.login()没有执行

onLaunch: function (options) {

console.log(‘打印----’)

// // 展示本地存储能力

// var logs = wx.getStorageSync(‘logs’) || []

// logs.unshift(Date.now())

// wx.setStorageSync(‘logs’, logs)

wx.login({

success: res => {

console.log(res, ‘1111111111111’)

// var code = res.code

this.globalData.code = res.code;

var that = this

if (res.code) {

//发起网络请求

wx.request({

url: that.globalData.url + ‘/weixin/login’,

method: ‘POST’,

data: {

code:res.code

},

header: {

‘content-type’: ‘application/x-www-form-urlencoded’ // 默认值

},

success: function (res) {

console.log(res, “aaaaaaaaaaa”)

wx.setStorageSync(‘token’, res.data.data.token)

// // 存token

console.log(‘token=’ + res.data.data.token)

console.log(wx.getStorageSync(‘token’))

that.globalData.token = res.data.data.token;

}

})

} else {

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

}

}

}) 

// 获取用户信息

wx.getSetting({

success: res => {

if (res.authSetting[‘scope.userInfo’]) {

// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框

wx.getUserInfo({

success: res => {

// 可以将 res 发送给后台解码出 unionId

this.globalData.userInfo = res.userInfo

// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回

// 所以此处加入 callback 以防止这种情况

if (this.userInfoReadyCallback) {

this.userInfoReadyCallback(res)

}

}

})

}

}

})

},

2 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)代码片段的格式请先阅读文档再按照文档说明来提供

上代码片段啊

回到顶部