-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
64 lines (61 loc) · 1.6 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
const qv = require("utils/qv");
const host = 'https://gbgbg.cn';
App({
onLaunch() {
// 强制更新
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新检测',
content: '检测到新版本,是否重启小程序?',
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
});
});
updateManager.onUpdateFailed(function () {
wx.showModal({
title: '更新提示',
content: '新版本下载失败',
showCancel: false
});
})
})
// 设置全面屏UI
let self = this;
wx.getSystemInfo({
success: (result) => {
console.log(result);
if (result.statusBarHeight > 20) {
self.globalData.isFullScreen = true;
}
if (result.windowWidth < 400) {
self.globalData.shortWidth = true;
}
},
});
// 登录
wx.login({
success: function(res) {
self.loginToMirai(res.code, '');
}
});
},
loginToMirai: function(code, displayName) {
let self = this;
return qv.post(host + '/api/openid/session', { jsCode: code, displayName: displayName }).then(result => {
self.globalData.session = result.data.data;
wx.$token = self.globalData.session.token;
self.globalData.launched = true;
});
},
globalData: {
host: host,
isFullScreen: false,
shortWidth: false,
launched: false
}
})