app.js
2.04 KB
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
// app.js
App({
onLaunch() {
const that = this;
// 展示本地存储能力
// const logs = wx.getStorageSync('logs') || []
// logs.unshift(Date.now())
// wx.setStorageSync('logs', logs)
// 获取系统信息
const systemInfo = wx.getSystemInfoSync();
that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
that.globalData.statusBarHeight = systemInfo.statusBarHeight;
that.globalData.system = systemInfo.platform;
that.globalData.shared = wx.getStorageSync('shared')
// 检测小程序是否有更新
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
//console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
//引入公共的js
//const Interfaces = require('http/interfaces.js');
//const request = require('http/request.js');
//this.globalData.Interfaces = Interfaces;
//this.globalData.request = request;
// 登录
// wx.login({
// success: res => {
// // 发送 res.code 到后台换取 openId, sessionKey, unionId
// console.log(res)
// let oParams = {}
// oParams.code = res.code;
// }
// })
},
globalData: {
userInfo: {},
shared: false, // 是否分享
shareId: '', // 分享ID
navBarHeight: 0,
statusBarHeight: 0,
platform: '', // 机型
alarmInfo: ''
}
})