initset.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("initSetCtrl", ["$http", "$timeout", function ($http, $timeout) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. // self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  9. // //console.log(self.get_AccessToken);
  10. // self.get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid;
  11. var postCfgJson = {
  12. headers: {
  13. 'Content-Type': 'application/json'
  14. }
  15. };
  16. self.info = {
  17. "unitname": "",
  18. "sysname": "",
  19. "sysimage": "",
  20. "adminuser": "administrator",
  21. "adminpass": "",
  22. "ConfirmPassword": ""
  23. };
  24. self.btnSubmit = function () {
  25. //console.log(self.info);
  26. if (spngvld.submit("#form_checkData")) {
  27. //大小写字母、数字、特殊符号、8位以上
  28. var pwdReg = !!self.info.adminpass.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/);
  29. if (!self.info.adminpass) {
  30. sp.dialog("请填写新密码");
  31. } else if (pwdReg == false) {
  32. sp.dialog("密码必须同时包含:数字、大写字母、小写字母、特殊符号,并且满足8~16位");
  33. } else if (self.info.adminpass !== self.info.ConfirmPassword) {
  34. sp.dialog("两次新密码输入不一致");
  35. }else {
  36. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  37. var dialogBody = "<div class=\"sp-dialog-body\">确认要提交吗?</div>";
  38. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='dialog_btnConfirm' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  39. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  40. sp.openCenter(".sp-dialog");
  41. ///取消按钮
  42. $('.sp-closeDialog').click(function (event) {
  43. sp.dialoghide();
  44. event.preventDefault();
  45. event.stopPropagation();
  46. });
  47. $("#dialog_btnConfirm").click(function () {
  48. var postPwdData = {
  49. "unitname": self.info.unitname,
  50. "sysname": self.info.sysname,
  51. "sysimage": self.info.sysimage,
  52. "adminuser": self.info.adminuser,
  53. "adminpass": self.info.adminpass
  54. }
  55. console.log(postPwdData);
  56. $http.post(apiurljs.login + "g2work/systemInit?unitname=" + self.info.unitname + "&sysname=" + self.info.sysname + "&sysimage=" + self.info.sysimage + "&adminuser=" + self.info.adminuser + "&adminpass=" + self.info.adminpass, { data: s4.encryptData_CBC(JSON.stringify(postPwdData)) }, postCfgJson)
  57. .success(function (obj) {
  58. var res = strToJson(s4.decryptData_CBC(obj.data));
  59. //sp.dialoghide();
  60. console.log(res);
  61. if (res.success) {
  62. sp.dialog("初始化设置成功!");
  63. $timeout(function(){
  64. window.location.href="login.html?v="+ new Date().getTime();
  65. },2000);
  66. } else {
  67. sp.dialog(res.message);
  68. }
  69. }).error(function (err) {
  70. ///sp.dialog(JSON.stringify(err));
  71. });
  72. });
  73. }
  74. }
  75. };
  76. }]);