// 'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("initSetCtrl", ["$http", "$timeout", function ($http, $timeout) { var self = this; var s4 = new SM4Util(); // self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); // //console.log(self.get_AccessToken); // self.get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid; var postCfgJson = { headers: { 'Content-Type': 'application/json' } }; self.info = { "unitname": "", "sysname": "", "sysimage": "", "adminuser": "administrator", "adminpass": "", "ConfirmPassword": "" }; self.btnSubmit = function () { //console.log(self.info); if (spngvld.submit("#form_checkData")) { //大小写字母、数字、特殊符号、8位以上 var pwdReg = !!self.info.adminpass.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/); if (!self.info.adminpass) { sp.dialog("请填写新密码"); } else if (pwdReg == false) { sp.dialog("密码必须同时包含:数字、大写字母、小写字母、特殊符号,并且满足8~16位"); } else if (self.info.adminpass !== self.info.ConfirmPassword) { sp.dialog("两次新密码输入不一致"); }else { var dialogHead = "温馨提示×"; var dialogBody = "
确认要提交吗?
"; var dialogFoot = "
"; $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot); sp.openCenter(".sp-dialog"); ///取消按钮 $('.sp-closeDialog').click(function (event) { sp.dialoghide(); event.preventDefault(); event.stopPropagation(); }); $("#dialog_btnConfirm").click(function () { var postPwdData = { "unitname": self.info.unitname, "sysname": self.info.sysname, "sysimage": self.info.sysimage, "adminuser": self.info.adminuser, "adminpass": self.info.adminpass } console.log(postPwdData); $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) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //sp.dialoghide(); console.log(res); if (res.success) { sp.dialog("初始化设置成功!"); $timeout(function(){ window.location.href="login.html?v="+ new Date().getTime(); },2000); } else { sp.dialog(res.message); } }).error(function (err) { ///sp.dialog(JSON.stringify(err)); }); }); } } }; }]);