UserList.js 28.7 KB
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
//*
// 用户列表
// */

import Emiter from "Emiter";
import Loger from "Loger";
import $ from "jquery";
import xdysdk from "libs/xdysdk";
import ErrorApe from './ErrorApe';
import ClassDataProxy from "proxy/ClassDataProxy";
import SearchApe from './SearchApe';


let loger = Loger.getLoger('PC-UserList');
// let curClassStuNum=0;
class UserList extends Emiter {
    constructor() {
        super();
        this.rosterList={};
        this.oneselfList = {};
        this.silenceUsers = {};
        this.showState ={
            0: './images/ico_state/ico_pc.png',
            1:'./images/ico_state/ico_app.png',
            2:'./images/ico_state/ico_app.png',
            3:'./images/ico_state/ico_h5.png'
        };

        this.isSilence = false;//判断当前是否点击了全体禁言
        this.addEvent();
        this.init();
        this.searchApe=new SearchApe();
    }

    init() {
        //布局

        //开启/关闭音视频举手功能
        $('.tabCon').on('click','.iconVideo',this._openVideoHandler.bind(this));
        $('.tabCon').on('click','.iconAudio',this._openAudioHandler.bind(this));
        $('.tabCon').on('click','.medioClose',this._mediaCloseHandler.bind(this));
        $('.tabCon').on('click','.iconRaise',this._iconRaiseHandler.bind(this));

        $('#raiseBtn').on('click',this._raiseBthHandler.bind(this));
        //监课控制学生禁言
        $('.tabCon').on('click','.iconBanned',this._iconBannedHandler.bind(this));
        //监课取消学生禁言
        $('.tabCon').on('click','.iconBanned1',this._iconRelieveBannedHandler.bind(this));
        //全体禁言按钮
        $('#bannedBtn').on('click',this._bannedBtnHandler.bind(this));

        //显示隐藏userlist
        $('.arrowsLeft').on('click',this._hideRightHandler.bind(this));
        $('.arrowsRight').on('click',this._showRightHandler.bind(this));
    }
    addEvent() {
        xdysdk.on("class_join_success", this._classJoinSuccessHandler.bind(this));

        xdysdk.on("class_update_status", this._classUpdateHandler.bind(this));//会议状态更新

        xdysdk.on("class_insert_roster", this._insertRosterHandler.bind(this));  //人员进入
        xdysdk.on("class_delete_roster", this._deleteRosterHandler.bind(this));  //人员离开
        xdysdk.on("class_update_roster", this._updateRosterHandler.bind(this));  //人员信息更新

    }

    _classJoinSuccessHandler(_data){
        //loger.log('_classJoinSuccessHandler',_data)
        this.oneselfList['nodeId'] = _data.nodeId;
        //loger.log(this.oneselfList['nodeId'])
        ClassDataProxy.maxMediaChannels=_data.maxMediaChannels;

        //直播的时候需要隐藏右侧头部的视频区域
         if( ClassDataProxy.maxMediaChannels==2){
            this._primaryEffect();
             //判断是1v1课堂时 老师端显示 控制学生端画笔
            if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
                $('#controlBrush').show();
            }
        }
        if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
            $('#raiseBtn').hide();
        }
    }
    //会议状态更新
    _classUpdateHandler(_data){
        if(_data){
            //处理全体禁言
            this._allSilenceHandler(_data);
            this.isSilence = _data.silence;
            this.silenceUsers = _data.silenceUsers;
            //处理单个禁言
            this._silenceHandler(_data);

        }

    }
    //处理全体禁言
    _allSilenceHandler(_data){
        if(_data) {
            if (_data.silence == true) {
                this._addSilenceHandler();
                //点击全体禁言时单个禁言失效
                $('.tabCon').off('click','.iconBanned1');
            } else {
                this._removeSilenceHandler();
                //取消时恢复单个点击事件
                if(ClassDataProxy.userRole != ClassDataProxy.USER_NOTMAL) {
                    $('.tabCon').on('click', '.iconBanned1', this._iconRelieveBannedHandler.bind(this));
                }
            }

        }
    }
    //处理单个禁言
    _silenceHandler(_data){
        if(_data){
            for(let k in _data.silenceUsers){

                let nodeList = this._selectNodeIdOffUserId(k);
                for(let i in nodeList){
                    this._addBannedHandler(nodeList[i])
                }
            }
        }

    }
    //添加全体禁言状态
    _addSilenceHandler(){
        if(ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL){
            this._silenceHanler();
            ClassDataProxy.isKeypress = false;
        }
        this._addSilence()
        this._addAllSilence();
    }
    //删除全体禁言状态
    _removeSilenceHandler(){
        this._relievesilenceHanler();
        this._removeSilence()
        this._removeAllSilence();
        ClassDataProxy.isKeypress = true;
    }
    //更新禁言状态
    _updateSilenceHandler(_userId){
        if(this.isSilence){
            this._addSilenceHandler();
        }else{
           if(this.silenceUsers[_userId]){
               let nodeList = this._selectNodeIdOffUserId(_userId)
               for(let i in nodeList){
                   this._addBannedHandler(nodeList[i])
               }
           }
        }
    }
    //查找nodeId 的长度
    _selectNodeIdOffUserId(_userId){
        let _newArr = []
        for(let i in this.rosterList){
            let _user = this.rosterList[i].nodeData;
            if(_user.userId == _userId){
                _newArr.push(_user.nodeId)
            }
        }
        return _newArr;
    }
    //添加单个禁言状态
    _addBannedHandler(nodeId){
            if(ClassDataProxy.nodeId == nodeId){
                this._silenceHanler();
                ClassDataProxy.isKeypress = false;
            }
            this._addSilence(nodeId);

    }
    //删除单个禁言状态
    _removeBannedHandler(nodeId){
        if(ClassDataProxy.userId == nodeId){
            this._relievesilenceHanler();
            this._removeAllSilence();
            ClassDataProxy.isKeypress = true;
            this._removeSilence(nodeId);
        }
    }

    _insertRosterHandler(_data) {
        loger.log("人员加入信息---->");
        if(_data){
            this.rosterList[_data.nodeId]=_data;
            ClassDataProxy.rosterList=this.rosterList;

            //console.log("this.rosterList===>",this.rosterList);
            //添加到列表,设置id ->"user_"+_data.nodeId
            //loger.log('显示全部人员信息',this.rosterList[_data.nodeId])
            if(this.rosterList[_data.nodeId]){
                if(ClassDataProxy.nodeId!=_data.nodeId){
                    let listItem = this._creatDiv(_data.nodeId, this.rosterList[_data.nodeId].nodeData.name, this.rosterList[_data.nodeId].nodeId);
                    $("#curClassUserListCommon").append(listItem);
                    if(this.rosterList[_data.nodeId].nodeData.userRole != 'host'){
                        if(_data.nodeData.handUpTime){
                            this._addRaiseNum(_data);
                            $("#curClassUserListRaise").append($('#user_'+this.rosterList[_data.nodeId].nodeId));
                        }
                        loger.log('显示不是老师的信息',_data.nodeData.selfSilence)
                    }else{
                        $("#curClassUserListTeacher").prepend($('#user_'+this.rosterList[_data.nodeId].nodeId));
                    }
                    this._VideoStatus(_data);
                    this._audioStatus(_data);

                }else{
                    let listItem = this._creatDiv(_data.nodeId, this.rosterList[_data.nodeId].nodeData.name, this.rosterList[_data.nodeId].nodeId);
                    $("#curClassUserListTeacher").append(listItem);
                    this._mediaUnclick(_data);
                    loger.log('自己不需要显示在列表上')
                }
            }
            //判断是否是h5端设备 是否显示音视频按钮
            this._isEquipmentH5(_data);
            this._raiseNum(this.rosterList);
            //更新禁言状态
            this._updateSilenceHandler(_data.nodeData.userId)
            //判断用户的登录设备
            $('#user_'+_data.nodeId).find('.userAvatar').attr('src',this.showState[parseInt(_data.nodeData.deviceType)])
        }
        if(_data.nodeData['userRole'] == 'host'){
            $('#markDiv_'+_data.nodeId).find('.iconRaise').html('');
            ClassDataProxy.curRosterHostInfo=_data;
        }
        if(ClassDataProxy.userRole != ClassDataProxy.USER_HOST){
            $('.markDiv').find('span,img').css('cursor','default');
            $('.tabCon').off('click','.iconVideo');
             $('.tabCon').off('click','.iconAudio');
             $('.tabCon').off('click','.medioClose');
             $('.tabCon').off('click','.iconRaise');

        }
        if(ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL){
            $('.tabCon').off('click','.iconBanned');
            $('.tabCon').off('click','.iconBanned1');
            $('#bannedBtn').off('click').css('cursor','default');
        }
        if(_data.nodeData['userRole']=='normal'){
            $('#markDiv_'+_data.nodeId).find('.iconBanned').show();
        }else{
            $('#markDiv_'+_data.nodeId).find('.bannedDiv_'+_data.nodeId).remove();
        }

        if(ClassDataProxy.userRole==ClassDataProxy.USER_INVISIBLE&&_data.nodeData['userRole']=='invisible'){
            ClassDataProxy.curRosterInvisibleNodeId=_data.nodeId;
            $('.markDiv').find('span,img').css('cursor','pointer');
            if(ClassDataProxy.maxMediaChannels<2){
                $('#markDiv_'+ClassDataProxy.curRosterHostInfo.nodeId).find('.setUpInfo').show();
                $('#markDiv_'+ClassDataProxy.curRosterInvisibleNodeId).find('.setUpInfo').remove();
            }
            if(ClassDataProxy.maxMediaChannels>=2){
                $("#curClassUserListCommon .setUpInfo").show();
                $('#markDiv_'+ClassDataProxy.curRosterInvisibleNodeId).find('.setUpInfo').remove();
                $("#curClassUserListRaise .setUpInfo").show();
            }
        }
        if(ClassDataProxy.userRole==ClassDataProxy.USER_INVISIBLE&&_data.nodeData['userRole']!=='invisible'){
            $("#curClassUserListTeacher .setUpInfo").show();

            $('#markDiv_'+ClassDataProxy.curRosterInvisibleNodeId).find('.setUpInfo').remove();
            $('.markDiv').find('span,img').css('cursor','pointer');
            if(ClassDataProxy.maxMediaChannels>=2){
                $("#curClassUserListCommon .setUpInfo").show();
            }
        }
        //判断是否是监课 并判断身份是不是老师或者不是自己的时候 显示踢人按钮
        this.showKickHandler(_data);
    }
    //判断是否是监课 并判断身份是不是老师或者不是自己的时候 显示踢人按钮
    showKickHandler(_data){
        if(_data){
            if(ClassDataProxy.userRole == ClassDataProxy.USER_INVISIBLE && _data.nodeData['userRole'] == ClassDataProxy.USER_NOTMAL){
                $('#kick_'+_data.nodeId).show();
            }
        }
    }
    _setKickHandler(evt){
        let iconKick = $(evt.target);
        let nodeId = parseInt(iconKick.attr('data'));
        loger.log('点击需要踢出课堂的用户',nodeId);
        if(nodeId){
            xdysdk.api('kickOutRosterFormNodeId',{"nodeId":nodeId});
        }

    }
    _deleteRosterHandler(_data) {
        loger.log('人员离开---->', _data);
        if(_data){
            let listItem=this.rosterList[_data.nodeId];
            if(listItem&&listItem.nodeData&&listItem.nodeData.handUpTime){
                this._removeRaiseNum(_data);
            }
            delete this.rosterList[_data.nodeId];
            ClassDataProxy.rosterList=this.rosterList;
            //从列表删除 id ->"user_"+_data.nodeId
            let nameId=$(".userInfo");
            nameId.each(function (k, v) {
               // console.log("thisId",this.id);
                if (this.id==_data.nodeId){
                    $(this).parent().remove();
                    // curClassStuNum--;
                    // $(".curClassUserNumTotal").html("成员人数:"+"&nbsp;"+curClassStuNum);
                }
            });
        }
    }
    _updateRosterHandler(_data){
        loger.log('人员信息更新---->');
        if(_data){
            if(ClassDataProxy.nodeId == _data.nodeId){
                this._showRaiseNum(_data);
                this._VideoStatus(_data);
                this._audioStatus(_data);
                this.rosterList[_data.nodeId]=_data;
                if(!_data.nodeData.handUpTime){
                    $('#raiseBtn').removeClass('active');
                    $('#curClassUserListTeacher').append($('#user_'+this.rosterList[_data.nodeId].nodeId));
                }else{
                    $("#curClassUserListRaise").append($('#user_'+this.rosterList[_data.nodeId].nodeId));
                }
            }else{
                if(!this.rosterList[_data.nodeId].nodeData.handUpTime && _data.nodeData.handUpTime){
                    let listItem = this._creatDiv(_data.nodeId, this.rosterList[_data.nodeId].nodeData.name, this.rosterList[_data.nodeId].nodeId);
                    $("#curClassUserListRaise").append($('#user_'+this.rosterList[_data.nodeId].nodeId));
                }else if(this.rosterList[_data.nodeId].nodeData.handUpTime && !_data.nodeData.handUpTime){
                    $('#curClassUserListCommon').append($('#user_'+this.rosterList[_data.nodeId].nodeId));
                }
                this._showRaiseNum(_data);
                this._VideoStatus(_data);
                //this._raiseNum(_data);
                this.rosterList[_data.nodeId]=_data;
            }
            if(this.rosterList[_data.nodeId].nodeData.userRole == 'host'){
                $('#curClassUserListTeacher').prepend($('#user_'+this.rosterList[_data.nodeId].nodeId));
            }
            this._audioStatus(_data);
            //判断是否是h5端设备 是否显示音视频按钮
            this._isEquipmentH5(_data);
            this._raiseNum(this.rosterList);
            this.rosterList[_data.nodeId]=_data;
            ClassDataProxy.rosterList=this.rosterList;
        }

        //更新禁言状态
        this._updateSilenceHandler(_data.nodeData.userId)
    }

    //学生禁言函数
    _silenceHanler(){
        $('#btn_send').css('background','#9aa5ad').attr('disabled',true)
        $('#txt_message').attr("placeholder",ClassDataProxy.localConfig.gagContent);
        $('#fileImgInput').width(0);
        $('.fileImgBtn').css('cursor','default');
    }
    //学生解除禁言函数
    _relievesilenceHanler(){
        $('#btn_send').css('background','#3598db').attr('disabled',false)
        $('#txt_message').attr("placeholder","");
        $('#fileImgInput').width('20px');
        $('.fileImgBtn').css('cursor','pointer');
    }
    //添加禁言图标
    _addSilence(_data){
        if(_data){
            $('#banned_'+_data).addClass('iconBanned1').removeClass('iconBanned');
        }else{
            $('.iconBanned').addClass('iconBanned1').removeClass('iconBanned');
        }
    }
    //删除禁言图标
    _removeSilence(_data){
        if(_data){
            $('#banned_'+_data).addClass('iconBanned').removeClass('iconBanned1');
        }else{
            $('.iconBanned1').addClass('iconBanned').removeClass('iconBanned1');
        }
    }
    _addAllSilence(){
        $('#bannedBtn').addClass('relieveBanned').removeClass('bannedBtn')
    }
    _removeAllSilence(){
        $('#bannedBtn').addClass('bannedBtn').removeClass('relieveBanned')
    }

    _VideoStatus(_data){
        if(ClassDataProxy.userRole==ClassDataProxy.USER_HOST){
            if(_data.nodeData.openCamera){
                $('#Video_'+_data.nodeId).hide();
                $('#audio_'+_data.nodeId).hide();
                $('#medio_'+_data.nodeId).show();
            }else{
                $('#Video_'+_data.nodeId).show().css('color','#b3b3b3');
                $('#audio_'+_data.nodeId).show().css('color','#b3b3b3');
                $('#medio_'+_data.nodeId).hide();
            }
        }else{
            if(!_data.nodeData.openCamera){
                $('#Video_'+_data.nodeId).css('color','#b3b3b3');
                $('#audio_'+_data.nodeId).css('color','#b3b3b3');
            }else{
                $('#Video_'+_data.nodeId).css('color','#3498db');
                $('#audio_'+_data.nodeId).css('color','#3498db');
            }
        }
    }
    _audioStatus(_data){
        if(ClassDataProxy.userRole==ClassDataProxy.USER_HOST){
            if(_data.nodeData.openMicrophones){
                $('#Video_'+_data.nodeId).hide();
                $('#audio_'+_data.nodeId).hide();
                $('#medio_'+_data.nodeId).show();
            }else{
                $('#Video_'+_data.nodeId).show().css('color','#b3b3b3');
                $('#audio_'+_data.nodeId).show().css('color','#b3b3b3');
                $('#medio_'+_data.nodeId).hide();
            }
        }else{
            if(!_data.nodeData.openMicrophones){
                $('#audio_'+_data.nodeId).css('color','#b3b3b3');
            }else{
                $('#audio_'+_data.nodeId).css('color','#3498db');
            }
        }
    }
    //判断是否是h5端设备 是否显示音视频按钮
    _isEquipmentH5(_data){
        if(_data && _data.nodeData){
            if(_data.nodeData.deviceType == 3){
                $('#Video_'+_data.nodeId).hide();
                $('#audio_'+_data.nodeId).hide();
            }
         /*   else{
                //判断是否有设备 否则不显示
                if(!_data.nodeData.microphones || _data.nodeData.microphones.length <1){
                    $('#audio_'+_data.nodeId).hide();
                }
                if(!_data.nodeData.cameras || _data.nodeData.cameras.length <1 ){
                    $('#Video_'+_data.nodeId).hide();
                }
            }*/
        }
    }
    _mediaUnclick(_data){
        $('#markDiv_'+_data.nodeId).find('span,img').css('cursor','default');
        $('#user_'+_data.nodeId+' .nameDiv').css('color','#d95136');
        $('#user_'+_data.nodeId+' .iconVideo').addClass('iconVideo1').removeClass('iconVideo');
        $('#user_'+_data.nodeId+' .iconAudio').addClass('iconAudio1').removeClass('iconAudio');
        $('#user_'+_data.nodeId+' .medioClose').addClass('medioClose1').removeClass('medioClose');
    }
    _addRaiseNum(_data){
        $('.raiseDiv_'+_data.nodeId).show();
        $('#raiseBtn').attr('data',_data.nodeId);
    }
    _removeRaiseNum(_data){
        $('.raiseDiv_'+_data.nodeId).hide();
    }
    _raiseNum(_data){
        let num = 0;
        for(let i in this.rosterList){
            if(_data[i].nodeData.handUpTime){
                num ++;
            }
        }
        if(num == 0){
            $('.raiseNum').html('');
        }else{
            $('.raiseNum').html('('+num+')');
        }
        //loger.log('举手总人数',num)
        return num;
    }
    _showRaiseNum(_data){
        if(_data){
            if(_data.nodeData.handUpTime){
                if(!this.rosterList[_data.nodeId].nodeData.handUpTime){
                    this.rosterList[_data.nodeId].nodeData.handUpTime = _data.nodeData.handUpTime;
                    this._addRaiseNum(_data);
                }
            }else{
                if(this.rosterList[_data.nodeId].nodeData.handUpTime){
                    this.rosterList[_data.nodeId].nodeData.handUpTime = 0;
                    this._removeRaiseNum(_data);
                }
            }

        }
    }
    _raiseBthHandler(){
        let data = $('.raiseBtn').attr('data');
        if(!$('.raiseBtn').is('.active')){
            $('.raiseBtn').addClass('active');
            xdysdk.api('changeHandUpStatus',{"isHandUp":true});
        }else{
            $('.raiseBtn').removeClass('active');
            xdysdk.api('changeHandUpStatus',{"isHandUp":false});
        }
    }
    //监课点击禁言按钮
    _iconBannedHandler(evt){
        $(evt.target).addClass('iconBanned1').removeClass('iconBanned')
        let _nodeId = evt.target.parentNode.id.substr(8);
        let newDate = parseInt(((new Date().getTime())/1000)-ClassDataProxy.serverTimeDistance);
        let _userId = this.rosterList[_nodeId].nodeData.userId;
        xdysdk.api("controlSilenceStatus", {"nodeId":_nodeId,"userId":_userId, "silence": {startTime:newDate,duration:5}});
    }
    //监课取消学生禁言
    _iconRelieveBannedHandler(evt){
        //console.log("监课取消学生禁言");
        $(evt.target).addClass('iconBanned').removeClass('iconBanned1')
        let _nodeId = evt.target.parentNode.id.substr(8);
        let newDate = parseInt(((new Date().getTime())/1000)-ClassDataProxy.serverTimeDistance);
        let _userId = this.rosterList[_nodeId].nodeData.userId;
        xdysdk.api("controlSilenceStatus", {"nodeId":_nodeId,"userId":_userId, "silence": null});
    }
    //全体禁言   发送禁言消息
    _bannedBtnHandler(evt){
        if($(evt.target).hasClass('bannedBtn')){
           // $(evt.target).addClass('relieveBanned').removeClass('bannedBtn')
            xdysdk.api('silenceClass',{"silence":true})
        }else{
           // $(evt.target).addClass('bannedBtn').removeClass('relieveBanned')
            xdysdk.api('silenceClass',{"silence":false})
        }
    }

    _openVideoHandler(evt){
        //开启推流之前先判断一下是否还能推流
        let result = xdysdk.api("getVideoPublishPath", {"type": "flash"});
        //code为0,代表成功
        if (result.code != 0) {
            loger.warn('不能再打开设备->最多只能开启->',ClassDataProxy.maxMediaChannels);
            ErrorApe.showError(ErrorApe.TYPE_3,ClassDataProxy.localConfig.cantOpenDevice);
            return;
        }

        let iconVideo = $(evt.target);
        let data = iconVideo.attr('data');
        xdysdk.api("sendVideoBroadcastMsg",{
         "actionType":1,
         "toNodeId":parseInt(data),
         "data":"0"
         });

    }
    _openAudioHandler(evt){
        //开启推流之前先判断一下是否还能推流
        let result = xdysdk.api("getAudioPublishPath", {"type": "flash"});
        //code为0,代表成功
        if (result.code != 0) {
            loger.warn('不能再打开设备->最多只能开启->',ClassDataProxy.maxMediaChannels);
            ErrorApe.showError(ErrorApe.TYPE_3,ClassDataProxy.localConfig.cantOpenDevice);
            return;
        }


        let iconVideo = $(evt.target);
        let data = iconVideo.attr('data');
        xdysdk.api("sendAudioBroadcastMsg",{
            "actionType":1,
            "toNodeId":parseInt(data),
            "data":"0"
        });
    }
    _mediaCloseHandler(evt){
        let iconVideo = $(evt.target);
        let data = iconVideo.attr('data');
        iconVideo.hide();
        iconVideo.siblings('.iconAudio').show();
        iconVideo.siblings('.iconVideo').show();

        let user = this.rosterList[data].nodeData;
        loger.log('点击用户列表中的关闭按钮->',user);
        //发送音视频控制消息
        if(user['openCamera']){
            xdysdk.api("sendVideoBroadcastMsg",{
                "actionType":2,
                "toNodeId":parseInt(data),
                "data":"0"
            });
        }else{
            xdysdk.api("sendAudioBroadcastMsg",{
                "actionType":2,
                "toNodeId":parseInt(data),
                "data":"0"
            });
        }



    }
    _iconRaiseHandler(evt){
        let data = $(evt.target).attr('data');
        if( this.rosterList[data]){
            //this._cancelRaise(data);
            xdysdk.api('controlHandUpStatus',{"isHandUp":false,"nodeId":parseInt(data)});
       }
    }
    _cancelRaise(_data){
        $('.raiseDiv_' + _data).hide();
        if($('#raiseBtn').attr('data')){
            $('#raiseBtn').removeClass('active');
            xdysdk.api('changeHandUpStatus',{"isHandUp":false});
            this._removeRaiseNum(this.rosterList[_data]);
        }
    }
    //监课设置功能
    _setUpInfoHandler(evt){
        let setId = $(evt.target).attr('data');
        loger.log('点击设置音视频信息',this.rosterList[setId]);
    }
    //音视频路数大于1的时候,隐藏videoWindow
    _primaryEffect(){
        $('.videoWindow').hide();
        $('.discussAndUsers').css('top',0);
        $('.rightGap').show();
        $('.right').on('mouseenter',this._showArrowsHandler.bind(this));
        $('.right').on('mouseleave',this._hideArrowsHandler.bind(this));
    }
    _showArrowsHandler(){
        let width = $('.right').width();
        if(width == '320'){
            this._rightShow();
        }else{
            this._leftShow();
        }
        let _num = this._raiseNum(this.rosterList);
        _num = _num ? _num + ClassDataProxy.localConfig.raiseNum : ClassDataProxy.localConfig.clickView;
        $('.arrowsLeft').attr('title',ClassDataProxy.localConfig.clickHideList);
        $('.arrowsRight').attr('title',_num);
    }
    _hideArrowsHandler(){
        let width = $('.right').width();
        if(width == '10'){
            this._leftShow();
        }else{
            $('.arrowsLeft').hide();
            $('.arrowsRight').hide();
        }

    }
    _leftShow(){
        $('.arrowsLeft').hide();
        $('.arrowsRight').show();
    }
    _rightShow(){
        $('.arrowsLeft').show();
        $('.arrowsRight').hide();
    }
    _hideRightHandler(){
        $('.right').width('10px');
        this._leftShow();
        this._emit(UserList.WINDOW_VIEW_CHANGE);
    }
    _showRightHandler(){
        $('.right').width('320px');
        this._rightShow();
        this._emit(UserList.WINDOW_VIEW_CHANGE);
    }
    //创建列表元素
    _creatDiv(_id, _name, _nodeId) {
        let div = document.createElement("div");
        div.id = "user_" + _id;
        div.className = "userListInfo clear";

        let markDiv = document.createElement("div");
        markDiv.id = 'markDiv_'+ _id;
        markDiv.className = "markDiv clear";
        div.appendChild(markDiv);

        let ico = document.createElement("img");
        ico.src = '';
        ico.className="userAvatar";
        div.appendChild(ico);

        let userInfo = document.createElement("div");
        userInfo.className="userInfo";
        userInfo.id = _id;
        div.appendChild(userInfo);

        let nameDiv = document.createElement("label");
        nameDiv.innerText = "" + _name;
        nameDiv.title = "" + _name;
        nameDiv.className="nameDiv";
        userInfo.appendChild(nameDiv);

       /* let userStatus = document.createElement("label");
        userStatus.className="userStatus userStatus_"+_id;
        userInfo.appendChild(userStatus);*/

        let setDiv = document.createElement("span");
        setDiv.innerHTML = "&#xe631;";
        setDiv.className="iconfont setUpInfo";
        setDiv.id = 'set_'+ _id;
        setDiv.setAttribute('data',_id);
        setDiv.setAttribute('title',ClassDataProxy.localConfig.setBtn);
        // setDiv.onclick = this._setUpInfoHandler.bind(this);
        markDiv.appendChild(setDiv);

        let bannedDiv = document.createElement("span");
        bannedDiv.className="iconBanned bannedDiv_"+_id;
        bannedDiv.id = 'banned_'+ _id;
        bannedDiv.setAttribute('title',ClassDataProxy.localConfig.gag);
        markDiv.appendChild(bannedDiv);

        let kickDiv = document.createElement("span");
        kickDiv.innerHTML = "&#xe690;";
        kickDiv.className="iconfont iconKick kick_"+_id;
        kickDiv.setAttribute('data',_id);
        kickDiv.setAttribute('title',ClassDataProxy.localConfig.kickOutClass);
        kickDiv.id = 'kick_'+ _id;
        kickDiv.onclick = this._setKickHandler.bind(this);
        markDiv.appendChild(kickDiv);

        if(ClassDataProxy.maxMediaChannels >1){
            let audioDiv = document.createElement("span");
            audioDiv.innerHTML = "&#xe651;";
            audioDiv.className="iconfont iconAudio";
            audioDiv.setAttribute('data',_id);
            audioDiv.id = 'audio_'+ _id;
            markDiv.appendChild(audioDiv);

            let VideoDiv = document.createElement("span");
            VideoDiv.innerHTML = "&#xe64f;";
            VideoDiv.className="iconfont iconVideo";
            VideoDiv.setAttribute('data',_id);
            VideoDiv.id = 'Video_'+ _id;
            markDiv.appendChild(VideoDiv);

            let medioClose = document.createElement("img");
            medioClose.src = "./images/hangup.gif";
            medioClose.className="medioClose";
            medioClose.setAttribute('data',_id);
            medioClose.id = 'medio_'+ _id;
            markDiv.appendChild(medioClose);
        }

        let raiseDiv = document.createElement("span");
        raiseDiv.innerHTML = "&#xe603;";
        raiseDiv.className="iconfont iconRaise raiseDiv_"+_id;
        raiseDiv.setAttribute('data',_id);
        markDiv.appendChild(raiseDiv);

        return div;
    }
}
UserList.prototype.WINDOW_VIEW_CHANGE=UserList.WINDOW_VIEW_CHANGE='window_view_change';
export default UserList;