var app = angular.module('app', [ ]); app.controller("personalDataTabletop", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-username"); self.userCName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.userTypeEng = $.cookie("GlWorkPlatform-userTypeEng"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.CrossPage = window.parent.CrossPage; self.loading = false; ////加载用户的框架列表******************************************************************************************* self.imgColActive_code = ""; self.frameArray = []; self.frameArray_active = {}; self.ifHasDefault_frame = 0; self.getData_frame = function () { self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/frame/queryDataUserByUserid", JSON.stringify(postData), postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; //console.log(JSON.stringify(res)); if (res.success) { self.loading = false; self.frameArray = res.data; angular.forEach(self.frameArray, function (item) { if (item.ISDEFAULT == "1") { self.ifHasDefault_frame = 1; self.imgColActive_code = item.CODE; self.frameArray_active = item; } }); $timeout(function () { if (self.ifHasDefault_frame == 0) { self.frameArray_active = self.frameArray[0]; self.imgColActive_code = self.frameArray[0].CODE; } },10) } else { self.loading = false; self.frameArray = []; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_frame(); self.btnModify_frame = function () { sp.layer("#layer_frame", 1); }; self.submit_frame = function () { var postData = { "userid": self.userId, "code": self.imgColActive_code }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/frame/updateDataUserDefault", JSON.stringify(postData), postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); self.getData_frame(); sp.dialog("框架修改成功,请重新登陆!"); $timeout(function () { //top.window.location.reload(); top.location.href = "../../login.html"; $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 }); $.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 }); $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 }); sessionStorage.removeItem("GlWorkPlatform-LoginFrom"); localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量 localStorage.removeItem("GlWorkPlatform-setLeftBarClickID"); localStorage.removeItem("GlWorkPlatform-AccessToken"); localStorage.removeItem("GlWorkPlatform-userInfoJsonStr"); }, 1000); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) } self.cancel_frame = function () { sp.closeCenter('#layer_frame'); } self.frame_imgColClick = function (itemdata) { self.imgColActive_code = itemdata.CODE; } ////加载用户的框架列表******************************************************************************************* ////加载用户的桌面列表******************************************************************************************* self.imgColActive_code_desktop = ""; self.desktopArray = []; self.desktopArray_active = {}; self.ifHasDefault_desktop = 0; self.getData_desktop = function () { self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/desktop/queryDataUserByUserid", JSON.stringify(postData), postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; //console.log(JSON.stringify(res)); if (res.success) { self.loading = false; self.desktopArray = res.data; angular.forEach(self.desktopArray, function (item) { if (item.ISDEFAULT == "1") { self.ifHasDefault_desktop = 1; self.imgColActive_code_desktop = item.CODE; self.desktopArray_active = item; } }); $timeout(function () { if (self.ifHasDefault_desktop == 0) { self.desktopArray_active = self.desktopArray[0]; self.imgColActive_code_desktop = self.desktopArray[0].CODE; } }, 10) } else { self.loading = false; self.desktopArray = []; self.desktopArray_active = {}; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_desktop(); self.btnModify_desktop = function () { sp.layer("#layer_desktop", 1); }; self.submit_desktop = function () { var postData = { "userid": self.userId, "code": self.imgColActive_code_desktop }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/desktop/updateDataUserDefault", JSON.stringify(postData), postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); self.getData_desktop(); //sp.dialog("桌面修改成功!"); $timeout(function () { top.window.location.reload(); //top.location.href = "../../login.html"; //$.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 }); //$.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 }); //$.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 }); //sessionStorage.removeItem("GlWorkPlatform-LoginFrom"); //localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量 //localStorage.removeItem("GlWorkPlatform-setLeftBarClickID"); //localStorage.removeItem("GlWorkPlatform-AccessToken"); //localStorage.removeItem("GlWorkPlatform-userInfoJsonStr"); }, 10); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.cancel_desktop = function () { sp.closeCenter('#layer_desktop'); }; self.desktop_imgColClick = function (itemdata) { self.imgColActive_code_desktop = itemdata.CODE; } ////加载用户的桌面列表******************************************************************************************* ////加载背景图片******************************************************************************************* self.imgColActive_code_bkimage = ""; self.bkimageArray = []; self.bkimageArray_active = {}; self.ifHasDefault_bkimage = 0; self.getData_bkimage = function () { self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/bkimage/queryDataUserByUserid", JSON.stringify(postData), postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; //console.log(JSON.stringify(res)); if (res.success) { self.loading = false; self.bkimageArray = res.data; angular.forEach(self.bkimageArray, function (item) { if (item.ISDEFAULT == "1") { self.ifHasDefault_bkimage = 1; self.imgColActive_code_bkimage = item.CODE; self.bkimageArray_active = item; } }); $timeout(function () { if (self.ifHasDefault_bkimage == 0) { self.bkimageArray_active = self.bkimageArray[0]; self.imgColActive_code_bkimage = self.bkimageArray[0].CODE; } }, 10); } else { self.loading = false; self.bkimageArray = []; self.bkimageArray_active = {}; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_bkimage(); self.btnModify_bkimage = function () { sp.layer("#layer_bkimage", 1); } self.submit_bkimage = function () { var postData = { "userid": self.userId, "code": self.imgColActive_code_bkimage }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/bkimage/updateDataUserDefault", JSON.stringify(postData), postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); self.getData_bkimage(); //sp.dialog("背景图片修改成功!"); $timeout(function () { top.window.location.reload(); //top.location.href = "../../login.html"; //$.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 }); //$.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 }); //$.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 }); //sessionStorage.removeItem("GlWorkPlatform-LoginFrom"); //localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量 //localStorage.removeItem("GlWorkPlatform-setLeftBarClickID"); //localStorage.removeItem("GlWorkPlatform-AccessToken"); //localStorage.removeItem("GlWorkPlatform-userInfoJsonStr"); }, 10); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) } self.cancel_bkimage = function () { sp.closeCenter('#layer_bkimage'); } self.bkimage_imgColClick = function (itemdata) { self.imgColActive_code_bkimage = itemdata.CODE; } ////加载背景图片******************************************************************************************* }]);