-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathapp.js
41 lines (41 loc) · 1.01 KB
/
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
33
34
35
36
37
38
39
40
41
App({
onLaunch: function () {
var storageData = wx.getStorageSync('postList');
if (!storageData) {
var dataObj = require("data/data.js")
wx.clearStorageSync();
wx.setStorageSync('postList', dataObj.postList);
}
this._getUserInfo();
// wx.login();
},
_getUserInfo: function () {
var userInfoStorage = wx.getStorageSync('user');
if (!userInfoStorage) {
var that = this;
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
console.log(res);
that.globalData.g_userInfo = res.userInfo
wx.setStorageSync('user', res.userInfo)
},
fail: function (res) {
console.log(res);
}
})
}
})
}
else {
this.globalData.g_userInfo = userInfoStorage;
}
},
globalData: {
g_isPlayingMusic: false,
g_currentMusicPostId: null,
doubanBase: "http://t.yushu.im",
g_userInfo: null
}
})