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

    //把时间戳转为时间格式
    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;
    }
    //计算时间差值显示列表
    static getTimeDifference(start,end){
        let newTime = new Date();
        let newStart = new Date(start)
        let newEnd = new Date(end)

        let date = newStart.getDate() - newTime.getDate();

        let newHours = newStart.getHours();//小时
        let oldHours = newEnd.getHours();
        let newMonth = newStart.getMonth()+1;//月
        let oldMonth = newEnd.getMonth()+1;
        let newDate = newStart.getDate();//日

        let newEndHours = oldHours <10 ? '0' + oldHours : oldHours;
        let newStartHours = newHours <10 ? '0' + newHours : newHours;

        let newStartDate = newStart.getDate()+1<10?'0'+newStart.getDate():newStart.getDate();
        let newStartDay = newStart.getDay()<10?'0'+newStart.getDay():newStart.getDay();

        if(date == 0){
            return '今天  ' + ' '+newStartHours + ':00' + ' - ' + newEndHours+':00';
        }else{
            return newMonth + '月' + newDate +'日  ' +  ' '+newHours + ':00' + ' - ' + oldHours+':00';
        }
    }
}

//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.userType = 0;

ClassDataProxy.loginName ="";
ClassDataProxy.password =""
ClassDataProxy.token ="";
ClassDataProxy.status = false;
ClassDataProxy.id = '';
ClassDataProxy.siteId = 'markettest';
ClassDataProxy.userMobile = '';
ClassDataProxy.userEmail = '';
ClassDataProxy.monicker = "";

ClassDataProxy.USER_TYPE_0 = 0;
ClassDataProxy.USER_TYPE_1 = 1;
ClassDataProxy.USER_TYPE_2 = 2;
ClassDataProxy.USER_TYPE_8 = 8;
ClassDataProxy.USER_TYPE_32 = 32;

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


ClassDataProxy.USER_HOST = 'host';//老师
ClassDataProxy.USER_NOTMAL = 'normal';//学生
ClassDataProxy.USER_INVISIBLE = 'invisible';//兼课
ClassDataProxy.USER_ADMIN = 'admin';//管理员
ClassDataProxy.USER_VISITOR = 'visitor';//游客

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.locationProt = "123.56.73.119:3000";//端口
ClassDataProxy.locationProtDomain = "market.xuedianyun.com/";//端口

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;