在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
var openId = (wx.getStorageSync('openId'))
if (openId) {
wx.getUserInfo({
success: function (res) {
that.setData({
nickName: res.userInfo.nickName,
avatarUrl: res.userInfo.avatarUrl,
})
},
fail: function () {
// fail
console.log("获取失败!")
},
complete: function () {
// complete
console.log("获取用户信息完成!")
}
})
} else {
wx.login({
success: function (res) {
if (res.code) {
wx.getUserInfo({
withCredentials: true,
success: function (res_user) {
wx.login({
success: function (res) {
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: {
appid: 'wx6286d06fe538aed9',
secret: '63ca18846d28001d334fecb84bd9bafb',
js_code: res.code,
grant_type: 'authorization_code'
},
method: 'GET',
success: function (res) {
var openid = res.data.openid;//获取到的openid
console.log(openid);
}
})
}
})
}, fail: function () {
}, complete: function (res) {
}
})
}
}
})
}
|
请发表评论