-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
143 lines (129 loc) · 3.15 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
<script>
import { mapMutations, mapActions } from 'vuex';
import APPUpdate from '@/plugins/APPUpdate';
export default {
onLaunch: function() {
// #ifdef APP-PLUS
// 行为上报
if (!uni.getStorageSync('phoneNumber')) {
this.behaviour({
statTypeDataId: plus.device.uuid,
statType: 'guest'
});
}
//监听push推送通知
plus.push.addEventListener('receive', ({ type, title, content, payload }) => {
//console.log(type,title,content,payload);
console.log(type, 'type');
if (type == 'receive' || uni.getSystemInfoSync().platform != 'ios') {
//如果type!='receive'是自己本地插件的push消息栏,“拦截”避免死循环',安卓系统没有这个问题
if (typeof payload != 'object') {
payload = JSON.parse(payload);
} //判断是否为object,不是的话手动转一下。hbuilderx 3.0以上版本已经修复此问题可省略
plus.ui.alert(payload.title);
plus.push.createMessage(content, JSON.stringify(payload), {
title: payload.title,
subtitle: payload.content
});
}
});
//监听点击通知栏
plus.push.addEventListener('click', function({ payload }) {
uni.switchTab({
url: '/pages/home/home'
});
});
// 一键登录预登陆,可以显著提高登录速度
uni.preLogin({
provider: 'univerify',
success: res => {
// 成功
this.setUniverifyErrorMsg();
console.log('preLogin success: ', res);
},
fail: res => {
this.setUniverifyLogin(false);
this.setUniverifyErrorMsg(res.errMsg);
// 失败
console.log('preLogin fail res: ', res);
}
});
APPUpdate();
// #endif
},
onShow: function() {
console.log('App Show');
},
onHide: function() {
console.log('App Hide');
},
methods: {
...mapActions(['behaviour']),
...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
}
};
</script>
<style>
/* #ifdef APP-PLUS */
@import 'common/main.css';
/* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
@import 'common/uni.css';
/* H5 兼容 pc 所需 */
/* #ifdef H5 */
@media screen and (min-width: 768px) {
body {
overflow-y: scroll;
}
}
/* 顶栏通栏样式 */
/* .uni-top-window {
left: 0;
right: 0;
} */
/* uni-page-body {
background-color: #f5f5f5 !important;
min-height: 100% !important;
height: auto !important;
} */
.uni-top-window uni-tabbar .uni-tabbar {
background-color: #fff !important;
}
.uni-app--showleftwindow .hideOnPc {
display: none !important;
}
/* #endif */
/* 以下样式用于 hello uni-app 演示所需 */
page {
background-color: #efeff4;
height: 100%;
font-size: 28rpx;
line-height: 1.8;
}
.fix-pc-padding {
padding: 0 50px;
}
.uni-header-logo {
padding: 30rpx;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 10rpx;
}
.uni-header-image {
width: 100px;
height: 100px;
}
.uni-hello-text {
color: #7a7e83;
}
.uni-hello-addfile {
text-align: center;
line-height: 300rpx;
background: #fff;
padding: 50rpx;
margin-top: 10px;
font-size: 38rpx;
color: #808080;
}
/* #endif*/
</style>