ErrorApe.js 12.2 KB
//*
// 控制UI界面的模块
// */

import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-ErrorApe');

class ErrorApe extends Ape {
    constructor() {
        super();
        this.init();


    }
    init(){
        $('.errorFlashHintA').on('click',this._hideErrorHintHandler.bind(this));
        $('.errorSetFlashHintB').on('click',this._showErrorDetectionFlashParticular.bind(this));
        //各浏览器设置信息跳转
        $('#e_speed360').on('click',this._skipNewWindow.bind(this));
        $('#e_chrome').on('click',this._skipNewWindow.bind(this));
        $('#e_firefox').on('click',this._skipNewWindow.bind(this));
        $('#e_ie10').on('click',this._skipNewWindow.bind(this));
        $('#e_security360').on('click',this._skipNewWindow.bind(this));
        $('#e_2345').on('click',this._skipNewWindow.bind(this));
        $('#e_qq').on('click',this._skipNewWindow.bind(this));
        $('#e_sogou').on('click',this._skipNewWindow.bind(this));
        $('#e_safari').on('click',this._skipNewWindow.bind(this));

        //警告框warn 关闭事件
        $('#warnHintA').on('click',this._hideWarnError.bind(this));
    }

    show(){
        $('.errorHintBox').show();
    }
    hide(){
        $('.errorHintBox').hide();
        $('#publicChoiceErrorrBox').hide();
    }
    _hideErrorHintHandler(evt){
        let parents = $(evt.target).parents('.errorHint');
        parents.attr('data','');
        parents.hide();
        this.judgeDisplayStatus();
    }
    //关闭warn提示框
    _hideWarnError(){
        clearTimeout(this._isTime);
        $('#warnHintBox').hide();
    }
    judgeDisplayStatus(){
        let children = $('.errorHintBox').find('.errorHint'),len = 0;
        for(let i = 0;i<children.length;i++){
            if($(children[i]).attr('data') == 'open'){
                len ++;
            }
        }
        if(len <= 0){
            this.hide();
        }
    }
    showError(_type,_msg,_callback){
        this.show();
        switch (_type){
            case ErrorApe.TYPE_1:
                //显示直播兼容浏览器
                this.showErrorTestLive();
                break;
            case ErrorApe.TYPE_2:
                //显示回放兼容浏览器
                this.showErrorPlayback();
                break;
            case ErrorApe.TYPE_3:
                //公用的弹出框
                this.showPublicError(_msg);
                break;
           /* case ErrorApe.TYPE_4:
                this.showErrorCamera(_msg);
                break;
            case ErrorApe.TYPE_5:
                this.showErrorOccupyMicrophone(_msg);
                break;
            case ErrorApe.TYPE_6:
                this.showErrorOccupyCamera(_msg);
                break;*/
            case ErrorApe.TYPE_7:
                break;
            case ErrorApe.TYPE_8:
                //下载flash
                this.showErrorDetectionFlash(_msg,true);
                break;
            case ErrorApe.TYPE_9:
                //设置浏览器的flash使用权限
                this.showErrorDetectionFlash(_msg,false);
                break;
            case ErrorApe.TYPE_10:
                //safari falsh 提示开启权限
                this.showErrorSafariFlash();
                break;
            case ErrorApe.TYPE_11:
                //QQ Chrome falsh 提示开启权限
                this.showErrorQQOrChromeFlash();
                break;
            case ErrorApe.TYPE_12:
                //搜狗 360极速 falsh 提示开启权限
                this.showErrorSougouOr360jisuFlash();
                break;
            case ErrorApe.TYPE_13:
                //开启chrome flash权限
                this.showSetChromeFlash();
                break;
            case ErrorApe.TYPE_14:
                //开启Firefox flash权限
                this.showSetFirefoxFlash();
                break;
            case ErrorApe.TYPE_15:
                //开启QQ flash权限
                this.showSetQQFlash();
                break;
            case ErrorApe.TYPE_16:
                //开启2345 flash权限
                this.showSet2345Flash();
                break;
            case ErrorApe.TYPE_17:
                //开启360安全 flash权限
                this.showSet360anquanFlash();
                break;
            case ErrorApe.TYPE_18:
                //开启极速 flash权限
                this.showSet360jisuFlash();
                break;
            case ErrorApe.TYPE_19:
                //开启搜狗 flash权限
                this.showSetsougouFlash();
                break;
            case ErrorApe.TYPE_20:
              //显示询问弹框
                this.showPublicChoiceErrorrBox(_msg,_callback);
                break;
            case ErrorApe.TYPE_23:
                this.showErrorPublic(_msg);
                break;
            case ErrorApe.TYPE_24:
                this.showNetworkDisconnection(_msg);
                break;
            default:
                this.hide();
                break;
        }
    }
    //显示warn提示框 倒计时结束自动关闭盒子
    showWarnError(_msg,_time=5){
        clearTimeout(this._isTime);
        $('#warnHintBox').show();
        $('#warnHintContent').html(_msg);
        let time = parseInt(_time*1000);
        this._isTime = setTimeout(function(){
            $('#warnHintBox').hide();
        },time)
    }

   //各个盒子的显示
    //显示直播兼容浏览器
    showErrorTestLive(){
        $('.errorTestLive').show().attr('data','open');
    }
    //显示回放兼容浏览器
    showErrorPlayback(){
        $('.errorPlayback').show().attr('data','open');
    }
    //公用的弹出框
    showPublicError(_msg){
        $('.publicErrorBox').show().attr('data','open');
        $('.publicErrorBox').find('.errorPublicHintContent').html(_msg);
    }
    showErrorCamera(_msg){
        $('.notCamera').show().attr('data','open');
        $('.notCamera').find('.errorHintContent').html(_msg);
    }
    showErrorOccupyMicrophone(_msg){
        $('.occupyMicrophone').show().attr('data','open');
        $('.occupyMicrophone').find('.errorHintContent').html(_msg);
    }
    showErrorOccupyCamera(_msg){
        $('.publicErrorBox').show().attr('data','open');
        $('.publicErrorBox').find('.errorHintContent').html(_msg);
    }
    //设备中没有检测到flash/flash被禁用
    showErrorDetectionFlash(_msg,_isDownload=false){
        $('#notDetectionFlash').show().attr('data','open');
        if(_isDownload==true){
            //显示下载flash
            $('#flashDetailSteps').hide();
            $('#flashUpdataVersions').show();
        }else {
            //显示浏览器设置flash
            $('#flashDetailSteps').show();
            $('#flashUpdataVersions').hide();
        }
    }
    _showErrorDetectionFlashParticular(){
        $('.notDetectionFlash').hide().attr('data','');
        $('.notDetectionFlash_1').show().attr('data','open');
    }
    //设备中的flash版本过低,提示信息
    showErrorVersionsFlash(){
        $('.versionsFlash').show().attr('data','open');
    }
    //safari falsh 提示开启权限
    showErrorSafariFlash(){
        $('.safariFlashBan').show().attr('data','open');
    }
    //QQ Chrome falsh 提示开启权限
    showErrorQQOrChromeFlash(){
        $('.QQOrChromeFlashBan').show().attr('data','open');
    }
    //搜狗 360极速 falsh 提示开启权限
    showErrorSougouOr360jisuFlash(){
        $('.sougouOr360jisuFlashBan').show().attr('data','open');
    }
    //开启chrome flash权限
    showSetChromeFlash(){
        $('.setChromeFlash').show().attr('data','open');
    }
    //开启Firefox flash权限
    showSetFirefoxFlash(){
        $('.setFirefoxFlash').show().attr('data','open');
    }
    //开启QQ flash权限
    showSetQQFlash(){
        $('.setQQFlash').show().attr('data','open');
    }
    //开启2345 flash权限
    showSet2345Flash(){
        $('.set2345Flash').show().attr('data','open');
    }
    //开启360安全 flash权限
    showSet360anquanFlash(){
        $('.set360anquanFlash').show().attr('data','open');
    }
    //开启360极速 flash权限
    showSet360jisuFlash(){
        $('.set360jisuFlash').show().attr('data','open');
    }
    //开启搜狗 flash权限
    showSetsougouFlash(){
        $('.setsougouFlash').show().attr('data','open');
    }
    showCloseEndClass(_msg,_callback){
        //$('.endClassHint').show().attr('data','open');
        //if(_callback){
        //    $('.endClassHint').hide().attr('data','');
        //}
        this.showPublicChoiceErrorrBox(_msg,_callback);
    }
    showCloseExitClass(_msg,_callback){
        //$('.exitClassHint').show().attr('data','open');
        //if(_callback){
        //    $('.exitClassHint').hide().attr('data','');
        //}
        this.showPublicChoiceErrorrBox(_msg,_callback);
    }
    showCloseEndShare(_msg,_callback){
        //$('.endShareHint').show().attr('data','open');
        //if(_callback){
        //    $('.endShareHint').hide().attr('data','');
        //}
        this.showPublicChoiceErrorrBox(_msg,_callback);
    }
    showErrorPublic(_msg){
        $('.errorPublicHint').show().attr('data','open');
        $('.errorPublicHint').find('.errorPublicHintContent').html(_msg);
    }
    showNetworkDisconnection(_msg,_callback){
        $('.networkDisconnection').show().attr('data','open');
        $('.networkDisconnection').find('.errornetworkHintContent').html(_msg);
        //if(_callback){
        //    $('.networkDisconnection').hide().attr('data','');
        //    this.judgeDisplayStatus();
        //}
    }

    //显示有确定和取消按钮的提示框
    showPublicChoiceErrorrBox(_msg,_callback){
        $('#publicChoiceErrorrBox').show();
        $('#choiceHintBoxText').html(_msg);
        $('#choiceConfirm').off("click");
        $('#choiceCancel').off("click");
        let _this=this;
        $('#choiceConfirm').on("click",function(){
            _this.hide();
            if(_callback){
                _callback(true);
            }

        });
        $('#choiceCancel').on("click",function(){
            _this.hide();
            if(_callback){
                _callback(false);
            }

        });
    }
    //各刘拉你设置flash跳转
    _skipNewWindow(evt){
        let _id = $(evt.target).attr('id');
        window.open(this.PATH + '/' + this.language + '/' + _id + '.html');
    }
}
ErrorApe.prototype.TYPE_1=ErrorApe.TYPE_1=1;//兼容直播课堂的浏览器
ErrorApe.prototype.TYPE_2=ErrorApe.TYPE_2=2;//兼容录制回放的浏览器

ErrorApe.prototype.TYPE_3=ErrorApe.TYPE_3=3;//没有麦克风
/*ErrorApe.TYPE_4=4;//没有摄像头
 ErrorApe.TYPE_5=5;//麦克风被占用
 ErrorApe.TYPE_6=6;//摄像头被占用*/
ErrorApe.prototype.TYPE_7=ErrorApe.TYPE_7=7;//摄像头和麦克风权限

ErrorApe.prototype.TYPE_8=ErrorApe.TYPE_8=8;//没有安装flash
ErrorApe.prototype.TYPE_9=ErrorApe.TYPE_9=9;//flash版本过低

ErrorApe.prototype.TYPE_10=ErrorApe.TYPE_10=10;//flash被禁用 safari
ErrorApe.prototype.TYPE_11=ErrorApe.TYPE_11=11;//flash被禁用 QQ  谷歌
ErrorApe.prototype.TYPE_12=ErrorApe.TYPE_12=12;//flash被禁用 搜狗  360极速
ErrorApe.prototype.TYPE_13=ErrorApe.TYPE_13=13;//flash被禁用 点击拒绝 谷歌
ErrorApe.prototype.TYPE_14=ErrorApe.TYPE_14=14;//flash被禁用 点击拒绝 火狐
ErrorApe.prototype.TYPE_15=ErrorApe.TYPE_15=15;//flash被禁用 点击拒绝 QQ
ErrorApe.prototype.TYPE_16=ErrorApe.TYPE_16=16;//flash被禁用 点击拒绝 2345
ErrorApe.prototype.TYPE_17=ErrorApe.TYPE_17=17;//flash被禁用 点击拒绝 360安全
ErrorApe.prototype.TYPE_18=ErrorApe.TYPE_18=18;//flash被禁用 点击拒绝 360极速
ErrorApe.prototype.TYPE_19=ErrorApe.TYPE_19=19;//flash被禁用 点击拒绝 搜狗

ErrorApe.prototype.TYPE_20=ErrorApe.TYPE_20=20;//结束课堂提示信息
ErrorApe.prototype.TYPE_21=ErrorApe.TYPE_21=21;//退出课堂提示信息
ErrorApe.prototype.TYPE_22=ErrorApe.TYPE_22=22;//屏幕共享提示信息
ErrorApe.prototype.TYPE_23=ErrorApe.TYPE_23=23;//错误提示信息

ErrorApe.prototype.TYPE_24=ErrorApe.TYPE_24=24;//显示退出课堂
ErrorApe.prototype.language=ErrorApe.language="zh_cn";//设置默认语言为中文
ErrorApe.prototype.PATH=ErrorApe.PATH="explorerSetMsg";//定义默认路径

export default new ErrorApe;