-
Notifications
You must be signed in to change notification settings - Fork 222
/
App.vue
94 lines (87 loc) · 2.72 KB
/
App.vue
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<script>
import config from 'config.js'
import util from 'utils/util.js'
export default {
onLaunch: function() {
let info = uni.getSystemInfoSync()
info.versionCode = 0
info.version = config.info.version
info.appVersion = config.info.version
info.bookshelfChanged = false
if (info.model && info.model.indexOf('iPhone') !== -1) {
info.titleBarHeight = 44
} else {
info.titleBarHeight = 48
}
// 新版小程序升级检测
// #ifdef MP-WEIXIN
if (uni.canIUse('getUpdateManager')) {
const updateManager = uni.getUpdateManager()
updateManager.onCheckForUpdate(function(res) {
if (res.hasUpdate) {
updateManager.onUpdateReady(function() {
uni.showModal({
title: '升级提示',
content: '新版本已经为您准备就绪,是否升级应用?',
success: function(res) {
if (res.confirm) updateManager.applyUpdate()
}
})
})
}
})
}
// #endif
// #ifdef APP-PLUS
// 查询版本信息
plus.runtime.getProperty(plus.runtime.appid, function(wgtInfo) {
info.versionCode = wgtInfo.versionCode
info.version = wgtInfo.version
// 如果是Android平台,则检测是否有新版本
if (String(info.platform).toLowerCase() == "android") {
if (config.debug) console.log("request version api", config.api.lastestVersion)
util.request(config.api.lastestVersion).then(function(res) {
if (config.debug) console.log("latest version:", res)
if (res && res.data && res.data.version) {
if (config.debug) console.log("当前版本", info.versionCode, "最新版本", res.data.version)
if (info.versionCode < res.data.version) {
uni.showModal({
title: "温馨提示",
content: "发现新版本APP,您是否要升级体验?",
cancelText: "暂时忽略",
confirmText: "码上升级",
success: (action) => {
if (action.confirm) {
if (config.debug) console.log('用户点击确定');
plus.runtime.openURL(res.data.url)
} else if (res.cancel) {
if (config.debug) console.log('用户点击取消');
}
}
})
}
}
}).catch(function(e) {
console.log(e)
})
}
});
// #endif
if (config.debug) {
console.log(info)
console.log('platform', info.platform)
}
util.setSysInfo(info)
},
onShow: function() {
if (config.debug) console.log('App Show')
},
onHide: function() {
if (config.debug) console.log('App Hide')
},
}
</script>
<style>
/*每个页面公共css */
@import url("static/css/bookchat.css");
</style>