智慧保安互联网APP
liuyg
2021-08-12 dd10ee2243fcfc1a0f6ae340c4c1732e5c5d1cf2
视频1
4 files modified
97 ■■■■ changed files
components/submit/submit.vue 33 ●●●● patch | view | raw | blame | history
pages/videoCall/videoCall.nvue 59 ●●●● patch | view | raw | blame | history
store/index.js 1 ●●●● patch | view | raw | blame | history
store/mutations.js 4 ●●●● patch | view | raw | blame | history
components/submit/submit.vue
@@ -259,6 +259,9 @@
            //开始音频
            openAudio(val) { //Mains
                // console.log(this.names)
                // var socketOpen = false;
                uni.navigateTo({
                    url: '../videoCall/videoCall?state=' + val + '&type=audio'
                });
@@ -271,17 +274,37 @@
            },
            //开始视频
            openVideo(val) { //Mains
                // uni.onSocketOpen(function(res) {
                //     // socketOpen = true;
                //     console.log('持续连接成功')
                //     sendSocketMessage();
                // });
                // function sendSocketMessage() {
                //     var data = {
                //         name: this.$store.state.puserName,
                //         id: this.names[1],
                //         // id: state.puserID,
                //         type: 'video'
                //     }
                //     // if (socketOpen) {
                //     uni.sendSocketMessage({
                //         data: JSON.stringify(data)
                //     });
                //     // }
                // }
                uni.navigateTo({
                    url: '../videoCall/videoCall?state=' + val + '&type=video' + '&myname=' + this.names[0] +
                        '&toname=' + this.names[1]
                });
            },
            //接收视频
            receiveVideo(val, room) { //Receiver
                uni.navigateTo({
                    url: '../videoCall/videoCall?state=' + val + '&type=video' + '&room=' + room
                });
            }
            // receiveVideo(val, room) { //Receiver
            //     uni.navigateTo({
            //         url: '../videoCall/videoCall?state=' + val + '&type=video' + '&room=' + room
            //     });
            // }
        },
        mounted() {
            // uni.onSocketMessage(function(res) {
pages/videoCall/videoCall.nvue
@@ -115,8 +115,8 @@
                <text class="activetext">语音通话中</text>
                <u-loading size="36" mode="flower"></u-loading>
            </view>
            <!-- 音视频基本开关 -->
            <view class="videoshow_control position">
                <!-- 音频开关 -->
@@ -206,8 +206,8 @@
                userName: '111',
                toName: '',
                Otype: '',
                formName:''
                formName: ''
            }
        },
        // 页面初始加载(仅执行一次)
@@ -226,17 +226,52 @@
            console.log(option.state);
            if (option.state == "Mains") {
                this.isMain = true;
                var call = false;
                // this.userName = 'faqiren';
                this.userName = option.myname;
                this.toName = option.toname;
                setTimeout(res => {
                    //发起请求  给后端双方姓名
                // setTimeout(res => {
                //发起请求  给后端双方姓名
                    //得到返回值   开始视频  或者拒绝视频
                    this.join();
                //得到返回值   开始视频  或者拒绝视频
                // this.join();
                uni.request({
                    url: this.$store.state.api + '/pushMsg/inviteVideoCall',
                    data: {
                        userId: option.toname,
                        name: this.$store.state.puserName,
                        type: 'video'
                    },
                    success(res) {
                        // if(res.data.res == 0){
                        // }
                        var d = res.data.data;
                        if (d.res == 0) {
                            console.log('对方不在线--退出');
                            call = false;
                            uni.navigateBack();
                        } else if (d.res == 1) {
                            console.log('对方在线-- 等待对方接受');
                            // call = true;
                            this.join();
                        }
                    }
                })
                }, 5000)
                uni.onSocketMessage(function(res) {
                    console.log(res.data);
                    var data = JSON.parse(res.data)
                    // if (call && ) {
                    // }
                    if (data.type = 'close') {
                        console.log('对方已挂断');
                        this.closeAll();
                    }
                });
                // }, 5000)
            } else if (option.state == "Receiver") {
                this.userName = 'jieshouren';
                this.formName = 'wo';
@@ -565,7 +600,7 @@
                RtcModule.destroyRtc((res) => {
                    console.log("页面销毁", res.code);
                    console.log('成功关闭')
                    // uni.navigateBack();
                    uni.navigateBack();
                });
                // }
                // });
store/index.js
@@ -35,6 +35,7 @@
        logPath: '',
        // piAPI: 'http://223.82.109.183:2080/api',
        piAPI: 'http://223.82.109.183:2082/api',
        api: 'http://192.168.0.111:83',
        // piAPI: 'http://localhost:82/',
        // piAPI: 'http://192.168.0.108:81',
        puserName: '',
store/mutations.js
@@ -73,13 +73,13 @@
        uni.onSocketMessage(function(res) {
            console.log(res.data);
            var data  = JSON.parse(res.data)
            // if (data.type == 'video') {
            if (data.type == 'video') {
                // this.receiveVideo('Receiver', );
                console.log('进入接受 跳转',data.type)
                uni.navigateTo({
                    url: '../videoCall/videoCall?state=Receiver&type=' + data.type +'&room=' + data.roomId
                });
            // }
            }
            // console.log('收到服务器内容:' + res.data);
        });