-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathApp.vue
148 lines (143 loc) · 3.49 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<script>
import Vue from 'vue'
export default {
onLaunch: function() {
// 初始化系统
this.initSystem()
this.setTabBarText()
// 自动登录检测
this.autoLogin()
// 处理推送消息
this.handlePush()
},
methods: {
setTabBarText() {
uni.setTabBarItem({
index: 0,
text: this.$t('ToDo')
})
uni.setTabBarItem({
index: 1,
text: this.$t('YzCloud')
})
uni.setTabBarItem({
index: 2,
text: this.$t('Project')
})
uni.setTabBarItem({
index: 3,
text: this.$t('Statistics')
})
uni.setTabBarItem({
index: 4,
text: this.$t('Profile')
})
},
/**
* 处理推送消息
*/
handlePush() {
// #ifdef APP-PLUS
const _self = this
const _handlePush = function(message) {
// 获取自定义信息
let payload = message.payload
try {
// JSON解析
payload = JSON.parse(payload)
// 携带自定义信息跳转应用页面
uni.navigateTo({
url: '/pages/xxx?data=' + JSON.stringify(payload)
})
} catch(e) {}
}
// 事件处理
plus.push.addEventListener('click', _handlePush)
plus.push.addEventListener('receive', _handlePush)
// #endif
},
/**
* app整包更新检测
*/
appUpgrade(platform) {
if (platform !== 'android') {
return
}
//#ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
let params = {
appid: plus.runtime.appid,
version: wgtinfo.versionCode,
platform: platform
}
this.$minApi.findUpgradeApp(params).then(appRes => {
if (appRes.appid) {
uni.showModal({
title: "下载更新提示",
content: appRes.note,
showCancel: false,
confirmText: '确定',
success: sucRes => {
if (sucRes.confirm) {
plus.runtime.openURL(appRes.url)
// uni.downloadFile({
// url: appRes.url,
// success: res => {}
// })
}
}
})
}
})
})
//#endif
},
/**
* 自动登录
* 判断本地是否有账号信息,如果有,就自动重新登录
*/
autoLogin() {
this.$store.dispatch('autoLogin')
},
/**
* 初始化系统
*/
initSystem() {
const self = this
uni.getSystemInfo({
success: function(e) {
// app整包更新检测
self.appUpgrade(e.platform)
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
// #endif
// #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
})
}
}
}
</script>
<style lang="less">
@import "common/css/uni.css";
@import "colorui/main.css";
@import "colorui/icon.css";
@import "common/css/iconfont.css";
@import "common/css/common.css";
@import "common/css/custom-dark.less";
@import "common/css/custom-light.less";
</style>