123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <view class="call-view">
- <!-- 本地视频画面 -->
- <!-- #ifdef APP -->
- <grtc-video v-if="currentCall.mediaType === 1" :userId="currentCall.caller.id" class="main-video"></grtc-video>
- <!-- #endif -->
- <!-- #ifdef H5 -->
- <web-grtc-video v-if="currentCall.mediaType === 1" :userId="currentCall.caller.id" class="main-video"></web-grtc-video>
- <!-- #endif -->
- <view class="profile">
- <image class="user-avatar" mode="widthFix" :src="callee.data.avatar"></image>
- <text class="user-name">{{callee.data.name}}</text>
- </view>
- <view class="status-box">
- <text class="status-notice">等待对方接受邀请</text>
- <image src="/static/images/load.gif" class="loading"></image>
- </view>
- <view class="action-box">
- <view class="action-item" @click="end()">
- <view class="end-background">
- <image class="action-icon" src="/static/images/phoneEnd.png"></image>
- </view>
- <text class="action-text">取消</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import webGrtcVideo from '../components/web-grtc-video/web-grtc-video.vue';
- const GRTC = uni.$GRTC;
- export default {
- data() {
- return {
- currentCall: GRTC.currentCall(),
- callee: GRTC.currentCall().callees[0],
- }
- },
- components: {
- webGrtcVideo,
- },
- onLoad() {
- this.initListener();
- },
- onUnload() {
- GRTC.off(GRTC.EVENT.USER_ACCEPTED, this.onUserAccepted);
- GRTC.off(GRTC.EVENT.USER_RANG, this.onUserRang);
- GRTC.off(GRTC.EVENT.USER_QUIT, this.onUserQuit);
- },
- onBackPress(event) {
- return event.from === 'backbutton'; // 禁止安卓侧滑返回
- },
- methods: {
- initListener() {
- GRTC.on(GRTC.EVENT.USER_ACCEPTED, this.onUserAccepted);
- GRTC.on(GRTC.EVENT.USER_RANG, this.onUserRang);
- GRTC.on(GRTC.EVENT.USER_QUIT, this.onUserQuit);
- },
- onUserAccepted(event) {
- uni.showToast({
- title: event.user.data.name+"已接听",
- icon: "none"
- });
- uni.redirectTo({
- url: './call'
- });
- },
- onUserRang(event) {
- uni.showToast({
- title: event.user.data.name+"已响铃",
- icon: "none"
- });
- },
- onUserQuit(event) {
- const username = event.user.data.name;
- let message = '';
- switch (event.reason) {
- case 'DIAL_TIMEOUT':
- message = `拨打超时`;
- break;
- case 'CANCELLED':
- message = `已取消`;
- break;
- case 'REJECTED':
- message = `${username}已拒绝`;
- break;
- case 'GOEASY_DISCONNECTED':
- message = `${username}网络异常`;
- break;
- }
- uni.showToast({title: message,icon: "none"});
- uni.navigateBack();
- },
- end() {
- GRTC.end();
- },
- }
- }
- </script>
- <style scoped>
- @import url('/static/style/rtcCallStyle.css');
- </style>
|