//------------------------------------------------------------------------------------用户桌面和程序数据初始化区域----------------------------------------------------------------------------------------------------------------
Namespace.register("U.MD.D"); //桌面onload和桌面总控的命名空间
/*
window.onload的流程:
1、自由属性的设置,例如:页面识别id。允许浏览器多页面浏览www.1473.cn
2、加载各种事件绑定,如:页面大小监视,不允许选择桌面文字,ie7以下浏览器页面提示
3、加载桌面图标。
4、加载跨域设置,如果没有跨域,首页数据无法获取
4、加载首页
5、加载广告,QQ登录等外链。

UD和UC区别 uc是框架函数 ud为操作系统原壳 这里的简化的目标很简单 只要有人应用ud 就会引用一个web操作系统 提供操作系统的功能应用
难题 :
1、命名和用户冲突 会导致原web系统不可使用
2、函数冲突 如 用户自带window.resize这样的函数 我们提供了接口 但是这个接口的的暴露性可见性体现出文档的重要 宣传文档也就是文宣的重要性高了
3、有参数注释的都为暴露接口类型 其他都为内部使用 更好的体现方式
*/

//#region 配置区域,相当于全局变量定义
U.MD.D.IsUseStudio = true;

//本地存储类
U.MD.D.LocalStorage = null;

//#endregion

//#region onload处理

/**
 * 系统初始化处理
 *
 * @param  {function} 在外部项目应用该项目的时候 可以传入cb这个参数,如果传入了这个参数在回调跨域main.1473.cn加载成功会就会直接回调
 */
window.onload = function () {
    U.MD.D.Load();
    U.MD.U.L.login();
    //U.MD.D.isLogin();
    // U.MD.D.fullscreen();
    U.MD.D.stopSafari();
    // window.addEventListener('resize', () => {
    //     var realHeight = window.innerHeight
    //     var realWidth = window.innerWidth
    //     initViewport(realHeight, realWidth);
    //     // window.location.reload();
    // })
}

US.Config = {
    server: '//beta.api.cocorobo.cn/api/',
    api: '//beta.api.cocorobo.cn/',
    chat: "//chat.api.cocorobo.cn/",
    edu: '//api.edu.cocorobo.cn/edu/',
    origin: '//cocorobo.cn',
    pbl: "//pbl.cocorobo.cn/api/pbl/",
    // bpbl:"//pbl.cocorobo.cn",//正式链接
    bpbl:"//beta.pbl.cocorobo.cn",//测试链接
    // pbl: "http://localhost:7003/api/pbl/",
    basename: '',
    type:1,
    background:'url("/img/icon/bgImg4.png")'
}
/**
 * 供外部调用的window.onload函数云端系统启动项
 *
 * @param  {function} 在外部项目应用该项目的时候 可以传入cb这个参数,如果传入了这个参数在回调跨域main.1473.cn加载成功会就会直接回调
 */
U.MD.D.Load = U.MD.D.FLoad = function (cb) {
    //这里判断是如果是www.1473.cn 或者 www.boomyun.com项目的时候 或者是 通过ufrom的跨域函数加载成功页面时候可以执行window.onload, 添加判断的目的主要是反正 其他项目引用uformd的时候自动执行window.onload报错。
    //当引用云端硬盘,好友模块时需要在自己的js文件中添加window.onload入口函数,否则会触发云端的window.onload,导致系统报错,
    //初始化桌面,如果是1473主站点那么初始化桌面系统,否则外部引入1473不加载桌面

    //系统初始化、第一个就是加载桌面,然后初始化全局变量、绑定事件、最后加载数据(加载数据需要跨域加载,因为项目分离的原因,我们有disk.1473.cn、user.1473.cn、firend.1473.cn里面有静态数据,还有动态的后台)
    if (U.MD.D.IsUseStudio) {
        //桌面初始化弹出
        U.selectEl("#UD_Dtop")[0].style.display = "block";
        //桌面做为一个置底的窗体
        new U.UF.UI.form(false, U.selectEl("#UD_Dtop")[0], { onresize: true, style: { "cssText": "width:100%;height:100%;padding:0;border:0;border-radius:0;box-shadow:0;position:static;" }, "className": "" }, { istop: false, isdrag: false, isdrag: false, isstretching: false, isenlarge: false, isnarrow: false, isclose: false }, null, { style: { "padding": "0" } });
    }
    //这里加判断的原因是怕有开发者开发的过程中直接调用uformd.js没有写跨域加载,没有写window.onload导致再运行的过程中找不到元素报错
    if ($("#U_MD_Home")[0]) {
        //设置页面大小等的全局变量
        U.MD.D.settingGlobalVariables();
        //浏览器事件监视及处理
        U.MD.D.addEvents();
        //var _browserinfo = U.UF.CI.getBrowser(); //获取浏览器
        ////ie7以下的浏览器弹出不兼容的处理 
        //if (_browserinfo["browser"] == "msie" && parseInt(_browserinfo["ver"]) < 7) {
        //    //弹出不兼容的处理 
        //    U.MD.D.A.browserCompatibleForm();
        //}
    }
    //跨域加载
    U.MD.D.crossDomain(cb); //跨域初始化,里面包含了用户登录
}

/**
 * 设置当前使用页面大小
 */
U.MD.D.settingGlobalVariables = function () {
    //获取页面的大小
    var _size = U.selectEl("body").getElementInfo();
    US.height = _size["CH"]; //获取高度
    US.width = _size["CW"]; //获取宽度
    //1473的登录识别id
    US.systemId = 1;
    //页面识别id 页面唯一的识别 作为用户访问1473的唯一识别码,在之前用户获取聊天室的信息的唯一识别码
    US.pageId = Guid.newGuid();
}

/**
 * 系统监视
 */
U.MD.D.addEvents = function () {
    //页面活动状态监视,失焦的时候停止五秒刷新,聚焦的时候开始刷新
    U.UF.EV.IsActivity(U.MD.D.focus, U.MD.D.blur);
    //监视页面的点击 使得窗体点击为顶部
    U.UF.F.clickTopWindow();
    //页面大小变化监视
    U.MD.D.reSize();
    window.onresize = U.MD.D.reSize;
    //如果是云端1473则屏蔽菜单和错误弹框
    if (U.MD.D.IsUseStudio) {
        if (window.print) { //判断是否有右键菜单
            document.oncontextmenu = U.UF.EV.stopDefault; //阻止桌面右键默认菜单
        }
        document.onselectstart = U.UF.C.shieldedSelect; //禁止文本选择处理
        U.UF.EV.addElementEvent("keydown", document, U.UF.C.shieldedBackspace); //禁止浏览器回退
        //window.onerror = U.MD.D.error; //错误提示屏蔽
    }
    //允许错误提示和右键菜单
    else {
        window.onerror = null;
    }
    //页面路由事件处理 
    U.UF.N.route(U.MD.N.urlGuide);
}

/**
 * 页面大小变化时,需要重新排列图标及任务栏大小的变化.
 */
U.MD.D.reSize = function () {
    //页面变化处理
    //获取页面的大小
    // US.height = window.innerHeight > window.innerWidth ? window.innerWidth : window.innerHeight;
    // US.width = window.innerHeight > window.innerWidth ? window.innerHeight : window.innerWidth;

    var _size = U.selectEl("html").getElementInfo();
    if (_size["CH"] > 500) {
        //处理窗体区域 随着页面大小变化而变化
        U.UF.UI.form.windowResize();
        // var _size = U.selectEl("body").getElementInfo();
        US.height = _size["CH"]; //获取高度
        US.width = _size["CW"]; //获取宽度;
        document.body.style.width = US.width + 'px';
        document.body.style.height = US.height + 'px';
        //任务栏处理
        if ($("#U_MD_D_RW")) {
            U.selectEl("#U_MD_D_RW").css("width", US.width - 165 + "px");
            U.MD.D.T.taskbar.multitask($("#U_MD_D_RW")[0]);
            //桌面图标处理
            if(US.Config.type == '1'){
                U.MD.D.iconPostion($("#U_MD_D_K").Child());
            }else{
                U.MD.D.iconPostion2($("#U_MD_D_K").Child());
            }
        }

    }
}

/**
 * 跨域引入1473
 * @param  {function} 跨域加载成功后的回调函数
 */
U.MD.D.crossDomain = function (cb) {
    U.MD.D.loadApplication(cb);
    ////跨域加载,如果是1473的跨域,那么则添加跨域的iframe处理
    //if (document.domain == "1473.cn") {
    //    U.UF.CD.loadAjaxCrossDomain(function () {
    //        U.MD.D.loadApplication(cb);
    //    });
    //}
    ////如果是非1473的跨域,添加跨域的iframe
    //else {
    //    U.UF.CD.thirdPartyLoadAjaxCrossDomain(function () {
    //        U.MD.D.loadApplication(cb);
    //    });
    //}
}

/**
 * 加载user 、 friend 、disk的js
 */
U.MD.D.loadApplication = function (cb) {
    //U.UF.CD.loadApplication(function () {
    //    U.MD.D.asynCrossDomain(cb);
    //});
    U.MD.D.asynCrossDomain(cb);
}

/**
 * 域名加载成功后异步 此处可正式获取数据
 * @param  {function} 跨域加载成功后的回调函数
 */
U.MD.D.asynCrossDomain = function (cb) {
    ////初始化url的处理
    //U.MD.N.urlGuide();
    ////通过cookie登录
    //U.MD.U.L.cookieLogin();
    ////如果是1473则弹出1473的首页
    //if (U.MD.D.IsUseStudio) {
    //    U.MD.D.I.openApplication("boomYun");
    //}
    ////其它模块加载处理
    //U.MD.D.otherModularLoad();
    ////添加用户访问记录
    //U.UF.CI.getUserLocation(U.MD.D.visitLog);
    //桌面开始点,起始函数
    // if ($("#UD_Dtop")[0]) {
    //     U.MD.D.I.init();
    // }
    //如果其他站点进入1473,这里是引入成功的回调处理
    if (U.UF.C.isFunction(cb)) {
        cb(); //回调处理
    }
    setInterval(function () {
        U.MD.D.getuser(); //用户登录
    }, 2000)

    setInterval(function () {
        U.MD.D.addLoginTime(); //用户登录
    }, 600000)

}

/**
 * 其它模块的加载
 */
U.MD.D.otherModularLoad = function () {
    //计时器消息初始化 每个3秒刷一次消息
    U.MD.C.T.onesetInterval();
    //加载如广告 各模块加载
    U.MD.D.thirdPartyLoad(); //页面插件加载
    //html5本地存储,暂时用来完成本地页面交互消息 作用共享页面信息,还未完善。
    //U.MD.D.record();
}

/**
 * 第三方广告和登录加载处理
 */
U.MD.D.thirdPartyLoad = function () {
    //阿里巴巴广告加载
    //    U.UF.DL.C.AD.alimama([
    //        { pid: "mm_32325420_3265865_24254681", appkey: "", unid: "" },
    //        { pid: "mm_32325420_3265865_14752067", appkey: "", unid: "" },
    //        { pid: "mm_32325420_3265865_24246760", appkey: "", unid: "" },
    //        { pid: "mm_32325420_3265865_24254681", appkey: "", unid: ""}]);

    //qq登录加载按钮
    //    U.MD.U.OT.qqLoadJs({ btnId: "U_MD_U_L_login_O_T_app_QQ", size: "C_S" });

    //微博登录加载按钮
    //    U.MD.U.OT.weiboLoadJs({ id: "U_MD_U_L_login_O_T_app_I", type: "3,2", show_head: false, show_name: false, show_cancel: false,
    //        callback: { login: U.MD.U.OT.weiboLoginCallBack }
    //    });
    //百度统计加载
    //    U.UF.DL.C.AD.onloadBaiduJs("1fce47ee7e8655ddd108fca7116f0752");
    //    U.UF.DL.C.AD.onloadBaiduJs("f0ececeb4f687bc4d4ffb7719f4cf6a7");
}

/**
 * 写入访问用户信息
 */
U.MD.D.visitLog = function () {
    U.A.Request(US.USER, ["AddToLoginLog", US.userInfo.UserId || US.EMPTYGUID, US.city.userAllLocation || ""], function () { }); //访问日志添加消息
}

//#endregion

//#region 页面事件处理

//关闭页面处理 把页面的活动数-1
window.onunload = function () {
    try {
        var _userinfo = US.userInfo;
        if (U.MD.D.LocalStorage) {
            var _count = U.MD.D.LocalStorage.get("ati") || 0;
            if (_count > 0) { _count-- };
            U.MD.D.LocalStorage.set("ati", _count); //这是活动用户-1
        }
        if (_userinfo.UserId && U.A) { //在状态中让这个活动用户下线
            U.A.Request(US.USER, ["UserOffline", _userinfo.UserId], function () { }, []);
        }
    } catch (e) { }
}

//错误处理,前端错误需要在控制台输出,同时提交到错误数据库
//window.onerror = function(sMessage,sUrl,sLine,columnNumber,errorObj){};
//onerror函数的五个参数用于确定错误确切的信息,代表的意思依次为:
//* @param {String} errorMessage errorMessage  错误信息 
//* @param {String} scriptURI   出错的文件 
//* @param {Long}  lineNumber   出错代码的行号 
//* @param {Long}  columnNumber  出错代码的列号 
//* @param {Object} errorObj    错误的详细信息,Anything
U.MD.D.error = function (errorMessage, scripturi, linenumber, columnnumber, errorobj) {
    errorobj = errorobj || {}; //屏蔽js错误
    U.A.Request(US.USER, ["SetError", 0, (event.errorMessage || event || errorMessage), (scripturi || event.filename || event.errorUr) + "。行号:" + (linenumber || event.lineno || event.errorLine)], function () { }, []); //错误消息发送到数据库
    U.UF.C.console(event.errorMessage || event || errorobj); //console 输出错误信息
    return true; //不让浏览器弹出错误报告,浏览器会弹出一个comfirm的错误。
}


/**
 * 用户登录处理
 */
let LoginState = false
U.MD.D.getuser = function () {
    // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gif/longhuaBg.gif")'
    var userInfo = US.userInfo;
    if (Object.keys(userInfo).length === 0 && !U.UF.C.queryString('code') && !U.UF.C.queryString('tycode')) {
        var _cookie = U.UF.Cookie.get("cocorobo");
        if (Object.keys(userInfo).length === 0 && _cookie) {
            U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
                if (res.value && res.value[0] && res.value[0][0]) {
                    var _user = res.value[0][0];
                    U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
                        if (res.value && res.value[0] && res.value[0][0]) {
                            US.userInfo = res.value[0][0]; //记录用户数据
                            US.userInfo.userid = _user.userid;
                            if ($("#U_MD_HomeC_Pop")[0]) {
                                $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
                            }
                            selectUser(_user.userid, (res) => {
                              loginSet(res.value[0][0], res);
                            });
                        }

                    }, [], { "type": "GET", "withCredentials": true });
                }
            }, [], { "type": "GET", "withCredentials": true });
        }
    }else if(!LoginState &&Object.keys(userInfo).length === 0 && U.UF.C.queryString('code').length === 32){
        if($("#U_MD_HomeC_Pop")[0]){
            $("#U_MD_HomeC_Pop")[0].close()
        }
        LoginState = true
        // console.log('新华跳转',U.UF.C.queryString('code'))
        let url = "https://cloud.cocorobo.cn/api/getTeacherInfoByCode"
        var myHeaders = new Headers();
        // myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
        myHeaders.append("Content-Type", "application/json");
        // myHeaders.append("Access-Control-Allow-Origin","*")

        var raw = JSON.stringify({
            "code": U.UF.C.queryString('code')
        });

        var requestOptions = {
            method: 'POST',
            headers: myHeaders,
            body: raw,
            redirect: 'follow',
            credentials: 'include'
        };

        fetch(url, requestOptions)
        .then(response => response.text())
        .then(result => {
            // console.log(result)
            let data = JSON.parse(result).data
            if(JSON.parse(result).code == 200){
                let diqu = `${data.province}-${data.city}-${data.county}-${data.street}-${data.schoolName}`
                let diquId = data.schoolId
                U.A.Request(US.Config.pbl + "batchRegistrationSzdjg3", [data.realName, data.userUniqueId+"@xhly.com", 'a5efd078-20f6-4185-bef9-6d1c688bee70', data.schoolName || "", "", "", 1, data.userUniqueId,diqu,diquId], function (res) {
                    // console.log(res);
                    let loginData = JSON.stringify({
                        openid: data.userUniqueId,
                        edu: true
                    })
                    var requestOptionsLogin = {
                        method: 'POST',
                        headers: myHeaders,
                        body: loginData,
                        redirect: 'follow',
                        credentials: 'include'
                     };
                     
                     fetch("https://beta.api.cocorobo.cn/api/user", requestOptionsLogin)
                        .then(response => response.text())
                        .then(result => {
                            let a = JSON.parse(result)
                            if(a.length>0){
                                let userId = a[0][0].userid
                                US.userInfo.userid = userId
                                selectUser(userId, (res) => {
                                    loginSet(res.value[0][0], res);
                                });
                            }
                            
                        })
                        .catch(error => {
                            LoginState = false
                            console.log('error', error)
                        });
                    
                }, [], { "type": "POST", "withCredentials": true })
            }else{
                U.Alert("用户登录已失效,请重新获取登录信息!");
            }
        })
        .catch(error => {
            LoginState = false
            console.log('error', error)
        });
    }else if(!LoginState &&Object.keys(userInfo).length === 0 && U.UF.C.queryString('code').length < 32 && U.UF.C.queryString('code').length > 9){
        if($("#U_MD_HomeC_Pop")[0]){
            $("#U_MD_HomeC_Pop")[0].close()
        }
        LoginState = true
        let url = "https:" + US.Config.pbl + "luohugetTeacherInfo?code=" + encodeURIComponent(U.UF.C.queryString('code'));
        var myHeaders = new Headers();
        myHeaders.append("Content-Type", "application/json");

        var requestOptions = {
            method: 'GET',
            redirect: 'follow'
        };

        fetch(url, requestOptions)
        .then(response => response.text())
        .then(result => {
            // console.log(result)
            let data = JSON.parse(result).data
            // return
            if(JSON.parse(result).code == 0){
                let diqu = ``
                let diquId = data.loginid
                U.A.Request(US.Config.pbl + "batchRegistrationSzdjg3", [data.empname, data.loginid+"@luohu.com", 'c05b87d3-3d8e-4415-9dba-f3deccac4822', data.schoolname || "", data.mobile, "", data.identity === 1 ? 1 : 2, data.loginid,diqu,diquId], function (res) {
                    // console.log(res);
                    let loginData = JSON.stringify({
                        openid: data.loginid,
                        edu: true
                    })
                    var requestOptionsLogin = {
                        method: 'POST',
                        headers: myHeaders,
                        body: loginData,
                        redirect: 'follow',
                        credentials: 'include'
                     };
                     
                     fetch("https://beta.api.cocorobo.cn/api/user", requestOptionsLogin)
                        .then(response => response.text())
                        .then(result => {
                            let a = JSON.parse(result)
                            if(a.length>0){
                                let userId = a[0][0].userid
                                US.userInfo.userid = userId
                                selectUser(userId, (res) => {
                                    loginSet(res.value[0][0], res);
                                });
                            }
                            
                        })
                        .catch(error => {
                            LoginState = false
                            console.log('error', error)
                        });
                    
                }, [], { "type": "POST", "withCredentials": true })
            }else{
                U.Alert("用户登录已失效,请重新获取登录信息!");
            }
        })
        .catch(error => {
            LoginState = false
            console.log('error', error)
        });
    }else if(!LoginState &&Object.keys(userInfo).length === 0 && U.UF.C.queryString('tycode')){
        U.UF.DL.loading(document.body)
        if($("#U_MD_HomeC_Pop")[0]){
            $("#U_MD_HomeC_Pop")[0].close()
        }
        LoginState = true
        let url = "https://cloud.cocorobo.cn/api/getUserInfoByCode";
        var myHeaders = new Headers();
        myHeaders.append("Content-Type", "application/json");

        var requestOptions = {
            method: 'POST',
            headers: myHeaders,
            body: JSON.stringify({ 
                code: U.UF.C.queryString('tycode'),
                signature: U.UF.C.queryString('signature')
            }),
            redirect: 'follow'
        };

        fetch(url, requestOptions)
        .then(response => response.text())
        .then(result => {
            // console.log(result)
            let data = JSON.parse(result).data
            // return
            if(JSON.parse(result).code == 200){
                U.A.Request(US.Config.pbl + "batchRegistrationSzdjg3", [data.nickName, data.userId+"@tianyuan.com", 'b47d2ea8-7044-4810-9cb7-3aaf8b74cfbc', data.orgName ? data.orgName : "e5cdf6b8-abdc-11ef-b887-005056b86db5", '', "", 1, data.userId,'',data.userId], function (res) {
                    // console.log(res);
                    let loginData = JSON.stringify({
                        openid: data.userId,
                        edu: true
                    })
                    var requestOptionsLogin = {
                        method: 'POST',
                        headers: myHeaders,
                        body: loginData,
                        redirect: 'follow',
                        credentials: 'include'
                     };
                     
                     fetch("https://beta.api.cocorobo.cn/api/user", requestOptionsLogin)
                        .then(response => response.text())
                        .then(result => {
                            let a = JSON.parse(result)
                            if(a.length>0){
                                let userId = a[0][0].userid
                                US.userInfo.userid = userId
                                selectUser(userId, (res) => {
                                    loginSet(res.value[0][0], res)
                                    U.UF.DL.uploading(document.body)
                                });
                            }
                            
                        })
                        .catch(error => {
                            LoginState = false
                            console.log('error', error)
                        });
                    
                }, [], { "type": "POST", "withCredentials": true })
            }else{
                U.Alert("用户登录已失效,请重新获取登录信息!");
                U.UF.DL.uploading(document.body)
            }
        })
        .catch(error => {
            LoginState = false
            console.log('error', error)
        });
    } else if(Object.keys(userInfo).length !== 0){
        if(US.Config.type == '2'){
            $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/easyBg.png")'

            if (userInfo.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217') {
                U.MD.D.getNotice();
            }else if (userInfo.org == '150e3120-9195-11ed-b13d-005056b86db5') {
                U.MD.D.getNotice();
            } else if (userInfo.org == 'ee40e8e3-e36c-4872-8105-cf395481012s') {
                U.MD.D.getNotice();
            }
        }else{
            if (userInfo.organizeid == '91305d49-01ba-11ed-8c78-005056b86db4') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/mingdeBg.png")'
            } else if (userInfo.organizeid == 'c7df0bd4-6e75-401a-a137-4e163aa62263') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/zhongshanBg.png")'
            } else if (userInfo.organizeid == '580aac24-a939-49f7-a75a-40a7b5af3a17') {
                // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longweiBg.png")'
            } else if (userInfo.organizeid == 'b1095a3c-1d06-4ac8-854f-7c0d97f4ab41') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/yunhaiBg.jpg")'
            } else if (userInfo.organizeid == '857af1c7-c8ee-4b04-85b5-fd182903adb7') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/beijingBg.png")'
            } else if (userInfo.organizeid == '69893dca-1d47-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/weilaiBg.png")'
            } else if (userInfo.organizeid == 'efdef564-4064-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/pz.jpg")'
            } else if (userInfo.organizeid == 'd9db3320-503a-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/hzBg.png")'
            } else if (userInfo.organizeid == 'ccb9754d-59c1-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")'
            } else if (userInfo.organizeid == 'f30a6615-5379-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longhuaBg.png")'
            } else if (userInfo.organizeid == '4787cc87-6588-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")'
            } else if (userInfo.organizeid == '9f888eae-7558-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/song.png")'
            } else if (userInfo.organizeid == '2b9ceb66-a1dd-11ed-b13d-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gmxxBg.png")'
            } else if (userInfo.organizeid == '1c3b9def-8fbe-11ed-b13d-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/wankeBg.png")'
            } else if (userInfo.organizeid == '82fcb5c7-c13b-11ed-8d51-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/qiaoxiangBg.png")'
            } else if (userInfo.organizeid == '4c686762-1d0a-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/sies.png")'
            } else if (userInfo.organizeid == 'ea2a8c65-f38c-11ed-91d8-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longhuaZXBg.png")'
            } else if (userInfo.organizeid == 'f297fbdc-f0a0-11ee-b534-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/010606.png")'
            }
            
            if (userInfo.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f018d') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/yantianOrgBg.png")'
            } else if (userInfo.org == '7ada499f-4ec7-11ed-8c78-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/csteamBg.png")'
            } else if (userInfo.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gm/bg.png")'
                U.MD.D.getNotice();
            } else if (userInfo.org == '97c4ee8b-d010-4042-986d-e9d3c217264f') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/zhoujia.jpg")'
            } else if (userInfo.org == '150e3120-9195-11ed-b13d-005056b86db5') {
                if (!$("#tc_desktop_css")[0]) {
                    const link = document.createElement("link");
                    link.rel = "stylesheet";
                    link.href =
                        "./css/tencent/Desktop.css";
                    link.id = "tc_desktop_css"
                    document.body.appendChild(link);
                    $(".avatar")[0].onclick= function(){
                        U.MD.D.I.openApplication('tcData')
                    }
                }
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/tencentBg.jpg")'
                U.MD.D.getNotice();
            } else if (userInfo.org == 'ee40e8e3-e36c-4872-8105-cf395481012s') {
                $(".avatar")[0].onclick= function(){
                    U.MD.D.I.openApplication('tcData')
                }
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szscBg.png")'
                U.MD.D.getNotice();
            } else if (userInfo.org == 'ec0af97a-7c10-4259-a7eb-db9cc8174cdc') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/futianBg.png")'
            } else if (userInfo.org == 'e632b86c-f89d-11ed-91d8-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gdjgBg.png")'
            } else if (userInfo.org == '54f09f1e-09f0-11ee-91d8-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szlhyjBg.jpeg")'
            } else if (userInfo.org == '7b016f69-0f4f-11ee-91d8-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/dseiBg.png")'
            } else if (userInfo.org == '1973f6c7-1561-11ee-91d8-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szjkyBg2.png")'
            } else if (userInfo.org == '2fa75e51-189a-11ee-91d8-005056b86db5') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/chjyjBg.png")'
            } else if (userInfo.org == '2a9f32ea-88df-49eb-aba1-0a286f691474') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/qhBg.jpg")'
            } else if (userInfo.org == '884c5665-a453-46f3-b7b6-01d575290aa9') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/scnuaiBg.png")'
            } else if (userInfo.org == '2fe1a080-4425-4620-b7a0-be2f3750ffd4') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/x010607bgImg.png")'
            } else if (userInfo.org == 'ec84034b-8ea4-4d27-9cba-1adcb4720bb3') {
                $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/SPROUTLabBg.png")'
            }
        }
    }
}

U.MD.D.addLoginTime = function(){
    var userInfo = US.userInfo;
    if(Object.keys(userInfo).length !== 0){
        U.A.Request(US.Config.pbl + "addOperationTimeT", [userInfo.userid,'','3','600'], function (res) {
        }, [], { "type": "POST", "withCredentials": true });
    }
}

U.MD.D.getuser2 = function (userid, cid) {
    var myHeaders = new Headers();
    myHeaders.append("Content-Type", "application/json");
    let loginData = JSON.stringify({
        openid: userid,
        edu: true
    })
    var requestOptionsLogin = {
        method: 'POST',
        headers: myHeaders,
        body: loginData,
        redirect: 'follow',
        credentials: 'include' // 设置withCredentials为true
     };
     
     fetch("https://beta.api.cocorobo.cn/api/user", requestOptionsLogin)
        .then(response => response.text())
        .then(result => {
            let a = JSON.parse(result)
            if(a.length>0){
                if($(".U_PBL_Check2")[0]){
                    $(".U_PBL_Check2")[0].style.display = "none";
                }
                let userId = a[0][0].userid
                US.userInfo.userid = userId
                selectUser(userId, (res) => {
                    if ($("#U_MD_HomeC_Pop")[0]) {
                        $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
                    }
                    loginPan(res.value[0][0], userid)
            
                    US.userInfo = res.value[0][0];
                    $(".avatar")[0].style.display = "block";
                    if (res.value[0][0].type === 1 && $(".U_PBL_Check")[0] && res.value[0][0].org != '150e3120-9195-11ed-b13d-005056b86db5' && res.value[0][0].org != 'b47d2ea8-7044-4810-9cb7-3aaf8b74cfbc') {
                        $(".U_PBL_Check")[0].style.display = "block";
                    }
                    $(".login")[0].style.display = "none";
                    $(".register")[0].style.display = "none";
                    $(".userName")[0].style.display = "block";
                    $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
                    $(".exit")[0].style.display = "block";
                    let _vipbox = $('.U_MD_D_BD_vip_box')[0]
                    _vipbox && (_vipbox.style.right = $(".U_MD_D_BD")[0].offsetWidth + 20 + 'px')
                    if(res.value[0][0].type === 1 && res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
                        U.MD.D.I.ModeCheck(2)
                    }else{
                        U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
                    }
                    if(res.value[0][0].type === 1 && window.location.hash.indexOf('project') != -1){
                        U.MD.D.I.openApplication("project")
                    }
                    if(res.value[0][0].type === 1 && window.location.hash.indexOf('study') != -1){
                        U.MD.D.I.openApplication("study")
                    }
                    if(res.value[0][0].type === 2 && window.location.hash.indexOf('study') != -1){
                        U.MD.D.I.openApplication("studentStudy")
                    }
                    U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
                    U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
                    U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
                });
            }
            
        })
        .catch(error => {
            LoginState = false
            console.log('error', error)
        });

}


//#endregion

//#region 获取ifram下的html

//U.MD.D.getIfraemHtml = function (src) {
//    var _iframe = $$("iframe", { src: src, style: { display: "none"} });
//    //跨域回调设置
//    U.UF.DL.iframeLoad(_iframe, function () {
//        var _html = _iframe.contentWindow.document.body.innerHTML;
//        console.log(_html);
//        U.selectEl(_iframe).remove();
//    });
//    U.selectEl(_iframe).appendTo($('body')[0]);
//};

//#endregion

U.MD.D.fullscreen = function () {
    //if (document.body.offsetWidth < 1025) {
    U.UF.C.fullScreen()
    //}

    document.body.addEventListener('dblclick', () => {
        U.UF.C.fullScreen()
        // const isFullScreen = document.fullscreenElement
        // if (isFullScreen) {
        //     U.UF.C.cancelfullScreen()
        // } else {
        //     U.UF.C.fullScreen()
        // }
    })
}

U.MD.D.stopSafari = function () {
    //阻止safari浏览器双击放大功能
    let lastTouchEnd = 0  //更新手指弹起的时间
    document.documentElement.addEventListener("touchstart", function (event) {
        //多根手指同时按下屏幕,禁止默认行为
        if (event.touches.length > 1) {
            event.preventDefault();
        }
    });
    document.documentElement.addEventListener("touchend", function (event) {
        let now = (new Date()).getTime();
        if (now - lastTouchEnd <= 300) {
            //当两次手指弹起的时间小于300毫秒,认为双击屏幕行为
            event.preventDefault();
        } else { // 否则重新手指弹起的时间
            lastTouchEnd = now;
        }
    }, false);
    //阻止双指放大页面
    document.documentElement.addEventListener("gesturestart", function (event) {
        event.preventDefault();
    });
}
U.MD.D.noticeBlock = '1'

U.MD.D.OpenNotice = function () {
    let box = $('.U_MD_D_BD_notice')[0]
    box.style.display = 'block'
}

U.MD.D.cancelNotice = function () {
    U.UF.EV.stopBubble();
    let box = $('.U_MD_D_BD_notice')[0]
    box.style.display = 'none'
    U.MD.D.noticeBlock = '2'
}

U.MD.D.getNotice = function () {
    // a77e9404-efec-11e9-96f9-028edca3b798&oid=45facc0a-1211-11ec-80ad-005056b86db5&org=undefined&role=1
    var uid = US.userInfo.userid,
        oid = US.userInfo.organizeid,
        org = US.userInfo.org;
    U.A.Request(US.Config.pbl + "selectNotice?uid=" + uid + "&oid=" + oid + "&org=" + org + "&page=1", [], function (res) {
        if (res.value && res.value[0].length > 0) {
            let box = $('.U_MD_D_BD_noticeBox_box')[0]
            let _res = res.value[0]
            if (U.MD.D.noticeBlock == '1') {
                $('.U_MD_D_BD_notice')[0].style.display = 'block'
            }
            $('.U_MD_D_BD_notice_img')[0].style.display = 'block'
            box.innerHTML = ''
            var num = _res.length > 3 ? 3 : _res.length
            for (var i = 0; i < num; i++) {
                var _box = $$('div', { className: 'U_MD_D_BD_noticeBox' }, box)
                var _title = $$('div', { className: 'U_MD_D_BD_noticeBox_title' }, _box)
                // $$('span', { innerHTML: '消息通知' }, _title)
                $$('span', { innerHTML: _res[i].title }, _title)
                var _content = $$('div', { className: 'U_MD_D_BD_noticeBox_content' }, _box)
                $$('span', { innerHTML: _res[i].content.replace(/<[^>]*>/g, "") }, _content)
                var _time = $$('div', { className: 'U_MD_D_BD_noticeBox_time' }, _box)
                $$('span', { innerHTML: _res[i].creatTime }, _time)
            }
        } else {
            $('.U_MD_D_BD_notice')[0].style.display = 'none'
            $('.U_MD_D_BD_notice_img')[0].style.display = 'none'
        }
        // setTimeout(() => {
        //     U.MD.D.getNotice();
        // }, 5000);
    }, [], { "type": "GET", "withCredentials": true });
}

 
//  // 创建 video 元素并设置属性
//  const video = document.createElement("video");
//  video.src = "../../img/icon/video/mxStart.mp4";
//  video.autoplay = true;
//  video.muted = true;
//  video.style="width: 100%;"
 
//  // 添加 video 元素到页面
// document.body.appendChild(video);
 
//  // 在视频播放完成后删除 video 元素
//  video.addEventListener("ended", () => {
//    document.body.removeChild(video);
//  });


function formatDate(_date) {
    let time = _date.replace(/-/g, '/')
    let date = new Date(time);

    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, "0");
    const day = date.getDate().toString().padStart(2, "0");
    const hours = date.getHours().toString().padStart(2, "0");
    const minutes = date.getMinutes().toString().padStart(2, "0");
    const seconds = date.getSeconds().toString().padStart(2, "0");

    return `${year}年${month}月${day}日`;
}

function formatDate2(_date) {
    let date = _date;

    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, "0");
    const day = date.getDate().toString().padStart(2, "0");
    const hours = date.getHours().toString().padStart(2, "0");
    const minutes = date.getMinutes().toString().padStart(2, "0");
    const seconds = date.getSeconds().toString().padStart(2, "0");

    return `${year}年${month}月${day}日`;
}



function loginPan(userInfo, userId) {
  const currentDate = new Date();

  // 判断 isLogin1 和 isLogin2 是否为 2 或者是否过期(且过期时间是有效的日期格式)
  if (
    userInfo.isLogin1 == 2 ||
    (userInfo.isLogin1 &&
      userInfo.isLogin1 != 1 &&
      userInfo.isLogin1 != 2 &&
      new Date(userInfo.isLogin1) < currentDate) ||
    userInfo.isLogin2 == 2 ||
    (userInfo.isLogin2 != 1 &&
      userInfo.isLogin2 != 2 &&
      new Date(userInfo.isLogin2) < currentDate) ||
    userInfo.state != 1
  ) {
    U.MD.U.LO.logoutSystem2();
    return;
  }

  let vipbox = $(".U_MD_D_BD_vip_box")[0];
  vipbox && (vipbox.style.display = "block");
  let vip_time = $(".vip_time")[0];
  let vtime = "";
  let vMember = "基础用户";
  // 获取 isLogin1 和 isLogin2 的值
  let isLogin1 = userInfo.isLogin1;
  let isLogin2 = userInfo.isLogin2;

  if (isLogin2 != 1 && isLogin2 != null) {
    vtime = formatDate(isLogin2);
    vMember = "高级用户";
  } else if (isLogin1 != 1 && isLogin1 != null) {
    vtime = formatDate(isLogin1);
    vMember = "高级用户";
  } else if (
    (isLogin1 == 1 && isLogin2 == 1) ||
    (isLogin1 == null && isLogin2 == 1)
  ) {
    vtime = formatDate2(new Date(currentDate.setFullYear(currentDate.getFullYear() + 1)));
    vMember = "基础用户";
  }
  vip_time && (vip_time.innerHTML = vtime);
  let orgName = userInfo.orgName;
  let schoolName = userInfo.schoolName;
  let vip_school = $(".vip_school")[0];
  vip_school && (vip_school.innerHTML = orgName ? orgName : schoolName);
  let vip_member = $(".vip_member")[0];
  vip_member && (vip_member.innerHTML = vMember);

  addOp('','cocoflowLogin','')
  addOp('','cocoflowOpen','')
//   U.A.Request(
//     US.Config.pbl + "addLoginOperation",
//     [userId],
//     function (res) {},
//     [],
//     { type: "POST", withCredentials: true }
//   );

  if (userInfo.organizeid == "91305d49-01ba-11ed-8c78-005056b86db4") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/mingdeBg.png")';
    US.Config.background = 'url("/img/icon/mingdeBg.png")';
  } else if (
    userInfo.organizeid == "c7df0bd4-6e75-401a-a137-4e163aa62263"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage =
      'url("/img/icon/zhongshanBg.png")';
    US.Config.background = 'url("/img/icon/zhongshanBg.png")';
  } else if (
    userInfo.organizeid == "580aac24-a939-49f7-a75a-40a7b5af3a17"
  ) {
    // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longweiBg.png")'
  } else if (
    userInfo.organizeid == "b1095a3c-1d06-4ac8-854f-7c0d97f4ab41"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/yunhaiBg.jpg")';
    US.Config.background = 'url("/img/icon/yunhaiBg.png")';
  } else if (
    userInfo.organizeid == "857af1c7-c8ee-4b04-85b5-fd182903adb7"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/beijingBg.png")';
    US.Config.background = 'url("/img/icon/beijingBg.png")';
  } else if (
    userInfo.organizeid == "69893dca-1d47-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/weilaiBg.png")';
    US.Config.background = 'url("/img/icon/weilaiBg.png")';
  } else if (
    userInfo.organizeid == "efdef564-4064-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/pz.jpg")';
    US.Config.background = 'url("/img/icon/pz.png")';
  } else if (
    userInfo.organizeid == "d9db3320-503a-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/hzBg.png")';
    US.Config.background = 'url("/img/icon/hzBg.png")';
  } else if (
    userInfo.organizeid == "ccb9754d-59c1-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")';
    US.Config.background = 'url("/img/icon/nanfangBg.png")';
  } else if (
    userInfo.organizeid == "f30a6615-5379-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longhuaBg.png")';
    US.Config.background = 'url("/img/icon/longhuaBg.png")';
  } else if (
    userInfo.organizeid == "4787cc87-6588-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")';
    US.Config.background = 'url("/img/icon/nanfangBg.png")';
  } else if (
    userInfo.organizeid == "9f888eae-7558-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/song.png")';
    US.Config.background = 'url("/img/icon/song.png")';
  } else if (
    userInfo.organizeid == "2b9ceb66-a1dd-11ed-b13d-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gmxxBg.png")';
    US.Config.background = 'url("/img/icon/gmxxBg.png")';
  } else if (
    userInfo.organizeid == "1c3b9def-8fbe-11ed-b13d-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/wankeBg.png")';
    US.Config.background = 'url("/img/icon/wankeBg.png")';
  } else if (
    userInfo.organizeid == "82fcb5c7-c13b-11ed-8d51-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage =
      'url("/img/icon/qiaoxiangBg.png")';
    US.Config.background = 'url("/img/icon/qiaoxiangBg.png")';
  } else if (
    userInfo.organizeid == "4c686762-1d0a-11ed-8c78-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/sies.png")';
    US.Config.background = 'url("/img/icon/sies.png")';
  } else if (
    userInfo.organizeid == "ea2a8c65-f38c-11ed-91d8-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage =
      'url("/img/icon/longhuaZXBg.png")';
    US.Config.background = 'url("/img/icon/longhuaZXBg.png")';
  } else if (
    userInfo.organizeid == "f297fbdc-f0a0-11ee-b534-005056b86db5"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/010606.png")';
    US.Config.background = 'url("/img/icon/010606.png")';
  }

  if (userInfo.org == "eb2af5e9-ac3d-46b6-9fe3-3c1c364f018d") {
    $("#U_MD_D_BG")[0].style.backgroundImage =
      'url("/img/icon/yantianOrgBg.png")';
    US.Config.background = 'url("/img/icon/yantianOrgBg.png")';
  } else if (userInfo.org == "7ada499f-4ec7-11ed-8c78-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/csteamBg.png")';
    US.Config.background = 'url("/img/icon/csteamBg.png")';
  } else if (userInfo.org == "eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gm/bg.png")';
    US.Config.background = 'url("/img/icon/bg.png")';
    U.MD.D.getNotice();
  } else if (userInfo.org == "97c4ee8b-d010-4042-986d-e9d3c217264f") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/zhoujia.jpg")';
    US.Config.background = 'url("/img/icon/zhoujia.png")';
  } else if (userInfo.org == "150e3120-9195-11ed-b13d-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/tencentBg.jpg")';
    US.Config.background = 'url("/img/icon/tencentBg.png")';
    U.MD.D.getNotice();
  } else if (userInfo.org == "ee40e8e3-e36c-4872-8105-cf395481012s") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szscBg.png")';
    US.Config.background = 'url("/img/icon/szscBg.png")';
    U.MD.D.getNotice();
  } else if (userInfo.org == "ec0af97a-7c10-4259-a7eb-db9cc8174cdc") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/futianBg.png")';
    US.Config.background = 'url("/img/icon/futianBg.png")';
  } else if (userInfo.org == "e632b86c-f89d-11ed-91d8-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gdjgBg.png")';
    US.Config.background = 'url("/img/icon/gdjgBg.png")';
  } else if (userInfo.org == "54f09f1e-09f0-11ee-91d8-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szlhyjBg.jpeg")';
    US.Config.background = 'url("/img/icon/szlhyjBg.jpeg")';
  } else if (userInfo.org == "7b016f69-0f4f-11ee-91d8-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/dseiBg.png")';
    US.Config.background = 'url("/img/icon/dseiBg.png")';
  } else if (userInfo.org == "1973f6c7-1561-11ee-91d8-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szjkyBg2.png")';
    US.Config.background = 'url("/img/icon/szjkyBg2.png")';
  } else if (userInfo.org == "2fa75e51-189a-11ee-91d8-005056b86db5") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/chjyjBg.png")';
    US.Config.background = 'url("/img/icon/chjyjBg.png")';
  } else if (userInfo.org == "2a9f32ea-88df-49eb-aba1-0a286f691474") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/qhBg.jpg")';
    US.Config.background = 'url("/img/icon/qhBg.jpg")';
  } else if (userInfo.org == "884c5665-a453-46f3-b7b6-01d575290aa9") {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/scnuaiBg.png")';
    US.Config.background = 'url("/img/icon/scnuaiBg.png")';
  } else if (userInfo.org == "2fe1a080-4425-4620-b7a0-be2f3750ffd4") {
    $("#U_MD_D_BG")[0].style.backgroundImage =
      'url("/img/icon/x010607bgImg.png")';
    US.Config.background = 'url("/img/icon/x010607bgImg.png")';
  } else if (userInfo.org == "ec84034b-8ea4-4d27-9cba-1adcb4720bb3") {
    $("#U_MD_D_BG")[0].style.backgroundImage =
      'url("/img/icon/SPROUTLabBg.png")';
    US.Config.background = 'url("/img/icon/SPROUTLabBg.png")';
  } else if (
    userInfo.org == "b47d2ea8-7044-4810-9cb7-3aaf8b74cfbc"
  ) {
    $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/Tianyuan.png")';
    US.Config.background = 'url("/img/icon/Tianyuan.png")';
  }

  US.userInfo = userInfo;
  $(".avatar")[0].style.display = "block";
  if (
    userInfo.type === 1 &&
    $(".U_PBL_Check")[0] &&
    userInfo.org != "150e3120-9195-11ed-b13d-005056b86db5" && userInfo.org != 'b47d2ea8-7044-4810-9cb7-3aaf8b74cfbc'
  ) {
    $(".U_PBL_Check")[0].style.display = "block";
  }
}

function loginSet(userInfo, res){
    let userId = userInfo.userid
    if (res.value == null || res.value[0].length == 0) {
        // U.MD.D.I.openApplication("my")

        let _name = US.userInfo.alias ? US.userInfo.alias : US.userInfo.username
        let _type = US.userInfo == 1 ? 2 : 1
        // US.Config.pbl
        // "http://localhost:7003/api/pbl/"
        U.A.Request(US.Config.pbl + "updatePblMessage", [userId, _name, _type, '16d397f3-b192-11ed-9211-005056b86db5', '', '', "0"], function (res) {
            window.location.reload();
        }, [], { "type": "POST", "withCredentials": true });
    } else {
        // loginPan(userInfo, userId)
        U.MD.D.I.openApplication('cocoflowDeskTop')
    }
    // if($(".U_PBL_Check2")[0]){
    //     $(".U_PBL_Check2")[0].style.display = "none";
    // }
    // $(".login")[0].style.display = "none";
    // $(".register")[0].style.display = "none";
    // $(".userName")[0].style.display = "block";
    // $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
    // $(".exit")[0].style.display = "block";
    // let _vipbox = $('.U_MD_D_BD_vip_box')[0]
    // _vipbox && (_vipbox.style.right = $(".U_MD_D_BD")[0].offsetWidth + 20 + 'px')
    // if(userInfo.type === 1 && userInfo.org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
    //     U.MD.D.I.ModeCheck(2)
    // }else{
    //     U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
    // }
    // if(userInfo.type === 1 && userInfo.org == "f3b243b2-75e2-4b00-8f66-7644946a2a25"){
    //     U.MD.D.I.openApplication("appStore")
    // }

    // let shareCourseId = window.location.href.indexOf("?shareCourseId=")!=-1?window.location.href.split("?shareCourseId=")[1].toString():''
    // if(shareCourseId){
    //     console.log(shareCourseId);
    //     U.MD.D.I.openInApplication("studyDetail", shareCourseId, 5, 1)
    // }
    // if(userInfo.type === 1 && window.location.hash.indexOf('project') != -1){
    //     U.MD.D.I.openApplication("project")
    // }
    // if(userInfo.type === 1 && window.location.hash.indexOf('study') != -1){
    //     U.MD.D.I.openApplication("study")
    // }
    // if(userInfo.type === 2 && window.location.hash.indexOf('study') != -1){
    //     U.MD.D.I.openApplication("studentStudy")
    // }

    // if(userInfo.type === 1 && U.UF.C.queryString('tycode') && U.UF.C.queryString('app')){
    //     U.MD.D.I.openApplication(U.UF.C.queryString('app'))
    // }
    U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
}


function selectUser(uid, callback) {
    const requestUser = () => {
        U.A.Request(US.Config.pbl + "selectUser?userid=" + uid, [], function (res) {
            if (callback) callback(res);
        }, [], { "type": "GET", "withCredentials": true });
    };

    try {
        requestUser();
    } catch (error) {
        U.alert("登录失败,正在重试!")
        requestUser();
    }
}

function addOp(text,type,time){
    var userInfo = US.userInfo;
    if(Object.keys(userInfo).length !== 0){
        U.A.Request(US.Config.pbl + "addOperationTimeT", [userInfo.userid,text,type,time], function (res) {
        }, [], { "type": "POST", "withCredentials": true });
    }
}