modifyPhoto.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination', ////分页用到的插件
  4. 'ngSanitize'///$sanitize这个服务.此服务依赖于ngSanitize模块.(这个模块需要加载angular-sanitize.js插件)
  5. ////应用ng-bind-html如果不引用此模块,会报安全错误
  6. ]);
  7. app.controller("modifyPhotoCtrl", ["$http", "$scope", function ($http, $scope) {
  8. var self = this;
  9. var s4 = new SM4Util();
  10. self.get_userid = $.cookie("GlWorkPlatform-userid");
  11. self.get_username = $.cookie("GlWorkPlatform-username"); //获取英文名
  12. self.get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名
  13. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  14. var postCfg = {
  15. headers: {
  16. 'Content-Type': 'application/json',
  17. 'Authorization': "Bearer " + self.get_AccessToken
  18. }
  19. };
  20. self.getUserSetting = function () {
  21. var postData = {
  22. userid: self.get_userid
  23. }
  24. $http.post(apiurljs.login + "g2work/desktop/queryDesktopMarkT", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  25. .success(function (obj) {
  26. var res = strToJson(s4.decryptData_CBC(obj.data));
  27. ////给选中的图片加上选中符号
  28. self.getAdminImgName = res.data.imgsrc;
  29. self.getAdminDeskName = res.data.tenantcode;
  30. self.getImgData();
  31. self.getDeskData();
  32. })
  33. }
  34. self.getImgData = function () {
  35. $http.get("json/modifyPhoto.txt", "", postCfg)
  36. .success(function (res) {
  37. if (res.success) {
  38. self.ImgData = res.Items;
  39. self.currentImg = "../../AFrontEnd/css/icons/photo/" + self.getAdminImgName;
  40. setTimeout(function () {
  41. $("#modiyPhotoPart img").each(function () {
  42. if ($(this).attr("data-name") == self.getAdminImgName) {
  43. $(this).next().addClass("sp-img-checked");
  44. };
  45. });
  46. }, 600);
  47. }
  48. });
  49. };
  50. self.getDeskData = function () {
  51. $http.get("json/modifyDesk.txt", "", postCfg)
  52. .success(function (res) {
  53. if (res.success) {
  54. self.DeskData = res.Items;
  55. $.each(self.DeskData, function (index, item) {
  56. if (item.deskUrl == self.getAdminDeskName) {
  57. self.currentDESK = "../../AFrontEnd/css/icons/photo/" + item.deskName;
  58. }
  59. })
  60. setTimeout(function () {
  61. $("#modiyDeskPart img").each(function () {
  62. if ($(this).attr("data-name") == self.getAdminDeskName) {
  63. $(this).next().addClass("sp-desk-checked");
  64. };
  65. });
  66. }, 600);
  67. }
  68. });
  69. };
  70. self.savePhoto = function () {
  71. var data = {
  72. "userid": self.get_userid,
  73. "data": {
  74. "IMGSRC": $(".sp-img-checked").prev().attr("data-name")
  75. }
  76. }
  77. $http.post(apiurljs.login + "g2work/desktop/InertOrUpManIMG", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  78. .success(function (res) {
  79. window.parent.location.reload()
  80. })
  81. }
  82. self.saveDeskTop = function () {
  83. var data = {
  84. "userid": self.get_userid,
  85. "data": {
  86. "TENANTCODE": $(".sp-desk-checked").prev().attr("data-name")
  87. }
  88. }
  89. $http.post(apiurljs.login + "g2work/desktop/updateManInfor", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  90. .success(function (res) {
  91. window.parent.location.reload()
  92. })
  93. }
  94. self.getUserSetting()
  95. }]);
  96. app.directive("modImgClick", function () {
  97. return {
  98. restrict: "A",
  99. link: function (scope, elem, attrs) {
  100. setTimeout(function () {
  101. //console.log($(elem).find("img").length);
  102. elem.find(".sp-page-col").each(function () {
  103. $(this).click(function () {
  104. $(".mod-img-up").removeClass("sp-img-checked");
  105. $(".mod-img-up", this).addClass("sp-img-checked");
  106. //var setAdminImgName = $("img", this).attr("data-name");
  107. //scope.ctl.currentImg = "../../AFrontEnd/css/icons/photo/" + setAdminImgName; //增加随机参数时间可强制刷新;
  108. //scope.ctl.savePhoto(setAdminImgName);
  109. //scope.$apply();
  110. });
  111. })
  112. }, 500);
  113. }
  114. }
  115. });
  116. app.directive("modDeskClick", function () {
  117. return {
  118. restrict: "A",
  119. link: function (scope, elem, attrs) {
  120. setTimeout(function () {
  121. elem.find(".sp-page-col").each(function () {
  122. $(this).click(function () {
  123. $(".mod-img-up").removeClass("sp-desk-checked");
  124. $(".mod-img-up", this).addClass("sp-desk-checked");
  125. //var setAdminDeskName = $("img", this).attr("data-name");
  126. //scope.ctl.currentDESK = $("img", this).attr("src"); //增加随机参数时间可强制刷新;
  127. //scope.ctl.saveDeskTop(setAdminDeskName);
  128. //scope.$apply();
  129. });
  130. })
  131. }, 500);
  132. }
  133. }
  134. });