-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
32 lines (32 loc) · 834 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var util = require('utils/util.js');
var that;
//app.js
App({
onLaunch: function() {
that = this;
that.globalData.uid = wx.getStorageSync('uid');
util.log('local uid:' + that.globalData.uid);
// 登录
wx.login({
success: res => {
util.requestApi(`/api/login/${res.code}`, {}).then((data) => {
util.log('login result', data);
if (data.data && data.data.uid) {
that.globalData.uid = data.data.uid;
if (that.globalData.loginListener != null) {
that.globalData.loginListener(data.data.uid);
}
try {
wx.setStorageSync('uid', data.data.uid)
} catch (e) {}
}
}, (error) => {})
}
})
},
globalData: {
userInfo: null,
uid: null,
loginListener: null
}
})