ClassDataProxy.js 8.8 KB
class ClassDataProxy {
    constructor() {
    }

    //获取课堂初始化的参数
    static getInitClassData() {
        let _data = {};
        _data.classId = this.classId;
        _data.portal = this.portal;
        _data.userRole = this.userRole;
        _data.userName = this.userName;
        _data.userId = this.userId;
        return _data;
    }

    //获取加入课堂的参数
    static getJoinClassData() {
        let _data = {};
        _data.password = this.password;
        _data.userName = this.userName;
        _data.autoLogin = this.autoLogin;
        return _data;
    }

    //生成时间戳毫秒
    static creatTimestamp() {
        let time = new Date().getTime();
        return time;
    }

    //生成时间戳 string
    static creatTimestampStr() {
        let curTime = new Date();
        let timeStr = "" + curTime.getFullYear() + "-";
        timeStr += (curTime.getMonth() + 1) + "-";
        timeStr += curTime.getDate() + "-";
        timeStr += curTime.getHours() + "-";
        timeStr += curTime.getMinutes() + "-";
        timeStr += curTime.getSeconds();
        return timeStr;
    }

    //把时间戳转为时间格式
    static timestampToDateTime(value) {
        var theTime = parseInt(value);// 秒
        var theTime1 = 0;// 分
        var theTime2 = 0;// 小时
        if (theTime > 60) {
            theTime1 = parseInt(theTime / 60);
            theTime = parseInt(theTime % 60);
            if (theTime1 > 60) {
                theTime2 = parseInt(theTime1 / 60);
                theTime1 = parseInt(theTime1 % 60);
            }
        }
        var result = "" + parseInt(theTime) + "";
        if (result < 10) {
            result = "0" + parseInt(theTime) + "";
        }
        if (theTime1 > 0) {
            if(theTime1<10){
                result = "0" + parseInt(theTime1) + ":" + result;
            }else{
                result = "" + parseInt(theTime1) + ":" + result;
            }

        }

        if (theTime2 > 0) {
            if(theTime2<10){
                result = "0" + parseInt(theTime2) + ":" + result;
            }else {
                result = "" + parseInt(theTime2) + ":" + result;
            }

        }

        return result;
    }

    //把时间戳转为时间格式  只显示时分秒
    static timestampToDateTimeSign(value) {
        let theTime = new Date(value * 1000);
        let hours = theTime.getHours();
        let minutes = theTime.getMinutes();
        let seconds = theTime.getSeconds();

        let timeValue = '';
        timeValue = ((hours < 10) ? "0" : "") + hours
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
        return timeValue;
    }

    //把时间戳转为时间格式
    static timestampToDateTimeFull(value) {
        var theTime = parseInt(value);// 秒
        var theTime1 = 0;// 分
        var theTime2 = 0;// 小时
        if (theTime > 60) {
            theTime1 = parseInt(theTime / 60);
            theTime = parseInt(theTime % 60);
            if (theTime1 > 60) {
                theTime2 = parseInt(theTime1 / 60);
                theTime1 = parseInt(theTime1 % 60);
            }
        }
        var result = "" + parseInt(theTime) + "";
        if (result < 10) {
            result = "0" + parseInt(theTime) + "";
        }
        if (theTime1 > 0) {
            if(theTime1<10){
                result = "0" + parseInt(theTime1) + ":" + result;
            }else{
                result = "" + parseInt(theTime1) + ":" + result;
            }
        }else {
            result = "0" + parseInt(theTime1) + ":" + result;
        }

        if (theTime2 > 0) {
            if(theTime2<10){
                result = "0" + parseInt(theTime2) + ":" + result;
            }else {
                result = "" + parseInt(theTime2) + ":" + result;
            }
        }else {
            result = "0" + parseInt(theTime2) + ":" + result;
        }

        return result;
    }
    //显示完整大小
    static getFitInFull(w1, h1, w2, h2) {
        if (w1 == 0 || h1 == 0 || w2 == 0 || h2 == 0) {
            console.warn("getFull->传入的参数值必须大于0", w1, h1, w2, h2);
            return;
        }
        let wScale = w2 / w1;
        let hScale = h2 / h1;
        let whScale = w2 / h2;
        if (wScale <= 1 && hScale <= 1) {
            return {w: parseInt(w2), h: parseInt(h2)}
        }
        let newW = w2;
        let newH = h2;
        if (wScale > hScale) {
            //缩放宽
            newW = w1;
            newH = newW / whScale;
        } else {
            //缩放高
            newH = h1;
            newW = newH * whScale;
        }
        return {w: parseInt(newW), h: parseInt(newH)}
    }

    //按宽度显示
    static getFitInWidth(w1, h1, w2, h2) {
        if (w1 == 0 || h1 == 0 || w2 == 0 || h2 == 0) {
            console.warn("getW->传入的参数值必须大于0", w1, h1, w2, h2);
            return;
        }
        let wScale = w2 / w1;
        let hScale = h2 / h1;
        let whScale = w2 / h2;
        let newW = w1;
        let newH = newW / whScale;
        return {w: parseInt(newW), h: parseInt(newH)}
    }
    //按高度显示
    static getFitInHeight(w1, h1, w2, h2) {
        if (w1 == 0 || h1 == 0 || w2 == 0 || h2 == 0) {
            console.warn("getH->传入的参数值必须大于0", w1, h1, w2, h2);
            return;
        }
        let wScale = w2 / w1;
        let hScale = h2 / h1;
        let whScale = w2 / h2;
        let newH = h1;
        let newW = newH * whScale;
        return {w: parseInt(newW), h: parseInt(newH)}
    }

    //获取浏览器和信息
    static getBrowserInfo() {
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var re = /(trident|msie|firefox|chrome|opera|version).*?([\d.]+)/;
        var m = ua.match(re);
        if (!m) m = ["version/1.0.0", "version", "1.0.0"];
        Sys.explorer = m[1].replace(/version/, "'safari");
        //判断是否是IE11
        if (Sys.explorer == "trident") {
            Sys.explorer = "IE11"
            Sys.explorerVersion = "11.0";
        } else if (Sys.explorer == "msie") {
            //IE
            Sys.explorer = "IE"
            Sys.explorerVersion = m[2];
        } else {
            //非IE
            Sys.explorerVersion = m[2];
        }
        return Sys;
    }
}

//Class
ClassDataProxy.siteId = "";
ClassDataProxy.classType = 1;

ClassDataProxy.className = "";
ClassDataProxy.classId = 0;
ClassDataProxy.classStatus = 0;
ClassDataProxy.classTimestamp = 0;
ClassDataProxy.recordPlaybackMaxTime = 0;
ClassDataProxy.isRecordPlayBack = false;
ClassDataProxy.portal = "";//IP+Port

ClassDataProxy.classStartTime = "";
ClassDataProxy.classStopTime = "";
ClassDataProxy.classBeginTime = "";
ClassDataProxy.classEndTime = "";

//USER
ClassDataProxy.userName = "";
ClassDataProxy.userId = "0";
ClassDataProxy.password = "";
ClassDataProxy.nodeId = 0;
ClassDataProxy.userRole = "normal";
ClassDataProxy.autoLogin = "";

ClassDataProxy.rosterList={};//用户列表数据
ClassDataProxy.rosterListUpdata={};//用户更新的数据
ClassDataProxy.curRosterHostInfo;//老师更新的信息
ClassDataProxy.curUserInfoTeaOrStu;
ClassDataProxy.curRosterInvisibleNodeId=0;


ClassDataProxy.USER_HOST = 'host';
ClassDataProxy.USER_NOTMAL = 'normal';
ClassDataProxy.USER_INVISIBLE = 'invisible';

ClassDataProxy.docServer = "";//文档服务器地址
ClassDataProxy.maxAudioChannels = 0;//最大音频路数
ClassDataProxy.maxVideoChannels = 0;//最大视频路数
ClassDataProxy.maxMediaChannels=0;//最大音视频路数,以音视频路数中的最大值为准

ClassDataProxy.currentPageNum = 1,//页码是第1页
ClassDataProxy.currentDocId = 0,//父级(文档)的itemIdx标识,如果当前没有文档,设置为0即可

//视频质量相关设置
ClassDataProxy.fps = 15;//帧频
ClassDataProxy.gop = 3;//关键帧间隔(秒)
ClassDataProxy.videoQuality = 2;//画面质量 0-低;1-中;2-高;
ClassDataProxy.curVideoQuality = 2;//画面质量 0-低;1-中;2-高;

ClassDataProxy.ssTunnelAppURL = '';//屏幕共享插件的地址
ClassDataProxy.locationProtocol="http://";

ClassDataProxy.locationProt = "192.168.31.8:3000";//端口

ClassDataProxy.SCENE_DOC=0;
ClassDataProxy.SCENE_SCREEN_SHARE=1;
ClassDataProxy.SCENE_MEDIA_SHARE=2;
ClassDataProxy.SCENE_MUSIC_SHARE=3

ClassDataProxy.currentSceneApeName=ClassDataProxy.SCENE_DOC;//默认显示文档区域

ClassDataProxy.isKeypress = true;//控制按回车键发送消息
ClassDataProxy.serverTimeDistance=0;//

ClassDataProxy.localConfig={};//语言编码
ClassDataProxy.isDraw;//是否在使用画笔
ClassDataProxy.isLaser;//是否在使用激光笔
ClassDataProxy.curSeek=1; //当前伴音seek;
ClassDataProxy.curVideoSeek=1;//当前媒体共享seek;

ClassDataProxy.isEnableDraw=false;//学生端画笔默认隐藏

export default ClassDataProxy;