Onload.js 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. //------------------------------------------------------------------------------------用戶桌面和程序數據初始化區域----------------------------------------------------------------------------------------------------------------
  2. Namespace.register("U.MD.D"); //桌面onload和桌面總控的命名空間
  3. /*
  4. window.onload的流程:
  5. 1、自由屬性的設置,例如:頁面識別id。允許瀏覽器多頁面瀏覽www.1473.cn
  6. 2、加載各種事件綁定,如:頁面大小監視,不允許選擇桌面文字,ie7以下瀏覽器頁面提示
  7. 3、加載桌面圖標。
  8. 4、加載跨域設置,如果沒有跨域,首頁數據無法獲取
  9. 4、加載首頁
  10. 5、加載廣告,QQ登錄等外鏈。
  11. UD和UC區別 uc是框架函數 ud為操作系統原殼 這裏的簡化的目標很簡單 只要有人應用ud 就會引用一個web操作系統 提供操作系統的功能應用
  12. 難題 :
  13. 1、命名和用戶沖突 會導致原web系統不可使用
  14. 2、函數沖突 如 用戶自帶window.resize這樣的函數 我們提供了接口 但是這個接口的的暴露性可見性體現出文檔的重要 宣傳文檔也就是文宣的重要性高了
  15. 3、有參數註釋的都為暴露接口類型 其他都為內部使用 更好的體現方式
  16. */
  17. //#region 配置區域,相當於全局變量定義
  18. U.MD.D.IsUseStudio = true;
  19. //本地存儲類
  20. U.MD.D.LocalStorage = null;
  21. //#endregion
  22. //#region onload處理
  23. /**
  24. * 系統初始化處理
  25. *
  26. * @param {function} 在外部項目應用該項目的時候 可以傳入cb這個參數,如果傳入了這個參數在回調跨域main.1473.cn加載成功會就會直接回調
  27. */
  28. window.onload = function () {
  29. U.MD.D.Load();
  30. U.MD.U.L.login();
  31. //U.MD.D.isLogin();
  32. // U.MD.D.fullscreen();
  33. U.MD.D.stopSafari();
  34. // window.addEventListener('resize', () => {
  35. // var realHeight = window.innerHeight
  36. // var realWidth = window.innerWidth
  37. // initViewport(realHeight, realWidth);
  38. // // window.location.reload();
  39. // })
  40. window.onbeforeunload = function (event) {
  41. // 阻止默认行为
  42. event.preventDefault();
  43. event.returnValue = '';
  44. // / 对某些浏览器有效
  45. }
  46. }
  47. US.Config = {
  48. server: '//cloud.api.cocorobo.hk/api/',
  49. api: '//cloud.api.cocorobo.hk/',
  50. chat: "//chat.api.cocorobo.cn/",
  51. edu: '//api.edu.cocorobo.cn/edu/',
  52. origin: '//cocorobo.cn',
  53. pbl: "//pbl.cocorobo.cn/api/pbl/",
  54. // bpbl:"//pbl.cocorobo.cn",//正式鏈接
  55. // bpbl:"//beta.pbl.cocorobo.cn",//測試鏈接
  56. bpbl:"//pbl.cocorobo.hk",//hk鏈接
  57. // pbl: "http://localhost:7003/api/pbl/",
  58. basename: '',
  59. type:1,
  60. background:'url("/img/icon/bgImg4.png")'
  61. }
  62. /**
  63. * 供外部調用的window.onload函數雲端系統啟動項
  64. *
  65. * @param {function} 在外部項目應用該項目的時候 可以傳入cb這個參數,如果傳入了這個參數在回調跨域main.1473.cn加載成功會就會直接回調
  66. */
  67. U.MD.D.Load = U.MD.D.FLoad = function (cb) {
  68. //這裏判斷是如果是www.1473.cn 或者 www.boomyun.com項目的時候 或者是 通過ufrom的跨域函數加載成功頁面時候可以執行window.onload, 添加判斷的目的主要是反正 其他項目引用uformd的時候自動執行window.onload報錯。
  69. //當引用雲端硬盤,好友模塊時需要在自己的js文件中添加window.onload入口函數,否則會觸發雲端的window.onload,導致系統報錯,
  70. //初始化桌面,如果是1473主站點那麼初始化桌面系統,否則外部引入1473不加載桌面
  71. //系統初始化、第一個就是加載桌面,然後初始化全局變量、綁定事件、最後加載數據(加載數據需要跨域加載,因為項目分離的原因,我們有disk.1473.cn、user.1473.cn、firend.1473.cn裏面有靜態數據,還有動態的後臺)
  72. if (U.MD.D.IsUseStudio) {
  73. //桌面初始化彈出
  74. U.selectEl("#UD_Dtop")[0].style.display = "block";
  75. //桌面做為一個置底的窗體
  76. 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" } });
  77. }
  78. //這裏加判斷的原因是怕有開發者開發的過程中直接調用uformd.js沒有寫跨域加載,沒有寫window.onload導致再運行的過程中找不到元素報錯
  79. if ($("#U_MD_Home")[0]) {
  80. //設置頁面大小等的全局變量
  81. U.MD.D.settingGlobalVariables();
  82. //瀏覽器事件監視及處理
  83. U.MD.D.addEvents();
  84. //var _browserinfo = U.UF.CI.getBrowser(); //獲取瀏覽器
  85. ////ie7以下的瀏覽器彈出不兼容的處理
  86. //if (_browserinfo["browser"] == "msie" && parseInt(_browserinfo["ver"]) < 7) {
  87. // //彈出不兼容的處理
  88. // U.MD.D.A.browserCompatibleForm();
  89. //}
  90. }
  91. //跨域加載
  92. U.MD.D.crossDomain(cb); //跨域初始化,裏面包含了用戶登錄
  93. }
  94. /**
  95. * 設置當前使用頁面大小
  96. */
  97. U.MD.D.settingGlobalVariables = function () {
  98. //獲取頁面的大小
  99. var _size = U.selectEl("body").getElementInfo();
  100. US.height = _size["CH"]; //獲取高度
  101. US.width = _size["CW"]; //獲取寬度
  102. //1473的登錄識別id
  103. US.systemId = 1;
  104. //頁面識別id 頁面唯一的識別 作為用戶訪問1473的唯一識別碼,在之前用戶獲取聊天室的信息的唯一識別碼
  105. US.pageId = Guid.newGuid();
  106. }
  107. /**
  108. * 系統監視
  109. */
  110. U.MD.D.addEvents = function () {
  111. //頁面活動狀態監視,失焦的時候停止五秒刷新,聚焦的時候開始刷新
  112. U.UF.EV.IsActivity(U.MD.D.focus, U.MD.D.blur);
  113. //監視頁面的點擊 使得窗體點擊為頂部
  114. U.UF.F.clickTopWindow();
  115. //頁面大小變化監視
  116. U.MD.D.reSize();
  117. window.onresize = U.MD.D.reSize;
  118. //如果是雲端1473則屏蔽菜單和錯誤彈框
  119. if (U.MD.D.IsUseStudio) {
  120. if (window.print) { //判斷是否有右鍵菜單
  121. document.oncontextmenu = U.UF.EV.stopDefault; //阻止桌面右鍵默認菜單
  122. }
  123. document.onselectstart = U.UF.C.shieldedSelect; //禁止文本選擇處理
  124. U.UF.EV.addElementEvent("keydown", document, U.UF.C.shieldedBackspace); //禁止瀏覽器回退
  125. //window.onerror = U.MD.D.error; //錯誤提示屏蔽
  126. }
  127. //允許錯誤提示和右鍵菜單
  128. else {
  129. window.onerror = null;
  130. }
  131. //頁面路由事件處理
  132. U.UF.N.route(U.MD.N.urlGuide);
  133. }
  134. /**
  135. * 頁面大小變化時,需要重新排列圖標及任務欄大小的變化.
  136. */
  137. U.MD.D.reSize = function () {
  138. //頁面變化處理
  139. //獲取頁面的大小
  140. // US.height = window.innerHeight > window.innerWidth ? window.innerWidth : window.innerHeight;
  141. // US.width = window.innerHeight > window.innerWidth ? window.innerHeight : window.innerWidth;
  142. var _size = U.selectEl("html").getElementInfo();
  143. if (_size["CH"] > 500) {
  144. //處理窗體區域 隨著頁面大小變化而變化
  145. U.UF.UI.form.windowResize();
  146. // var _size = U.selectEl("body").getElementInfo();
  147. US.height = _size["CH"]; //獲取高度
  148. US.width = _size["CW"]; //獲取寬度;
  149. document.body.style.width = US.width + 'px';
  150. document.body.style.height = US.height + 'px';
  151. //任務欄處理
  152. if ($("#U_MD_D_RW")) {
  153. U.selectEl("#U_MD_D_RW").css("width", US.width - 165 + "px");
  154. U.MD.D.T.taskbar.multitask($("#U_MD_D_RW")[0]);
  155. //桌面圖標處理
  156. if(US.Config.type == '1'){
  157. U.MD.D.iconPostion($("#U_MD_D_K").Child());
  158. }else{
  159. U.MD.D.iconPostion2($("#U_MD_D_K").Child());
  160. }
  161. }
  162. }
  163. }
  164. /**
  165. * 跨域引入1473
  166. * @param {function} 跨域加載成功後的回調函數
  167. */
  168. U.MD.D.crossDomain = function (cb) {
  169. U.MD.D.loadApplication(cb);
  170. ////跨域加載,如果是1473的跨域,那麼則添加跨域的iframe處理
  171. //if (document.domain == "1473.cn") {
  172. // U.UF.CD.loadAjaxCrossDomain(function () {
  173. // U.MD.D.loadApplication(cb);
  174. // });
  175. //}
  176. ////如果是非1473的跨域,添加跨域的iframe
  177. //else {
  178. // U.UF.CD.thirdPartyLoadAjaxCrossDomain(function () {
  179. // U.MD.D.loadApplication(cb);
  180. // });
  181. //}
  182. }
  183. /**
  184. * 加載user 、 friend 、disk的js
  185. */
  186. U.MD.D.loadApplication = function (cb) {
  187. //U.UF.CD.loadApplication(function () {
  188. // U.MD.D.asynCrossDomain(cb);
  189. //});
  190. U.MD.D.asynCrossDomain(cb);
  191. }
  192. /**
  193. * 域名加載成功後異步 此處可正式獲取數據
  194. * @param {function} 跨域加載成功後的回調函數
  195. */
  196. U.MD.D.asynCrossDomain = function (cb) {
  197. ////初始化url的處理
  198. //U.MD.N.urlGuide();
  199. ////通過cookie登錄
  200. //U.MD.U.L.cookieLogin();
  201. ////如果是1473則彈出1473的首頁
  202. //if (U.MD.D.IsUseStudio) {
  203. // U.MD.D.I.openApplication("boomYun");
  204. //}
  205. ////其它模塊加載處理
  206. //U.MD.D.otherModularLoad();
  207. ////添加用戶訪問記錄
  208. //U.UF.CI.getUserLocation(U.MD.D.visitLog);
  209. //桌面開始點,起始函數
  210. if ($("#UD_Dtop")[0]) {
  211. U.MD.D.I.init();
  212. }
  213. //如果其他站點進入1473,這裏是引入成功的回調處理
  214. if (U.UF.C.isFunction(cb)) {
  215. cb(); //回調處理
  216. }
  217. setInterval(function () {
  218. U.MD.D.getuser(); //用戶登錄
  219. }, 2000)
  220. setInterval(function () {
  221. U.MD.D.addLoginTime(); //用戶登錄
  222. }, 600000)
  223. }
  224. /**
  225. * 其它模塊的加載
  226. */
  227. U.MD.D.otherModularLoad = function () {
  228. //計時器消息初始化 每個3秒刷一次消息
  229. U.MD.C.T.onesetInterval();
  230. //加載如廣告 各模塊加載
  231. U.MD.D.thirdPartyLoad(); //頁面插件加載
  232. //html5本地存儲,暫時用來完成本地頁面交互消息 作用共享頁面信息,還未完善。
  233. //U.MD.D.record();
  234. }
  235. /**
  236. * 第三方廣告和登錄加載處理
  237. */
  238. U.MD.D.thirdPartyLoad = function () {
  239. //阿裏巴巴廣告加載
  240. // U.UF.DL.C.AD.alimama([
  241. // { pid: "mm_32325420_3265865_24254681", appkey: "", unid: "" },
  242. // { pid: "mm_32325420_3265865_14752067", appkey: "", unid: "" },
  243. // { pid: "mm_32325420_3265865_24246760", appkey: "", unid: "" },
  244. // { pid: "mm_32325420_3265865_24254681", appkey: "", unid: ""}]);
  245. //qq登錄加載按鈕
  246. // U.MD.U.OT.qqLoadJs({ btnId: "U_MD_U_L_login_O_T_app_QQ", size: "C_S" });
  247. //微博登錄加載按鈕
  248. // 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,
  249. // callback: { login: U.MD.U.OT.weiboLoginCallBack }
  250. // });
  251. //百度統計加載
  252. // U.UF.DL.C.AD.onloadBaiduJs("1fce47ee7e8655ddd108fca7116f0752");
  253. // U.UF.DL.C.AD.onloadBaiduJs("f0ececeb4f687bc4d4ffb7719f4cf6a7");
  254. }
  255. /**
  256. * 寫入訪問用戶信息
  257. */
  258. U.MD.D.visitLog = function () {
  259. U.A.Request(US.USER, ["AddToLoginLog", US.userInfo.UserId || US.EMPTYGUID, US.city.userAllLocation || ""], function () { }); //訪問日誌添加消息
  260. }
  261. //#endregion
  262. //#region 頁面事件處理
  263. //關閉頁面處理 把頁面的活動數-1
  264. window.onunload = function () {
  265. try {
  266. var _userinfo = US.userInfo;
  267. if (U.MD.D.LocalStorage) {
  268. var _count = U.MD.D.LocalStorage.get("ati") || 0;
  269. if (_count > 0) { _count-- };
  270. U.MD.D.LocalStorage.set("ati", _count); //這是活動用戶-1
  271. }
  272. if (_userinfo.UserId && U.A) { //在狀態中讓這個活動用戶下線
  273. U.A.Request(US.USER, ["UserOffline", _userinfo.UserId], function () { }, []);
  274. }
  275. } catch (e) { }
  276. }
  277. //錯誤處理,前端錯誤需要在控製臺輸出,同時提交到錯誤數據庫
  278. //window.onerror = function(sMessage,sUrl,sLine,columnNumber,errorObj){};
  279. //onerror函數的五個參數用於確定錯誤確切的信息,代表的意思依次為:
  280. //* @param {String} errorMessage errorMessage 錯誤信息
  281. //* @param {String} scriptURI 出錯的文件
  282. //* @param {Long} lineNumber 出錯代碼的行號
  283. //* @param {Long} columnNumber 出錯代碼的列號
  284. //* @param {Object} errorObj 錯誤的詳細信息,Anything
  285. U.MD.D.error = function (errorMessage, scripturi, linenumber, columnnumber, errorobj) {
  286. errorobj = errorobj || {}; //屏蔽js錯誤
  287. U.A.Request(US.USER, ["SetError", 0, (event.errorMessage || event || errorMessage), (scripturi || event.filename || event.errorUr) + "。行號:" + (linenumber || event.lineno || event.errorLine)], function () { }, []); //錯誤消息發送到數據庫
  288. U.UF.C.console(event.errorMessage || event || errorobj); //console 輸出錯誤信息
  289. return true; //不讓瀏覽器彈出錯誤報告,瀏覽器會彈出一個comfirm的錯誤。
  290. }
  291. /**
  292. * 用戶登錄處理
  293. */
  294. let LoginState = false
  295. let CookieS = ''
  296. U.MD.D.getuser = function () {
  297. // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gif/longhuaBg.gif")'
  298. var userInfo = US.userInfo;
  299. var panId = userInfo && userInfo.accountNumber
  300. if (!LoginState && !panId && !U.UF.C.queryString('code') && !U.UF.C.queryString('tycode')) {
  301. LoginState = true
  302. var _cookie = U.UF.Cookie.get("cocorobo");
  303. try {
  304. if (!panId && _cookie) {
  305. U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
  306. if (res.value && res.value[0] && res.value[0][0]) {
  307. var _user = res.value[0][0];
  308. U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
  309. if (res.value && res.value[0] && res.value[0][0]) {
  310. US.userInfo = res.value[0][0]; //记录用户数据
  311. US.userInfo.userid = _user.userid;
  312. // if ($("#U_MD_HomeC_Pop")[0]) {
  313. // $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
  314. // }
  315. selectUser(_user.userid, (res) => {
  316. loginSet(res.value[0][0], res);
  317. });
  318. }else {
  319. LoginState = false
  320. }
  321. }, [], { "type": "GET", "withCredentials": true });
  322. }else {
  323. LoginState = false
  324. }
  325. }, [], { "type": "GET", "withCredentials": true });
  326. }else {
  327. LoginState = false
  328. }
  329. } catch (error) {
  330. LoginState = false
  331. }
  332. }else if(!LoginState &&!panId && U.UF.C.queryString('code').length === 32){
  333. if($("#U_MD_HomeC_Pop")[0]){
  334. $("#U_MD_HomeC_Pop")[0].close()
  335. }
  336. LoginState = true
  337. // console.log('新華跳轉',U.UF.C.queryString('code'))
  338. let url = "https://cloud.cocorobo.cn/api/getTeacherInfoByCode"
  339. var myHeaders = new Headers();
  340. // myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
  341. myHeaders.append("Content-Type", "application/json");
  342. // myHeaders.append("Access-Control-Allow-Origin","*")
  343. var raw = JSON.stringify({
  344. "code": U.UF.C.queryString('code')
  345. });
  346. var requestOptions = {
  347. method: 'POST',
  348. headers: myHeaders,
  349. body: raw,
  350. redirect: 'follow',
  351. credentials: 'include'
  352. };
  353. fetch(url, requestOptions)
  354. .then(response => response.text())
  355. .then(result => {
  356. // console.log(result)
  357. let data = JSON.parse(result).data
  358. if(JSON.parse(result).code == 200){
  359. let diqu = `${data.province}-${data.city}-${data.county}-${data.street}-${data.schoolName}`
  360. let diquId = data.schoolId
  361. 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) {
  362. // console.log(res);
  363. let loginData = JSON.stringify({
  364. openid: data.userUniqueId,
  365. edu: true
  366. })
  367. var requestOptionsLogin = {
  368. method: 'POST',
  369. headers: myHeaders,
  370. body: loginData,
  371. redirect: 'follow',
  372. credentials: 'include'
  373. };
  374. fetch("https://cloud.api.cocorobo.hk/api/user", requestOptionsLogin)
  375. .then(response => response.text())
  376. .then(result => {
  377. let a = JSON.parse(result)
  378. if(a.length>0){
  379. let userId = a[0][0].userid
  380. US.userInfo.userid = userId
  381. selectUser(userId, (res) => {
  382. loginSet(res.value[0][0], res);
  383. });
  384. }
  385. })
  386. .catch(error => {
  387. LoginState = false
  388. console.log('error', error)
  389. });
  390. }, [], { "type": "POST", "withCredentials": true })
  391. }else{
  392. U.Alert("用戶登錄已失效,請重新獲取登錄信息!");
  393. }
  394. })
  395. .catch(error => {
  396. LoginState = false
  397. console.log('error', error)
  398. });
  399. }else if(!LoginState &&!panId && U.UF.C.queryString('code').length < 32 && U.UF.C.queryString('code').length > 9){
  400. if($("#U_MD_HomeC_Pop")[0]){
  401. $("#U_MD_HomeC_Pop")[0].close()
  402. }
  403. LoginState = true
  404. let url = "https:" + US.Config.pbl + "luohugetTeacherInfo?code=" + encodeURIComponent(U.UF.C.queryString('code'));
  405. var myHeaders = new Headers();
  406. myHeaders.append("Content-Type", "application/json");
  407. var requestOptions = {
  408. method: 'GET',
  409. redirect: 'follow'
  410. };
  411. fetch(url, requestOptions)
  412. .then(response => response.text())
  413. .then(result => {
  414. // console.log(result)
  415. let data = JSON.parse(result).data
  416. // return
  417. if(JSON.parse(result).code == 0){
  418. let diqu = ``
  419. let diquId = data.loginid
  420. 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) {
  421. // console.log(res);
  422. let loginData = JSON.stringify({
  423. openid: data.loginid,
  424. edu: true
  425. })
  426. var requestOptionsLogin = {
  427. method: 'POST',
  428. headers: myHeaders,
  429. body: loginData,
  430. redirect: 'follow',
  431. credentials: 'include'
  432. };
  433. fetch("https://cloud.api.cocorobo.hk/api/user", requestOptionsLogin)
  434. .then(response => response.text())
  435. .then(result => {
  436. let a = JSON.parse(result)
  437. if(a.length>0){
  438. let userId = a[0][0].userid
  439. US.userInfo.userid = userId
  440. selectUser(userId, (res) => {
  441. loginSet(res.value[0][0], res);
  442. });
  443. }
  444. })
  445. .catch(error => {
  446. LoginState = false
  447. console.log('error', error)
  448. });
  449. }, [], { "type": "POST", "withCredentials": true })
  450. }else{
  451. U.Alert("用户登录已失效,请重新获取登录信息!");
  452. }
  453. })
  454. .catch(error => {
  455. LoginState = false
  456. console.log('error', error)
  457. });
  458. }else if(!LoginState &&!panId && U.UF.C.queryString('tycode')){
  459. U.UF.DL.loading(document.body)
  460. if($("#U_MD_HomeC_Pop")[0]){
  461. $("#U_MD_HomeC_Pop")[0].close()
  462. }
  463. LoginState = true
  464. let url = "https://cloud.cocorobo.cn/api/getUserInfoByCode";
  465. var myHeaders = new Headers();
  466. myHeaders.append("Content-Type", "application/json");
  467. var requestOptions = {
  468. method: 'POST',
  469. headers: myHeaders,
  470. body: JSON.stringify({
  471. code: U.UF.C.queryString('tycode'),
  472. signature: U.UF.C.queryString('signature')
  473. }),
  474. redirect: 'follow'
  475. };
  476. fetch(url, requestOptions)
  477. .then(response => response.text())
  478. .then(result => {
  479. // console.log(result)
  480. let data = JSON.parse(result).data
  481. // return
  482. if(JSON.parse(result).code == 200){
  483. 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) {
  484. // console.log(res);
  485. let loginData = JSON.stringify({
  486. openid: data.userId,
  487. edu: true
  488. })
  489. var requestOptionsLogin = {
  490. method: 'POST',
  491. headers: myHeaders,
  492. body: loginData,
  493. redirect: 'follow',
  494. credentials: 'include'
  495. };
  496. fetch("https://cloud.api.cocorobo.hk/api/user", requestOptionsLogin)
  497. .then(response => response.text())
  498. .then(result => {
  499. let a = JSON.parse(result)
  500. if(a.length>0){
  501. let userId = a[0][0].userid
  502. US.userInfo.userid = userId
  503. selectUser(userId, (res) => {
  504. loginSet(res.value[0][0], res)
  505. U.UF.DL.uploading(document.body)
  506. });
  507. }
  508. })
  509. .catch(error => {
  510. LoginState = false
  511. console.log('error', error)
  512. });
  513. }, [], { "type": "POST", "withCredentials": true })
  514. }else{
  515. U.Alert("用户登录已失效,请重新获取登录信息!");
  516. U.UF.DL.uploading(document.body)
  517. }
  518. })
  519. .catch(error => {
  520. LoginState = false
  521. console.log('error', error)
  522. });
  523. } else if(panId){
  524. try {
  525. if(US.Config.type == '2'){
  526. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/easyBg.png")'
  527. if (userInfo.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217') {
  528. U.MD.D.getNotice();
  529. }else if (userInfo.org == '150e3120-9195-11ed-b13d-005056b86db5') {
  530. U.MD.D.getNotice();
  531. } else if (userInfo.org == 'ee40e8e3-e36c-4872-8105-cf395481012s') {
  532. U.MD.D.getNotice();
  533. }
  534. }else{
  535. if (userInfo.organizeid == '91305d49-01ba-11ed-8c78-005056b86db4') {
  536. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/mingdeBg.png")'
  537. } else if (userInfo.organizeid == 'c7df0bd4-6e75-401a-a137-4e163aa62263') {
  538. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/zhongshanBg.png")'
  539. } else if (userInfo.organizeid == '580aac24-a939-49f7-a75a-40a7b5af3a17') {
  540. // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longweiBg.png")'
  541. } else if (userInfo.organizeid == 'b1095a3c-1d06-4ac8-854f-7c0d97f4ab41') {
  542. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/yunhaiBg.jpg")'
  543. } else if (userInfo.organizeid == '857af1c7-c8ee-4b04-85b5-fd182903adb7') {
  544. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/beijingBg.png")'
  545. } else if (userInfo.organizeid == '69893dca-1d47-11ed-8c78-005056b86db5') {
  546. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/weilaiBg.png")'
  547. } else if (userInfo.organizeid == 'efdef564-4064-11ed-8c78-005056b86db5') {
  548. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/pz.jpg")'
  549. } else if (userInfo.organizeid == 'd9db3320-503a-11ed-8c78-005056b86db5') {
  550. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/hzBg.png")'
  551. } else if (userInfo.organizeid == 'ccb9754d-59c1-11ed-8c78-005056b86db5') {
  552. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")'
  553. } else if (userInfo.organizeid == 'f30a6615-5379-11ed-8c78-005056b86db5') {
  554. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longhuaBg.png")'
  555. } else if (userInfo.organizeid == '4787cc87-6588-11ed-8c78-005056b86db5') {
  556. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")'
  557. } else if (userInfo.organizeid == '9f888eae-7558-11ed-8c78-005056b86db5') {
  558. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/song.png")'
  559. } else if (userInfo.organizeid == '2b9ceb66-a1dd-11ed-b13d-005056b86db5') {
  560. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gmxxBg.png")'
  561. } else if (userInfo.organizeid == '1c3b9def-8fbe-11ed-b13d-005056b86db5') {
  562. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/wankeBg.png")'
  563. } else if (userInfo.organizeid == '82fcb5c7-c13b-11ed-8d51-005056b86db5') {
  564. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/qiaoxiangBg.png")'
  565. } else if (userInfo.organizeid == '4c686762-1d0a-11ed-8c78-005056b86db5') {
  566. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/sies.png")'
  567. } else if (userInfo.organizeid == 'ea2a8c65-f38c-11ed-91d8-005056b86db5') {
  568. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longhuaZXBg.png")'
  569. } else if (userInfo.organizeid == 'f297fbdc-f0a0-11ee-b534-005056b86db5') {
  570. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/010606.png")'
  571. }
  572. if (userInfo.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f018d') {
  573. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/yantianOrgBg.png")'
  574. } else if (userInfo.org == '7ada499f-4ec7-11ed-8c78-005056b86db5') {
  575. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/csteamBg.png")'
  576. } else if (userInfo.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217') {
  577. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gm/bg.png")'
  578. U.MD.D.getNotice();
  579. } else if (userInfo.org == '97c4ee8b-d010-4042-986d-e9d3c217264f') {
  580. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/zhoujia.jpg")'
  581. } else if (userInfo.org == '150e3120-9195-11ed-b13d-005056b86db5') {
  582. if (!$("#tc_desktop_css")[0]) {
  583. const link = document.createElement("link");
  584. link.rel = "stylesheet";
  585. link.href =
  586. "./css/tencent/Desktop.css";
  587. link.id = "tc_desktop_css"
  588. document.body.appendChild(link);
  589. $(".avatar")[0].onclick= function(){
  590. U.MD.D.I.openApplication('tcData')
  591. }
  592. }
  593. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/tencentBg.jpg")'
  594. U.MD.D.getNotice();
  595. } else if (userInfo.org == 'ee40e8e3-e36c-4872-8105-cf395481012s') {
  596. $(".avatar")[0].onclick= function(){
  597. U.MD.D.I.openApplication('tcData')
  598. }
  599. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szscBg.png")'
  600. U.MD.D.getNotice();
  601. } else if (userInfo.org == 'ec0af97a-7c10-4259-a7eb-db9cc8174cdc') {
  602. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/futianBg.png")'
  603. } else if (userInfo.org == 'e632b86c-f89d-11ed-91d8-005056b86db5') {
  604. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gdjgBg.png")'
  605. } else if (userInfo.org == '54f09f1e-09f0-11ee-91d8-005056b86db5') {
  606. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szlhyjBg.jpeg")'
  607. } else if (userInfo.org == '7b016f69-0f4f-11ee-91d8-005056b86db5') {
  608. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/dseiBg.png")'
  609. } else if (userInfo.org == '1973f6c7-1561-11ee-91d8-005056b86db5') {
  610. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szjkyBg2.png")'
  611. } else if (userInfo.org == '2fa75e51-189a-11ee-91d8-005056b86db5') {
  612. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/chjyjBg.png")'
  613. } else if (userInfo.org == '2a9f32ea-88df-49eb-aba1-0a286f691474') {
  614. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/qhBg.jpg")'
  615. } else if (userInfo.org == '884c5665-a453-46f3-b7b6-01d575290aa9') {
  616. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/scnuaiBg.png")'
  617. } else if (userInfo.org == '2fe1a080-4425-4620-b7a0-be2f3750ffd4') {
  618. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/x010607bgImg.png")'
  619. } else if (userInfo.org == 'ec84034b-8ea4-4d27-9cba-1adcb4720bb3') {
  620. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/SPROUTLabBg.png")'
  621. }
  622. }
  623. } catch (error) {
  624. // if ($("#U_MD_HomeC_Pop")[0]) {
  625. // $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
  626. // }
  627. selectUser(userInfo.userid, (res) => {
  628. loginSet(res.value[0][0], res);
  629. });
  630. }
  631. }
  632. var _cookie = U.UF.Cookie.get("cocorobo");
  633. if(LoginState && !_cookie){
  634. window.onbeforeunload = null
  635. window.location.reload();
  636. }else if(LoginState && !CookieS){
  637. CookieS = _cookie
  638. }else if(LoginState && _cookie != CookieS){
  639. US.userInfo = {}
  640. U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
  641. if (res.value && res.value[0] && res.value[0][0]) {
  642. var _user = res.value[0][0];
  643. U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + _user.userid, [], function (res) {
  644. if (res.value && res.value[0] && res.value[0][0]) {
  645. US.userInfo = res.value[0][0]; //记录用户数据
  646. US.userInfo.userid = _user.userid;
  647. selectUser(_user.userid, (res) => {
  648. loginSet(res.value[0][0], res);
  649. });
  650. }else {
  651. LoginState = false
  652. }
  653. }, [], { "type": "GET", "withCredentials": true });
  654. }else {
  655. window.onbeforeunload = null
  656. window.location.reload();
  657. }
  658. }, [], { "type": "GET", "withCredentials": true });
  659. }
  660. }
  661. U.MD.D.addLoginTime = function(){
  662. var userInfo = US.userInfo;
  663. if(Object.keys(userInfo).length !== 0){
  664. U.A.Request(US.Config.pbl + "addOperationTimeT", [userInfo.userid,'','3','600'], function (res) {
  665. }, [], { "type": "POST", "withCredentials": true });
  666. }
  667. }
  668. U.MD.D.getuser2 = function (userid, cid) {
  669. var myHeaders = new Headers();
  670. myHeaders.append("Content-Type", "application/json");
  671. let loginData = JSON.stringify({
  672. openid: userid,
  673. edu: true
  674. })
  675. var requestOptionsLogin = {
  676. method: 'POST',
  677. headers: myHeaders,
  678. body: loginData,
  679. redirect: 'follow',
  680. credentials: 'include' // 设置withCredentials为true
  681. };
  682. fetch("https://cloud.api.cocorobo.hk/api/user", requestOptionsLogin)
  683. .then(response => response.text())
  684. .then(result => {
  685. let a = JSON.parse(result)
  686. if(a.length>0){
  687. if($(".U_PBL_Check2")[0]){
  688. $(".U_PBL_Check2")[0].style.display = "none";
  689. }
  690. let userId = a[0][0].userid
  691. US.userInfo.userid = userId
  692. selectUser(userId, (res) => {
  693. if ($("#U_MD_HomeC_Pop")[0]) {
  694. $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
  695. }
  696. loginPan(res.value[0][0], userid)
  697. US.userInfo = res.value[0][0];
  698. $(".avatar")[0].style.display = "block";
  699. 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') {
  700. $(".U_PBL_Check")[0].style.display = "block";
  701. }
  702. $(".login")[0].style.display = "none";
  703. $(".register")[0].style.display = "none";
  704. $(".userName")[0].style.display = "block";
  705. $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
  706. $(".exit")[0].style.display = "block";
  707. let _vipbox = $('.U_MD_D_BD_vip_box')[0]
  708. _vipbox && (_vipbox.style.right = $(".U_MD_D_BD")[0].offsetWidth + 20 + 'px')
  709. if(res.value[0][0].type === 1 && res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
  710. U.MD.D.I.ModeCheck(2)
  711. }else{
  712. U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
  713. }
  714. if(res.value[0][0].type === 1 && window.location.hash.indexOf('project') != -1){
  715. U.MD.D.I.openApplication("project")
  716. }
  717. if(res.value[0][0].type === 1 && window.location.hash.indexOf('study') != -1){
  718. U.MD.D.I.openApplication("study")
  719. }
  720. if(res.value[0][0].type === 2 && window.location.hash.indexOf('study') != -1){
  721. U.MD.D.I.openApplication("studentStudy")
  722. }
  723. U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
  724. U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
  725. U.MD.D.I.openInApplication("studyDetail", cid, 2, 2)
  726. });
  727. }
  728. })
  729. .catch(error => {
  730. LoginState = false
  731. console.log('error', error)
  732. });
  733. }
  734. //#endregion
  735. //#region 獲取ifram下的html
  736. //U.MD.D.getIfraemHtml = function (src) {
  737. // var _iframe = $$("iframe", { src: src, style: { display: "none"} });
  738. // //跨域回調設置
  739. // U.UF.DL.iframeLoad(_iframe, function () {
  740. // var _html = _iframe.contentWindow.document.body.innerHTML;
  741. // console.log(_html);
  742. // U.selectEl(_iframe).remove();
  743. // });
  744. // U.selectEl(_iframe).appendTo($('body')[0]);
  745. //};
  746. //#endregion
  747. U.MD.D.fullscreen = function () {
  748. //if (document.body.offsetWidth < 1025) {
  749. U.UF.C.fullScreen()
  750. //}
  751. document.body.addEventListener('dblclick', () => {
  752. U.UF.C.fullScreen()
  753. // const isFullScreen = document.fullscreenElement
  754. // if (isFullScreen) {
  755. // U.UF.C.cancelfullScreen()
  756. // } else {
  757. // U.UF.C.fullScreen()
  758. // }
  759. })
  760. }
  761. U.MD.D.stopSafari = function () {
  762. //阻止safari瀏覽器雙擊放大功能
  763. let lastTouchEnd = 0 //更新手指彈起的時間
  764. document.documentElement.addEventListener("touchstart", function (event) {
  765. //多根手指同時按下屏幕,禁止默認行為
  766. if (event.touches.length > 1) {
  767. event.preventDefault();
  768. }
  769. });
  770. document.documentElement.addEventListener("touchend", function (event) {
  771. let now = (new Date()).getTime();
  772. if (now - lastTouchEnd <= 300) {
  773. //當兩次手指彈起的時間小於300毫秒,認為雙擊屏幕行為
  774. event.preventDefault();
  775. } else { // 否則重新手指彈起的時間
  776. lastTouchEnd = now;
  777. }
  778. }, false);
  779. //阻止雙指放大頁面
  780. document.documentElement.addEventListener("gesturestart", function (event) {
  781. event.preventDefault();
  782. });
  783. }
  784. U.MD.D.noticeBlock = '1'
  785. U.MD.D.OpenNotice = function () {
  786. let box = $('.U_MD_D_BD_notice')[0]
  787. box.style.display = 'block'
  788. }
  789. U.MD.D.cancelNotice = function () {
  790. U.UF.EV.stopBubble();
  791. let box = $('.U_MD_D_BD_notice')[0]
  792. box.style.display = 'none'
  793. U.MD.D.noticeBlock = '2'
  794. }
  795. U.MD.D.getNotice = function () {
  796. // a77e9404-efec-11e9-96f9-028edca3b798&oid=45facc0a-1211-11ec-80ad-005056b86db5&org=undefined&role=1
  797. var uid = US.userInfo.userid,
  798. oid = US.userInfo.organizeid,
  799. org = US.userInfo.org;
  800. U.A.Request(US.Config.pbl + "selectNotice?uid=" + uid + "&oid=" + oid + "&org=" + org + "&page=1", [], function (res) {
  801. if (res.value && res.value[0].length > 0) {
  802. let box = $('.U_MD_D_BD_noticeBox_box')[0]
  803. let _res = res.value[0]
  804. if (U.MD.D.noticeBlock == '1') {
  805. $('.U_MD_D_BD_notice')[0].style.display = 'block'
  806. }
  807. $('.U_MD_D_BD_notice_img')[0].style.display = 'block'
  808. box.innerHTML = ''
  809. var num = _res.length > 3 ? 3 : _res.length
  810. for (var i = 0; i < num; i++) {
  811. var _box = $$('div', { className: 'U_MD_D_BD_noticeBox' }, box)
  812. var _title = $$('div', { className: 'U_MD_D_BD_noticeBox_title' }, _box)
  813. // $$('span', { innerHTML: '消息通知' }, _title)
  814. $$('span', { innerHTML: _res[i].title }, _title)
  815. var _content = $$('div', { className: 'U_MD_D_BD_noticeBox_content' }, _box)
  816. $$('span', { innerHTML: _res[i].content.replace(/<[^>]*>/g, "") }, _content)
  817. var _time = $$('div', { className: 'U_MD_D_BD_noticeBox_time' }, _box)
  818. $$('span', { innerHTML: _res[i].creatTime }, _time)
  819. }
  820. } else {
  821. $('.U_MD_D_BD_notice')[0].style.display = 'none'
  822. $('.U_MD_D_BD_notice_img')[0].style.display = 'none'
  823. }
  824. // setTimeout(() => {
  825. // U.MD.D.getNotice();
  826. // }, 5000);
  827. }, [], { "type": "GET", "withCredentials": true });
  828. }
  829. // // 創建 video 元素並設置屬性
  830. // const video = document.createElement("video");
  831. // video.src = "../../img/icon/video/mxStart.mp4";
  832. // video.autoplay = true;
  833. // video.muted = true;
  834. // video.style="width: 100%;"
  835. // // 添加 video 元素到頁面
  836. // document.body.appendChild(video);
  837. // // 在視頻播放完成後刪除 video 元素
  838. // video.addEventListener("ended", () => {
  839. // document.body.removeChild(video);
  840. // });
  841. function formatDate(_date) {
  842. let time = _date.replace(/-/g, '/')
  843. let date = new Date(time);
  844. const year = date.getFullYear();
  845. const month = (date.getMonth() + 1).toString().padStart(2, "0");
  846. const day = date.getDate().toString().padStart(2, "0");
  847. const hours = date.getHours().toString().padStart(2, "0");
  848. const minutes = date.getMinutes().toString().padStart(2, "0");
  849. const seconds = date.getSeconds().toString().padStart(2, "0");
  850. return `${year}年${month}月${day}日`;
  851. }
  852. function formatDate2(_date) {
  853. let date = _date;
  854. const year = date.getFullYear();
  855. const month = (date.getMonth() + 1).toString().padStart(2, "0");
  856. const day = date.getDate().toString().padStart(2, "0");
  857. const hours = date.getHours().toString().padStart(2, "0");
  858. const minutes = date.getMinutes().toString().padStart(2, "0");
  859. const seconds = date.getSeconds().toString().padStart(2, "0");
  860. return `${year}年${month}月${day}日`;
  861. }
  862. function loginPan(userInfo, userId) {
  863. const currentDate = new Date();
  864. // 判斷 isLogin1 和 isLogin2 是否為 2 或者是否過期(且過期時間是有效的日期格式)
  865. if (
  866. userInfo.isLogin1 == 2 ||
  867. (userInfo.isLogin1 &&
  868. userInfo.isLogin1 != 1 &&
  869. userInfo.isLogin1 != 2 &&
  870. new Date(userInfo.isLogin1) < currentDate) ||
  871. userInfo.isLogin2 == 2 ||
  872. (userInfo.isLogin2 != 1 &&
  873. userInfo.isLogin2 != 2 &&
  874. new Date(userInfo.isLogin2) < currentDate) ||
  875. userInfo.state != 1
  876. ) {
  877. U.MD.U.LO.logoutSystem2();
  878. return;
  879. }
  880. let vipbox = $(".U_MD_D_BD_vip_box")[0];
  881. vipbox && (vipbox.style.display = "block");
  882. let vip_time = $(".vip_time")[0];
  883. let vtime = "";
  884. let vMember = "基礎用戶";
  885. // 獲取 isLogin1 和 isLogin2 的值
  886. let isLogin1 = userInfo.isLogin1;
  887. let isLogin2 = userInfo.isLogin2;
  888. if (isLogin2 != 1 && isLogin2 != null) {
  889. vtime = formatDate(isLogin2);
  890. vMember = "高級用戶";
  891. } else if (isLogin1 != 1 && isLogin1 != null) {
  892. vtime = formatDate(isLogin1);
  893. vMember = "高級用戶";
  894. } else if (
  895. (isLogin1 == 1 && isLogin2 == 1) ||
  896. (isLogin1 == null && isLogin2 == 1)
  897. ) {
  898. vtime = formatDate2(new Date(currentDate.setFullYear(currentDate.getFullYear() + 1)));
  899. vMember = "基礎用戶";
  900. }
  901. vip_time && (vip_time.innerHTML = vtime);
  902. let orgName = userInfo.orgName;
  903. let schoolName = userInfo.schoolName;
  904. let vip_school = $(".vip_school")[0];
  905. vip_school && (vip_school.innerHTML = orgName ? orgName : schoolName);
  906. let vip_member = $(".vip_member")[0];
  907. vip_member && (vip_member.innerHTML = vMember);
  908. U.A.Request(
  909. US.Config.pbl + "addLoginOperation",
  910. [userId],
  911. function (res) {},
  912. [],
  913. { type: "POST", withCredentials: true }
  914. );
  915. if (userInfo.organizeid == "91305d49-01ba-11ed-8c78-005056b86db4") {
  916. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/mingdeBg.png")';
  917. US.Config.background = 'url("/img/icon/mingdeBg.png")';
  918. } else if (
  919. userInfo.organizeid == "c7df0bd4-6e75-401a-a137-4e163aa62263"
  920. ) {
  921. $("#U_MD_D_BG")[0].style.backgroundImage =
  922. 'url("/img/icon/zhongshanBg.png")';
  923. US.Config.background = 'url("/img/icon/zhongshanBg.png")';
  924. } else if (
  925. userInfo.organizeid == "580aac24-a939-49f7-a75a-40a7b5af3a17"
  926. ) {
  927. // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longweiBg.png")'
  928. } else if (
  929. userInfo.organizeid == "b1095a3c-1d06-4ac8-854f-7c0d97f4ab41"
  930. ) {
  931. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/yunhaiBg.jpg")';
  932. US.Config.background = 'url("/img/icon/yunhaiBg.png")';
  933. } else if (
  934. userInfo.organizeid == "857af1c7-c8ee-4b04-85b5-fd182903adb7"
  935. ) {
  936. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/beijingBg.png")';
  937. US.Config.background = 'url("/img/icon/beijingBg.png")';
  938. } else if (
  939. userInfo.organizeid == "69893dca-1d47-11ed-8c78-005056b86db5"
  940. ) {
  941. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/weilaiBg.png")';
  942. US.Config.background = 'url("/img/icon/weilaiBg.png")';
  943. } else if (
  944. userInfo.organizeid == "efdef564-4064-11ed-8c78-005056b86db5"
  945. ) {
  946. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/pz.jpg")';
  947. US.Config.background = 'url("/img/icon/pz.png")';
  948. } else if (
  949. userInfo.organizeid == "d9db3320-503a-11ed-8c78-005056b86db5"
  950. ) {
  951. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/hzBg.png")';
  952. US.Config.background = 'url("/img/icon/hzBg.png")';
  953. } else if (
  954. userInfo.organizeid == "ccb9754d-59c1-11ed-8c78-005056b86db5"
  955. ) {
  956. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")';
  957. US.Config.background = 'url("/img/icon/nanfangBg.png")';
  958. } else if (
  959. userInfo.organizeid == "f30a6615-5379-11ed-8c78-005056b86db5"
  960. ) {
  961. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/longhuaBg.png")';
  962. US.Config.background = 'url("/img/icon/longhuaBg.png")';
  963. } else if (
  964. userInfo.organizeid == "4787cc87-6588-11ed-8c78-005056b86db5"
  965. ) {
  966. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/nanfangBg.png")';
  967. US.Config.background = 'url("/img/icon/nanfangBg.png")';
  968. } else if (
  969. userInfo.organizeid == "9f888eae-7558-11ed-8c78-005056b86db5"
  970. ) {
  971. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/song.png")';
  972. US.Config.background = 'url("/img/icon/song.png")';
  973. } else if (
  974. userInfo.organizeid == "2b9ceb66-a1dd-11ed-b13d-005056b86db5"
  975. ) {
  976. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gmxxBg.png")';
  977. US.Config.background = 'url("/img/icon/gmxxBg.png")';
  978. } else if (
  979. userInfo.organizeid == "1c3b9def-8fbe-11ed-b13d-005056b86db5"
  980. ) {
  981. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/wankeBg.png")';
  982. US.Config.background = 'url("/img/icon/wankeBg.png")';
  983. } else if (
  984. userInfo.organizeid == "82fcb5c7-c13b-11ed-8d51-005056b86db5"
  985. ) {
  986. $("#U_MD_D_BG")[0].style.backgroundImage =
  987. 'url("/img/icon/qiaoxiangBg.png")';
  988. US.Config.background = 'url("/img/icon/qiaoxiangBg.png")';
  989. } else if (
  990. userInfo.organizeid == "4c686762-1d0a-11ed-8c78-005056b86db5"
  991. ) {
  992. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/sies.png")';
  993. US.Config.background = 'url("/img/icon/sies.png")';
  994. } else if (
  995. userInfo.organizeid == "ea2a8c65-f38c-11ed-91d8-005056b86db5"
  996. ) {
  997. $("#U_MD_D_BG")[0].style.backgroundImage =
  998. 'url("/img/icon/longhuaZXBg.png")';
  999. US.Config.background = 'url("/img/icon/longhuaZXBg.png")';
  1000. } else if (
  1001. userInfo.organizeid == "f297fbdc-f0a0-11ee-b534-005056b86db5"
  1002. ) {
  1003. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/010606.png")';
  1004. US.Config.background = 'url("/img/icon/010606.png")';
  1005. }
  1006. if (userInfo.org == "eb2af5e9-ac3d-46b6-9fe3-3c1c364f018d") {
  1007. $("#U_MD_D_BG")[0].style.backgroundImage =
  1008. 'url("/img/icon/yantianOrgBg.png")';
  1009. US.Config.background = 'url("/img/icon/yantianOrgBg.png")';
  1010. } else if (userInfo.org == "7ada499f-4ec7-11ed-8c78-005056b86db5") {
  1011. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/csteamBg.png")';
  1012. US.Config.background = 'url("/img/icon/csteamBg.png")';
  1013. } else if (userInfo.org == "eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217") {
  1014. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gm/bg.png")';
  1015. US.Config.background = 'url("/img/icon/bg.png")';
  1016. U.MD.D.getNotice();
  1017. } else if (userInfo.org == "97c4ee8b-d010-4042-986d-e9d3c217264f") {
  1018. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/zhoujia.jpg")';
  1019. US.Config.background = 'url("/img/icon/zhoujia.png")';
  1020. } else if (userInfo.org == "150e3120-9195-11ed-b13d-005056b86db5") {
  1021. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/tencentBg.jpg")';
  1022. US.Config.background = 'url("/img/icon/tencentBg.png")';
  1023. U.MD.D.getNotice();
  1024. } else if (userInfo.org == "ee40e8e3-e36c-4872-8105-cf395481012s") {
  1025. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szscBg.png")';
  1026. US.Config.background = 'url("/img/icon/szscBg.png")';
  1027. U.MD.D.getNotice();
  1028. } else if (userInfo.org == "ec0af97a-7c10-4259-a7eb-db9cc8174cdc") {
  1029. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/futianBg.png")';
  1030. US.Config.background = 'url("/img/icon/futianBg.png")';
  1031. } else if (userInfo.org == "e632b86c-f89d-11ed-91d8-005056b86db5") {
  1032. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gdjgBg.png")';
  1033. US.Config.background = 'url("/img/icon/gdjgBg.png")';
  1034. } else if (userInfo.org == "54f09f1e-09f0-11ee-91d8-005056b86db5") {
  1035. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szlhyjBg.jpeg")';
  1036. US.Config.background = 'url("/img/icon/szlhyjBg.jpeg")';
  1037. } else if (userInfo.org == "7b016f69-0f4f-11ee-91d8-005056b86db5") {
  1038. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/dseiBg.png")';
  1039. US.Config.background = 'url("/img/icon/dseiBg.png")';
  1040. } else if (userInfo.org == "1973f6c7-1561-11ee-91d8-005056b86db5") {
  1041. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/szjkyBg2.png")';
  1042. US.Config.background = 'url("/img/icon/szjkyBg2.png")';
  1043. } else if (userInfo.org == "2fa75e51-189a-11ee-91d8-005056b86db5") {
  1044. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/chjyjBg.png")';
  1045. US.Config.background = 'url("/img/icon/chjyjBg.png")';
  1046. } else if (userInfo.org == "2a9f32ea-88df-49eb-aba1-0a286f691474") {
  1047. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/qhBg.jpg")';
  1048. US.Config.background = 'url("/img/icon/qhBg.jpg")';
  1049. } else if (userInfo.org == "884c5665-a453-46f3-b7b6-01d575290aa9") {
  1050. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/scnuaiBg.png")';
  1051. US.Config.background = 'url("/img/icon/scnuaiBg.png")';
  1052. } else if (userInfo.org == "2fe1a080-4425-4620-b7a0-be2f3750ffd4") {
  1053. $("#U_MD_D_BG")[0].style.backgroundImage =
  1054. 'url("/img/icon/x010607bgImg.png")';
  1055. US.Config.background = 'url("/img/icon/x010607bgImg.png")';
  1056. } else if (userInfo.org == "ec84034b-8ea4-4d27-9cba-1adcb4720bb3") {
  1057. $("#U_MD_D_BG")[0].style.backgroundImage =
  1058. 'url("/img/icon/SPROUTLabBg.png")';
  1059. US.Config.background = 'url("/img/icon/SPROUTLabBg.png")';
  1060. } else if (
  1061. userInfo.org == "b47d2ea8-7044-4810-9cb7-3aaf8b74cfbc"
  1062. ) {
  1063. $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/Tianyuan.png")';
  1064. US.Config.background = 'url("/img/icon/Tianyuan.png")';
  1065. }
  1066. US.userInfo = userInfo;
  1067. U.MD.D.addOp3("1", "", { type: "user_login" }, "success")
  1068. $(".avatar")[0].style.display = "block";
  1069. if (
  1070. userInfo.type === 1 &&
  1071. $(".U_PBL_Check")[0] &&
  1072. userInfo.org != "150e3120-9195-11ed-b13d-005056b86db5" && userInfo.org != 'b47d2ea8-7044-4810-9cb7-3aaf8b74cfbc'
  1073. ) {
  1074. $(".U_PBL_Check")[0].style.display = "block";
  1075. }
  1076. }
  1077. function loginSet(userInfo, res){
  1078. if ($("#U_MD_HomeC_Pop")[0]) {
  1079. $("#U_MD_HomeC_Pop")[0].close(); //关闭登陆
  1080. }
  1081. let userId = userInfo.userid
  1082. if (res.value == null || res.value[0].length == 0) {
  1083. // U.MD.D.I.openApplication("my")
  1084. let _name = US.userInfo.alias ? US.userInfo.alias : US.userInfo.username
  1085. let _type = US.userInfo == 1 ? 2 : 1
  1086. // US.Config.pbl
  1087. // "http://localhost:7003/api/pbl/"
  1088. U.A.Request(US.Config.pbl + "updatePblMessage", [userId, _name, _type, '16d397f3-b192-11ed-9211-005056b86db5', '', '', "0"], function (res) {
  1089. window.location.reload();
  1090. }, [], { "type": "POST", "withCredentials": true });
  1091. } else {
  1092. loginPan(userInfo, userId)
  1093. }
  1094. if($(".U_PBL_Check2")[0]){
  1095. $(".U_PBL_Check2")[0].style.display = "none";
  1096. }
  1097. $(".login")[0].style.display = "none";
  1098. $(".register")[0].style.display = "none";
  1099. $(".userName")[0].style.display = "block";
  1100. $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
  1101. $(".exit")[0].style.display = "block";
  1102. let _vipbox = $('.U_MD_D_BD_vip_box')[0]
  1103. _vipbox && (_vipbox.style.right = $(".U_MD_D_BD")[0].offsetWidth + 20 + 'px')
  1104. if(userInfo.type === 1 && userInfo.org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
  1105. U.MD.D.I.ModeCheck(2)
  1106. }else{
  1107. U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
  1108. }
  1109. if(userInfo.type === 1 && userInfo.org == "f3b243b2-75e2-4b00-8f66-7644946a2a25"){
  1110. U.MD.D.I.openApplication("appStore")
  1111. }
  1112. let shareCourseId = window.location.href.indexOf("?shareCourseId=")!=-1?window.location.href.split("?shareCourseId=")[1].toString():''
  1113. if(shareCourseId){
  1114. console.log(shareCourseId);
  1115. U.MD.D.I.openInApplication("studyDetail", shareCourseId, 5, 1)
  1116. }
  1117. if(userInfo.type === 1 && window.location.hash.indexOf('project') != -1){
  1118. U.MD.D.I.openApplication("project")
  1119. }
  1120. if(userInfo.type === 1 && window.location.hash.indexOf('study') != -1){
  1121. U.MD.D.I.openApplication("study")
  1122. }
  1123. if(userInfo.type === 2 && window.location.hash.indexOf('study') != -1){
  1124. U.MD.D.I.openApplication("studentStudy")
  1125. }
  1126. if(userInfo.type === 1 && U.UF.C.queryString('tycode') && U.UF.C.queryString('app')){
  1127. U.MD.D.I.openApplication(U.UF.C.queryString('app'))
  1128. }
  1129. U.MD.O.P.connect(); //登录成功后连接socket服务同步协同编辑
  1130. }
  1131. function selectUser(uid, callback) {
  1132. var userInfo = US.userInfo;
  1133. var panId = userInfo && userInfo.accountNumber
  1134. if(panId){
  1135. let res = {value:[[userInfo]]}
  1136. if (callback) callback(res);
  1137. return
  1138. }
  1139. const requestUser = () => {
  1140. U.A.Request(`${US.Config.pbl}selectUser?userid=${uid}`, [], function (res) {
  1141. if(res && res.value && res.value.length && res.value[0].length && res.value[0][0].userid){
  1142. if (callback) callback(res);
  1143. }else {
  1144. U.alert("获取用户信息失败,正在重试!")
  1145. LoginState = false
  1146. requestUser();
  1147. }
  1148. }, [], { "type": "GET", "withCredentials": true });
  1149. };
  1150. try {
  1151. requestUser();
  1152. } catch (error) {
  1153. U.alert("登录失败,正在重试!")
  1154. LoginState = false
  1155. requestUser();
  1156. }
  1157. }
  1158. function detectBrowser() {
  1159. const ua = navigator.userAgent;
  1160. // 按优先级顺序检测
  1161. if (ua.includes("Edg/") || ua.includes("Edge/")) {
  1162. return "Microsoft Edge";
  1163. } else if (ua.includes("Firefox")) {
  1164. return "Mozilla Firefox";
  1165. } else if (ua.includes("Trident") || ua.includes("MSIE")) {
  1166. return "Internet Explorer";
  1167. } else if (ua.includes("360EE")) {
  1168. return "360 Browser (极速模式)";
  1169. } else if (ua.includes("360SE")) {
  1170. return "360 Browser (安全模式)";
  1171. } else if (ua.includes("SLBrowser")) {
  1172. return "QQ Browser";
  1173. } else if (ua.includes("UCBrowser")) {
  1174. return "UC Browser";
  1175. } else if (ua.includes("Opera") || ua.includes("OPR/")) {
  1176. return "Opera";
  1177. } else if (ua.includes("Chrome") && !ua.includes("Edg/")) {
  1178. return "Google Chrome";
  1179. } else if (ua.includes("Safari/") && !ua.includes("Chrome")) {
  1180. return "Safari";
  1181. } else {
  1182. return "Other Browser";
  1183. }
  1184. }
  1185. U.MD.D.addOp3 = async (userTime, loadTime, object, status) => {
  1186. let browser = detectBrowser()
  1187. let _time = new Date().toLocaleString('zh-CN', { hour12: false, timeZone: 'Asia/Shanghai' }).replace(/\//g, '-');
  1188. let params = {
  1189. userid: US.userInfo.userid,
  1190. username: US.userInfo.name,
  1191. accountNumber: US.userInfo.accountNumber,
  1192. org: US.userInfo.orgName,
  1193. school: US.userInfo.schoolName,
  1194. role: US.userInfo.type == '1' ? '老师' : '学生',
  1195. browser: browser,
  1196. userTime: userTime == '1' ? _time : userTime, // 使用时间 1次的就1 其次传秒
  1197. loadTime: loadTime, //load的时间没有就“”
  1198. object: JSON.stringify(object), //执行信息传json
  1199. status: status, //成功返回success。失败返回error的信息
  1200. }
  1201. fetch("https://pbl.cocorobo.cn/api/mongo/updateUserData2P", { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params) }).then(res => {
  1202. if (res.status == 200) {
  1203. console.log('保存成功')
  1204. } else {
  1205. console.log('保存失败')
  1206. }
  1207. }).catch(e => {
  1208. console.log('保存失败')
  1209. console.log(e);
  1210. })
  1211. }