123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // '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 = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">确认要提交吗?</div>";
- 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>";
- $('.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));
- });
- });
- }
- }
- };
- }]);
|