1 |
|
2 | App({
|
3 | onLaunch: function () {
|
4 |
|
5 | var logs = wx.getStorageSync('logs') || []
|
6 | logs.unshift(Date.now())
|
7 | wx.setStorageSync('logs', logs)
|
8 | },
|
9 | getUserInfo:function(cb){
|
10 | var that = this
|
11 | if(this.globalData.userInfo){
|
12 | typeof cb == "function" && cb(this.globalData.userInfo)
|
13 | }else{
|
14 |
|
15 | wx.login({
|
16 | success: function () {
|
17 | wx.getUserInfo({
|
18 | success: function (res) {
|
19 | that.globalData.userInfo = res.userInfo
|
20 | typeof cb == "function" && cb(that.globalData.userInfo)
|
21 | }
|
22 | })
|
23 | }
|
24 | })
|
25 | }
|
26 | },
|
27 | globalData:{
|
28 | userInfo:null
|
29 | }
|
30 | }) |
\ | No newline at end of file |