123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination', ////分页用到的插件
- 'ngSanitize'///$sanitize这个服务.此服务依赖于ngSanitize模块.(这个模块需要加载angular-sanitize.js插件)
- ////应用ng-bind-html如果不引用此模块,会报安全错误
- ]);
- app.controller("modifyPwdCtrl", ["$http", "$timeout",function ($http,$timeout) {
- var self = this;
- var s4 = new SM4Util();
- self.get_AccessToken=localStorage.getItem("GlWorkPlatform-AccessToken");
- ///console.log(self.get_AccessToken);
- var get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid;
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
-
- self.info = {
- username: $.cookie("GlWorkPlatform-username"),
- oldPwd: '',
- newPwd: '',
- newPwdConfirm: ''
- };
- self.btnSubmit = function () {
- //console.log(self.info);
- if (spngvld.submit("#form_checkData")) {
- //大小写字母、数字、特殊符号,8位以上
- var pwdReg = !!self.info.newPwd.match(/^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,16}$/);//验证包含大小写字母、数字、特殊符号
- //var pwdReg = !!self.info.newPwd.match(/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){8,16}$/);//验证包含大小写字母、数字、特殊符号任意两种规则
- if (!self.info.newPwd) {
- sp.dialog("请填写新密码");
- }else if(pwdReg==false){
- sp.dialog("密码必须同时包含:数字、大写字母、小写字母、特殊符号,并且8~16位");
- } else if (self.info.newPwd !== self.info.newPwdConfirm) {
- sp.dialog("两次新密码输入不一致");
- } else {
- //console.log(self.info);
- 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 = {
- "oldpassword": self.info.oldPwd,
- "newpassword": self.info.newPwd
- }
- //console.log(postPwdData);
- $http.post(apiurljs.login + "g2work/user/updatePasswordByUserid", { data: s4.encryptData_CBC(JSON.stringify(postPwdData)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //sp.dialoghide();
- ///console.log(res);
- if(res.success){
- sp.dialog("密码修改成功,请重新登录!");
- var data = {
- tablename: "LOGIN_STATISTICS_TAB",
- data: {
- USERID: $.cookie("GlWorkPlatform-userid"),
- USHOWNAME: decodeURI($.cookie("GlWorkPlatform-chineseName")),
- UINPUTNAME: $.cookie("GlWorkPlatform-username"),
- OPERATIONTIME: sp.getLocalDate(),
- ONLINEMARK: "out"
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (res) {})
- $timeout(function(){
- top.location.href = "../../login.html";
- $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
- sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
- localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
- localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
- localStorage.removeItem("GlWorkPlatform-AccessToken");
- },1500);
- }else{
- sp.dialog(res.message);
- }
- }).error(function(err) {
- sp.dialog(JSON.stringify(err));
- });
- });
- }
- }
- };
- self.btnCancel = function () {
- 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='btnYes' 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();
- });
- $("#btnYes").click(function () {
- self.info = {
- username: $.cookie("GlWorkPlatform-username"),
- oldPwd: '',
- newPwd: '',
- newPwdConfirm: ''
- };
- spngvld.clear("#form_checkData");
- })
- };
- }]);
|