forked from wildfirechat/uni-chat
-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.vue
120 lines (110 loc) · 3.64 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
<script>
import store from "./store";
import {getItem} from "./pages/util/storageHelper";
import wfc from "./wfc/client/wfc";
import conferenceManager from "./pages/voip/conference/conferenceManager";
import ConferenceInviteMessageContent from "./wfc/av/messages/conferenceInviteMessageContent";
import Message from "./wfc/messages/message";
import ForwardType from "./pages/conversation/message/forward/ForwardType";
import ConnectionStatus from "./wfc/client/connectionStatus";
export default {
data() {
return {
wfc: null,
store: null,
conferenceManager: null,
}
},
onLaunch: function () {
console.log("App Launch");
this.wfc = wfc;
this.store = store;
this.conferenceManager = conferenceManager;
// #ifdef APP-PLUS
plus.push.getClientInfoAsync((info) => {
let cid = info["clientid"];
if (cid) {
console.log('push clientId', cid);
wfc.setDeviceToken(7, cid);
}
});
// #endif
},
onShow: function () {
console.log("App Show");
store.state.misc.isAppHidden = false;
// #ifdef H5
let userId = getItem('userId');
let token = getItem('token')
if (token) {
if(wfc.getConnectionStatus() === ConnectionStatus.ConnectionStatusConnected){
console.log('app Show and connected')
return;
}
wfc.connect(userId, token);
this.go2ConversationList();
} else {
uni.redirectTo({
url: '/pages/login/LoginPage',
})
}
// #endif
},
mounted() {
//屏蔽默认的contextmenu事件
document.oncontextmenu = (e) => e.preventDefault();
},
onHide: function () {
console.log("App Hide");
store.state.misc.isAppHidden = true;
},
methods: {
go2ConversationList() {
uni.switchTab({
url: '/pages/conversationList/ConversationListPage',
success: () => {
console.log('to conversation list success');
},
fail: e => {
console.log('to conversation list error', e);
},
complete: () => {
console.log('switch tab complete')
}
});
},
forwardConferenceInviteMessage(callId, host, title, desc, startTime, audioOnly, defaultAudience, advance, pin) {
let inviteMessageContent = new ConferenceInviteMessageContent(callId, host, title, desc, startTime, audioOnly, defaultAudience, advance, pin);
console.log('invite', inviteMessageContent);
let message = new Message(null, inviteMessageContent);
this.$forward({
forwardType: ForwardType.NORMAL,
messages: [message]
});
},
}
}
</script>
<style lang="css">
/*每个页面公共css */
@import './global.css';
@import './wfc.css';
/* #ifndef APP-NVUE */
@import './static/iconfonts/customicons.css';
@import './static/iconfonts/icomoon/style.css';
/* #endif */
:root {
--uni-tabbar-height: 50px;
/*app-plus header 和 tabbar 是原生的*/
/* #ifdef APP-PLUS */
--uni-page-header-height: 0;
--page-full-height-without-header-and-tabbar: 100vh;
--page-full-height-without-header: 100vh;
/* #endif */
/* #ifdef H5 */
--uni-page-header-height: 44px;
--page-full-height-without-header-and-tabbar: calc(100vh - 44px - 50px);
--page-full-height-without-header: calc(100vh - 44px);
/* #endif */
}
</style>