-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
56 lines (55 loc) · 1.42 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
// app.js
const SYSTEM_INFO = 'SYSTEM_INFO';
App({
onLaunch() {
const _this = this;
wx.login({
success: (res) => {
_this.globalData.code = res.code;
},
})
// wx.getLocation({
// type: 'wgs84',
// success (res) {
// if (!_this.globalData.userInfo) {
// _this.globalData.userInfo = {};
// }
// _this.globalData.userInfo.lat = res.latitude;
// _this.globalData.userInfo.lon = res.longitude;
// }
// })
},
onShow(options) {
this.initSystemInfo(options);
},
initSystemInfo(options) {
const systemInfo = wx.getStorageSync(SYSTEM_INFO);
const _this = this;
if (!systemInfo) {
const res = wx.getSystemInfoSync();
const system = {
SDKVersion: res.SDKVersion,
platform: res.platform,
brand: res.brand,
model: res.model,
system: res.system,
version: res.version,
screenHeight: res.screenHeight,
screenWidth: res.screenWidth,
safeArea: res.safeArea,
isDebug: false //res.platform === 'devtools'
}
wx.setStorageSync(SYSTEM_INFO, JSON.stringify(system));
_this.globalData.systemInfo = system;
} else {
this.globalData.systemInfo = JSON.parse(systemInfo);
}
if (options) {
this.globalData.$route = options.path;
this.globalData.$options = options;
}
},
globalData: {
userInfo: null
}
})