personalData_phone.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. var app = angular.module('app', [
  2. ]);
  3. app.controller("personalDataPhone", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
  4. var self = this;
  5. var s4 = new SM4Util();
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-username");
  8. self.userCName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.userTypeEng = $.cookie("GlWorkPlatform-userTypeEng");
  11. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.CrossPage = window.parent.CrossPage;
  18. self.loading = false;
  19. self.userinfoAddress = {
  20. "CARDID": "",///身份证号码
  21. "FAX": "",///传真号
  22. "ROOM": "",///房间号
  23. "CELLPHONE": "",
  24. "TELPHONE": "",
  25. "EMAIL": ""
  26. };
  27. self.getData_frame = function () {
  28. self.loading = true;
  29. var postData = { "userid": self.userId };
  30. //console.log(postData);
  31. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  32. $http.post(apiurljs.login + "g2work/user/queryUserinfoAddress", JSON.stringify(postData), postCfg)
  33. .success(function (obj) {
  34. var res = strToJson(s4.decryptData_CBC(obj.data));
  35. //var res = obj;
  36. //console.log(JSON.stringify(res));
  37. if (res.success) {
  38. self.loading = false;
  39. self.userinfoAddress = {
  40. "CARDID": res.data.CARDID,///身份证号码
  41. "FAX": res.data.FAX,///传真号
  42. "ROOM": res.data.ROOM,///房间号
  43. "CELLPHONE": res.data.CELLPHONE,
  44. "TELPHONE": res.data.TELPHONE,
  45. "EMAIL": res.data.EMAIL
  46. };
  47. } else {
  48. self.loading = false;
  49. self.userinfoAddress = {
  50. "CARDID": "",///身份证号码
  51. "FAX": "",///传真号
  52. "ROOM": "",///房间号
  53. "CELLPHONE": "",
  54. "TELPHONE": "",
  55. "EMAIL": ""
  56. };
  57. }
  58. })
  59. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  60. if (textStatus != 200) {
  61. self.loading = false;
  62. }
  63. })
  64. };
  65. self.getData_frame();
  66. self.btnSave = function () {
  67. if (sp.isval(self.userinfoAddress.CARDID)) {
  68. var pwdReg = !!self.userinfoAddress.CARDID.match(/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/);
  69. if (pwdReg == false) {
  70. sp.dialog("身份证号码错误");
  71. return;
  72. }
  73. }
  74. if (sp.isval(self.userinfoAddress.TELPHONE)) {
  75. var pwdReg = !!self.userinfoAddress.TELPHONE.match(/^(?:(?:0\d{2,3})-)?(?:\d{7,8})(-(?:\d{3,}))?$/);
  76. if (pwdReg == false) {
  77. sp.dialog("固定电话错误");
  78. return;
  79. }
  80. }
  81. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  82. var dialogBody = "<div class=\"sp-dialog-body\">您确认要提交吗?</div>";
  83. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  84. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  85. sp.openCenter(".sp-dialog");
  86. ///取消按钮
  87. $('.sp-closeDialog').click(function (event) {
  88. sp.closeCenter(".sp-dialog");
  89. event.preventDefault(); event.stopPropagation();
  90. });
  91. //post消息的id
  92. $("#delDataTrue").click(function () {
  93. var getid = $(this).attr("data-id");
  94. var data = {
  95. userid: self.userId,///角色编码
  96. cellphone: self.userinfoAddress.CELLPHONE,
  97. telphone: self.userinfoAddress.TELPHONE,
  98. email: self.userinfoAddress.EMAIL,
  99. cardid: self.userinfoAddress.CARDID,
  100. fax: self.userinfoAddress.FAX,
  101. room: self.userinfoAddress.ROOM
  102. };
  103. //console.log(data);
  104. $http.post(apiurljs.login + "g2work/user/saveUserinfoAddress", JSON.stringify(data), postCfg)
  105. .success(function (obj) {
  106. var res = strToJson(s4.decryptData_CBC(obj.data));
  107. //var res = obj;
  108. if (res.success) {
  109. self.getData_frame();
  110. sp.dialoghide();
  111. sp.dialog("修改成功")
  112. $timeout(function () {
  113. sp.dialoghide()
  114. },2000)
  115. } else {
  116. sp.dialog(res.message);
  117. }
  118. });
  119. });
  120. };
  121. }]);