forked from Cha0s0000/MicroSteemit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (38 loc) · 1.08 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
//app.js
App({
onLaunch: function () {
// get local storage
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// login with wechat account
wx.login({
success: res => {
// get data "res" after login success
}
})
// get wechat account info
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// Already authorized, you can call getUserInfo directly to get the avatar name, not the box.
wx.getUserInfo({
success: res => {
// You can send the res to the background to decode the unionId.
this.globalData.userInfo = res.userInfo
//Since getUserInfo is a network request, it might be returned after page.onload.
// So add a callback here to prevent this.
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null,
tag:''
}
})