2453关注8237浏览
为什么我用了wx.getShareInfo返回解密后没有openGId,只有如下json
{"openId":null,"nickName":null,"gender":null,"city":null,"province":null,"country":null,"avatarUrl":null,"unionId":null,"watermark":{"appid":"XXX","timestamp":"1534411759"}}
app.js代码如下
App({
onLaunch: function (options) {
//this.checkLogin(options.shareTicket);
this.globalData.shareInfo = null;
if (options.scene == 1044) {
that.getShareInfo(options.shareTicket);
}
},
onShow: function (options) {
this.checkLogin(options.shareTicket);
},
checkLogin: function (shareTicket) {
var that = this;
wx.checkSession({
success: function () {
if (!that.globalData.session) {
that.login(shareTicket);
}
else
{
if (shareTicket) {
that.getShareInfo(shareTicket);
}
};
},
fail: function () {
that.login(shareTicket);
}
})
},
//登录
login: function (shareTicket) {
var that = this
wx.login({
success: function (r) {
if (r.code) {
that.decodeSession(r.code, shareTicket);
}
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo;
}
})
}
})
},
//解密session信息
decodeSession: function (code, shareTicket) {
var that = this;
wx.request({
url: 'https://weixin.wlstock.com/Haogudao/GetOpenIdByCode',//向后端发起换取session_key请求的URL
data: {
code: code
},
success: function (re) {
if (re.data != null && re.data.openid != null && re.data.openid != '') {
that.globalData.session = {
openid: re.data.openid,
key: re.data.session_key
};
if (shareTicket) {
that.getShareInfo(shareTicket);
}
}
else {
that.globalData.session = null;
}
},
fail: function (res) {
console.log(res);
}
})
},
//获取群信息
getShareInfo: function (shareTicket) {
var that = this;
console.log('去获取getShareInfo');
wx.getShareInfo({
shareTicket: shareTicket,
success: function (res) {
console.log('去获取shareinfo');
wx.request({
url: that.globalData.APIUrl +'/DataHandle/Decrypt',//向后端发起解密请求的URL
data: {
encryptStrOfBase64: res.encryptedData,
encryptSessionKey: that.globalData.session.key,
iv: res.iv
},
success: fun
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>