diff --git a/pages/index/index.wxml b/pages/index/index.wxml index e8e229f..5c33d43 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -26,8 +26,8 @@ - - + + {{item.limitNum}}人团 diff --git a/pages/login/login.js b/pages/login/login.js index e2137a6..c4e50d1 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -138,6 +138,10 @@ Page({ success: res => { // 可以将 res 发送给后台解码出 unionId app.globalData.userInfo = res.userInfo + // 发送 res.code 到后台换取 openId, sessionKey, unionId + if (that.globalData.openid != undefined && that.globalData.openid !=""){ + that.commitUserInfo(that.globalData.openid, res.encryptedData, res.iv); + }; // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 @@ -172,8 +176,7 @@ Page({ that.ohShitfadeOut(); return; } - // 发送 res.code 到后台换取 openId, sessionKey, unionId - that.commitUserInfo(that.globalData.openid, res.encryptedData, res.iv); + app.globalData.sessionId = data.response.sessionId; wx.setStorageSync('sessionId', data.response.sessionId); console.log('sessionId : ' + data.response.sessionId);