-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
66 lines (65 loc) · 1.9 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var n = require("./utils/index.js");
App({
globalData: {
openId: null,
wxUserInfo: null,
userInfo: null,
permission: null,
isMaster: !1,
isStudent: !1,
organ: [],
bathhouse: null,
error: !1,
sessionKey: null
},
onShow: function(n) {
this.getOpenId(), wx.setKeepScreenOn({
keepScreenOn: !0
});
},
getOpenId: function() {
var e = this;
wx.login({
success: function(o) {
o.code && (0, n.Request)(n.Api.getOpenId, {
jsCode: o.code
}).then(function(n) {
e.globalData.sessionKey = n.sessionKey, e.globalData.openId = n.openid, wx.setStorageSync("openid", n.openid),
e.getUserInfo();
}).catch(function(n) {
e.globalData.error = !0, e.loadFinish();
});
},
fail: function() {
e.globalData.error = !0, e.loadFinish();
}
});
},
getUserInfo: function() {
var n = this;
wx.getSetting({
success: function(e) {
wx.getUserInfo({
success: function(e) {
n.getToken(n.globalData.openId, function() {
n.globalData.wxUserInfo = e.userInfo, n.loadFinish();
});
},
fail: function() {
n.loadFinish();
}
});
}
});
},
getToken: function(e, o) {
(0, n.Request)(n.Api.getToken, {
openId: e
}).then(function(n) {
n && n.token && wx.setStorageSync("token_ap", n.token), o();
});
},
loadFinish: function() {
this.onLoadFinish && this.onLoadFinish(this.globalData);
}
});