| xqd
@@ -6,28 +6,16 @@ App({
|
|
|
var logs = wx.getStorageSync('logs') || []
|
|
|
logs.unshift(Date.now())
|
|
|
wx.setStorageSync('logs', logs)
|
|
|
-
|
|
|
+ var that = this;
|
|
|
wx.checkSession({
|
|
|
success: function() {
|
|
|
-
|
|
|
+ var we_chat_user_id = wx.getStorageSync('we_chat_user_id')
|
|
|
+ if(!we_chat_user_id) {
|
|
|
+ that.login()
|
|
|
+ }
|
|
|
},
|
|
|
fail: function() {
|
|
|
- wx.login({
|
|
|
- success: res => {
|
|
|
- wx.request({
|
|
|
- url: api.loginUrl,
|
|
|
- method: 'GET',
|
|
|
- data: {
|
|
|
- code: res.code
|
|
|
- },
|
|
|
- success: res => {
|
|
|
- if(res.data.status == 'success') {
|
|
|
- wx.setStorageSync('we_chat_user_id', res.data.id);
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ that.login()
|
|
|
}
|
|
|
})
|
|
|
},
|
| xqd
@@ -55,27 +43,19 @@ App({
|
|
|
login: function(info) {
|
|
|
wx.login({
|
|
|
success: res => {
|
|
|
- console.log(info, res)
|
|
|
wx.request({
|
|
|
url: api.loginUrl,
|
|
|
- method: 'POST',
|
|
|
+ method: 'GET',
|
|
|
data: {
|
|
|
- code: res.code,
|
|
|
- iv: info.iv,
|
|
|
- encryptedData: info.encryptedData
|
|
|
+ code: res.code
|
|
|
},
|
|
|
- success: info => {
|
|
|
- console.log(info);
|
|
|
- if (info.data.status == 'success') {
|
|
|
- wx.setStorageSync('pt_student', info.data.data);
|
|
|
- getApp().globalData.ptStudent = info.data.data;
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/index/index',
|
|
|
- })
|
|
|
+ success: res => {
|
|
|
+ if (res.data.status == 'success') {
|
|
|
+ wx.setStorageSync('we_chat_user_id', res.data.id);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
})
|