'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination', ////分页用到的插件 'ngSanitize'///$sanitize这个服务.此服务依赖于ngSanitize模块.(这个模块需要加载angular-sanitize.js插件) ////应用ng-bind-html如果不引用此模块,会报安全错误 ]); app.controller("modifyPhotoCtrl", ["$http", "$scope", function ($http, $scope) { var self = this; var s4 = new SM4Util(); self.get_userid = $.cookie("GlWorkPlatform-userid"); self.get_username = $.cookie("GlWorkPlatform-username"); //获取英文名 self.get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名 self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.getUserSetting = function () { var postData = { userid: self.get_userid } $http.post(apiurljs.login + "g2work/desktop/queryDesktopMarkT", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); ////给选中的图片加上选中符号 self.getAdminImgName = res.data.imgsrc; self.getAdminDeskName = res.data.tenantcode; self.getImgData(); self.getDeskData(); }) } self.getImgData = function () { $http.get("json/modifyPhoto.txt", "", postCfg) .success(function (res) { if (res.success) { self.ImgData = res.Items; self.currentImg = "../../AFrontEnd/css/icons/photo/" + self.getAdminImgName; setTimeout(function () { $("#modiyPhotoPart img").each(function () { if ($(this).attr("data-name") == self.getAdminImgName) { $(this).next().addClass("sp-img-checked"); }; }); }, 600); } }); }; self.getDeskData = function () { $http.get("json/modifyDesk.txt", "", postCfg) .success(function (res) { if (res.success) { self.DeskData = res.Items; $.each(self.DeskData, function (index, item) { if (item.deskUrl == self.getAdminDeskName) { self.currentDESK = "../../AFrontEnd/css/icons/photo/" + item.deskName; } }) setTimeout(function () { $("#modiyDeskPart img").each(function () { if ($(this).attr("data-name") == self.getAdminDeskName) { $(this).next().addClass("sp-desk-checked"); }; }); }, 600); } }); }; self.savePhoto = function () { var data = { "userid": self.get_userid, "data": { "IMGSRC": $(".sp-img-checked").prev().attr("data-name") } } $http.post(apiurljs.login + "g2work/desktop/InertOrUpManIMG", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (res) { window.parent.location.reload() }) } self.saveDeskTop = function () { var data = { "userid": self.get_userid, "data": { "TENANTCODE": $(".sp-desk-checked").prev().attr("data-name") } } $http.post(apiurljs.login + "g2work/desktop/updateManInfor", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (res) { window.parent.location.reload() }) } self.getUserSetting() }]); app.directive("modImgClick", function () { return { restrict: "A", link: function (scope, elem, attrs) { setTimeout(function () { //console.log($(elem).find("img").length); elem.find(".sp-page-col").each(function () { $(this).click(function () { $(".mod-img-up").removeClass("sp-img-checked"); $(".mod-img-up", this).addClass("sp-img-checked"); //var setAdminImgName = $("img", this).attr("data-name"); //scope.ctl.currentImg = "../../AFrontEnd/css/icons/photo/" + setAdminImgName; //增加随机参数时间可强制刷新; //scope.ctl.savePhoto(setAdminImgName); //scope.$apply(); }); }) }, 500); } } }); app.directive("modDeskClick", function () { return { restrict: "A", link: function (scope, elem, attrs) { setTimeout(function () { elem.find(".sp-page-col").each(function () { $(this).click(function () { $(".mod-img-up").removeClass("sp-desk-checked"); $(".mod-img-up", this).addClass("sp-desk-checked"); //var setAdminDeskName = $("img", this).attr("data-name"); //scope.ctl.currentDESK = $("img", this).attr("src"); //增加随机参数时间可强制刷新; //scope.ctl.saveDeskTop(setAdminDeskName); //scope.$apply(); }); }) }, 500); } } });