ClassDataProxy.js 13.4 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
import $ from "jquery";
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 getTimeCompareSize(start,end){
        let newDate = Date.parse(new Date());
        //开始时间
        let newTime = Date.parse(new Date(start))
        //结束时间
        let oldTime = Date.parse(new Date(end))

        if(newDate - newTime < 0  && newDate - oldTime > 0){
            console.log('正在直播')
            return '正在直播';
        }else if(newDate - oldTime < 0 && newTime - newDate > 0){
            console.log('未开始')
            return '未开始';
        }else if(newDate - newDate > 0 && newDate - oldTime < 0 ){
            console.log('已结束')
            return '已结束';
        }
    }
    //计算时间戳倒计时
    static getTimeCountDown(start,end){

        let now = new Date(), //现在的时间
            last = new Date(start), //开始上课时间

            eend = new Date(end),
            now_second = now.getTime(), //计算现在的毫秒数为多少(记住是从1970,1,1开始算起的)
            last_second = last.getTime(), //同上
            reserve_second = last.getTime() + 600000,
            end_second = eend.getTime(),
            gaptime = parseInt((last_second - now_second)/1000), //计算的是结束时间到现在时间的差(单位为秒)
            reserveTime = parseInt((reserve_second - now_second)/1000),//提前十分钟
            endTime = parseInt((end_second - now_second)/1000),
            //这里是计算还剩多少天数(一天24小时,一小时60分钟,一分钟60秒,一秒钟1000毫秒)
            date = parseInt(gaptime/(24*60*60)),
            hour = parseInt((gaptime/3600)%24), //这里是计算还剩多少小时
            min = parseInt((gaptime/60)%60), //这里是计算还剩多少分钟
            sec = parseInt(gaptime%60); //这里是计算还剩多少秒数

        if( date == 0){
            date = ''
        }else{
            date = "0" + date + ":";
        }
        if (hour < 10) {
            hour = "0" + hour;
        }
        if (min < 10) {
            min = "0" + min;
        }
        if (sec < 10) {
            sec = "0" + sec;
        }

        let result;
        if(gaptime > 0){
            if(reserveTime<0){
                result = date + hour + ":" + min + ":" + sec + '.';
            }else{
                result = date + hour + ":" + min + ":" + sec+ '|';
            }
        }else{
            if(gaptime != 0){
                result = '马上加入';
            }else{
                result = '已结束';
            }
        }
        return result;
    }
    //判断是否是今天
    static getTimeDay(start){

        let newDate = new Date();
        let month = newDate.getMonth()+1;
        let day = newDate.getDate();

        let oldDate = new Date(start);
        let d_month = oldDate.getMonth()+1;
        let d_day = oldDate.getDate();

        if(month <= d_month && day <= d_day){
            return true;
        } else {
            return false;
        }
    }
    //计算时间差值显示列表
    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 +'日  ' +  ' '+newStartHours + ':00' + ' - ' + newEndHours+':00';
        }
    }
    static getTimeEnd(start,end){
        let newDate = Date.parse(new Date());
        //开始时间
        let newTime = Date.parse(new Date(start))
        //结束时间
        let endTime = Date.parse(new Date(end))

        let t = newDate - endTime;//结束时间
        let y = newDate - newTime;//开始时间

        if(t<0){
            if(y < 0){
                return '未开始';
            }else{
                return '准备';
            }
        }else{
            return '已结束';
        }

    }

    //设置弹框位置  方法
    static getMarginTopHandler(_data){
        let top = ($(window).height() - _data.height())/2;
        let left = ($(window).width() - _data.width())/2;
        let scrollTop = $(document).scrollTop();
        let scrollLeft = $(document).scrollLeft();
        _data.css( { position : 'absolute', 'top' : top + scrollTop, left : left + scrollLeft } ).show();
    }
}

//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 = '';
ClassDataProxy.userMobile = '';
ClassDataProxy.userEmail = '';
ClassDataProxy.monicker = "";
ClassDataProxy.meetingId = '';
ClassDataProxy.userPhoto = '';

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;