var app = angular.module('app', [ ]); app.controller("personalData", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-username"); self.userCName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.userTypeEng = $.cookie("GlWorkPlatform-userTypeEng"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.CrossPage = window.parent.CrossPage; self.loading = false; ////加载用户头像数据******************************************************************************************* self.frameArray_userPhoto = ""; self.getData_userPhoto = function () { self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/user/queryUserinfoImgsrc", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { self.loading = false; self.frameArray_userPhoto = res.data.IMGSRC; } else { self.loading = false; self.frameArray = []; self.frameArray_userPhoto = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAGjklEQVR4XuVbe4iUVRT/nU+mzR4g62MLAl2QIEWXnXvvxi4FiVE+ysweRBooZKQhPTR6+ae9SF1DepCCgiZRaab5iiKhcGm/e2dZRYMQViEoUxfB1LbB78RdZ2R2nMf3zXdnHZj7zyzLub9z7u+7j3PPOZdQ5aa1vp2I5gVBMNHzvDHMPBbAGCLK/g0iOs3MZwCcsX8HQXDG87zjzLxDSvlnNU2kaoAbYyYCeJSZHwZwb0wdPxPRbgDfCCGOx8S6prtTArTWzwJ4HMCDrg3N4B0A8LWUcqMrfCcEGGPmMfMyAPe5MqwMzkEiWi+E2BFXXywCfN+3A15m13hcQyrpb/cIAOuVUgcr6W/7VETA0aNHGy9duvQ+ADvla6FtHDly5GuTJ0/u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AfvOihakKXsEqjqJgigh5n3AvghbBY3k3W+n4hmAWiN9Y1LdzbVPAbPEdHqxsbGNc3Nzf9WMoi+vr4b+/v7lzPzCgCjKsEo0+dAtRyhbUS0SgjxmwujjTF3MfNK17nJQUeoCq7we1LKN1wMPB9Da/0ugNddYQ+6wi4vQ0QkhRDGlYGFcIwxgpntvuWiLXV2HU6n083t7e3OokqlRtfV1TUhkUj0xWVg8DpsQeIGRIIgWNTW1rY5rkFR+nd3dy/0PG9TlD65slcDIvafcUJiRLRZCLGoUkPi9DPGbGLmhZVgDAmJxQiK2qOuw9VuH3UgmdPBxgkiH5FDgqJWsdY6cliciFYKId6OarhLeWPMW8y8KiLm0LB4hgBb8hYlMdIzevTojkqdnIgGFxW3ztLZs2ftLIjiMV6bGMmQECUHt1pK+aqrgcTB0Vp/YCPRITGG5CwrTo4y82yllPXxr3vzfX8WEe0JY0jJ5GjmSAyTHr8gpbwljMLhktFa/wPg5lL6yqbHMwSEKZDYK6V0kkd0RZDW2s4Ae3ss2kIVSGT2gpIlMkTUKYQYjohNaH6MMWuZuVQ+MlyJjNUYokgqduVH6JGFFCxTSRKtSCozC4qWyRHRTCGEDafXTDPGzGDmfUUMilYmlwWp60LJLAl1XSqbJaHKyYmqLaMwSZmyxdI5JNRvuXzOcqjfBxM5M6F+n8xkSajrR1O5O1bdPpvL37br9uFkPhF1+3S2wIyoz8fThTyaWn8+/z++OBrmg9xLVgAAAABJRU5ErkJggg=="; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_userPhoto(); self.userPhoto = { imagesmall:"" }; self.btnModify_userPhoto = function () { $("#btnfile").val(""); //文件 self.userPhoto.imagesmall = ""; $(".sp-upload-img").attr("src", ""); sp.layer("#layer_userPhoto", 1); }; //图片文件转base64 var imgBaseArr, fileSize; self.upload = function () { $("#btnfile").change(function (e) { //获取图片大小,字节 var fileMsg = e.currentTarget.files; if (fileMsg[0].type.indexOf('image') !== -1) { //console.log(fileMsg[0].type); fileSize = fileMsg[0].size;//不能超过2668484,大约为2.6MB if (fileSize > 0.5 * 1024 * 1024) { alert("选择的图像文件不能超过500K,请重新选择!"); $("#btnfile").val(""); //文件 self.userPhoto.imagesmall = ""; $(".sp-upload-img").attr("src", ""); } else { var reader = new FileReader(); reader.onload = function (e) { //console.log(e) var imgBase = reader.result; //这个就是base64的编码 imgBaseArr = imgBase; //截取掉前面的内容“data:image/png;base64”, //if (imgBase.split(',')[0].indexOf('base64') >= 0) { // imgBaseArr = imgBase.split(',')[1]; //} self.userPhoto.imagesmall = imgBaseArr; $(".sp-upload-img").attr("src", imgBaseArr); } reader.readAsDataURL(this.files[0]); } } else { alert("仅能上传图片"); } }) }; self.upload(); ///提交保存--用户头像 self.submit_userPhoto = function () { var postData = { "userid": self.userId, "imgsrc": self.userPhoto.imagesmall }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/user/saveUserinfoImgsrc", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); $timeout(function () { self.getData_userPhoto(); }, 210); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) } self.cancel_userPhoto = function () { sp.closeCenter('#layer_userPhoto'); } ////加载用户头像数据******************************************************************************************* ////加载用户的账号信息*********************************************************************************** self.frameArray_UserinfoAccount = "";///原账号 self.frameArray_UserinfoAccount_new = "";///新账号 self.getData_UserinfoAccount = function () { //self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/user/queryUserinfoAccount", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { //self.loading = false; self.frameArray_UserinfoAccount = res.data.UINPUTNAME; } else { //self.loading = false; self.frameArray_UserinfoAccount = self.userName; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_UserinfoAccount(); self.btnModify_UserinfoAccount = function () { self.frameArray_UserinfoAccount_new = "";///新账号 sp.layer("#layer_UserinfoAccount", 1); } self.submit_UserinfoAccount = function () { if (spngvld.submit("#layer_UserinfoAccount")) { var postData = { "userid": self.userId, "account": self.frameArray_UserinfoAccount_new, "token": localStorage.getItem("main-token") }; //$http.post(apiurljs.login + "g2work/user/saveUserinfoAccount", JSON.stringify(postData), postCfg) $http.post(apiurljs.login + "g2app/usercertification/saveUserinfoAccount", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); sp.dialog("账号修改成功,请重新登录!"); $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"); localStorage.removeItem("GlWorkPlatform-userInfoJsonStr"); }, 1500); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) } } self.cancel_UserinfoAccount = function () { spngvld.clear("#layer_UserinfoAccount"); sp.closeCenter('#layer_UserinfoAccount'); } ////加载用户的账号信息*********************************************************************************** ////加载用户名称*********************************************************************************** self.frameArray_UserinfoUsername = "";///原账号 self.frameArray_UserinfoUsername_new = "";///新账号 self.getData_UserinfoUsername = function () { //self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/user/queryUserinfoUsername", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { //self.loading = false; self.frameArray_UserinfoUsername = res.data.USHOWNAME; } else { //self.loading = false; self.frameArray_UserinfoUsername = self.userCName; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_UserinfoUsername(); self.btnModify_UserinfoUsername = function () { self.frameArray_UserinfoUsername_new = "";///新账号 sp.layer("#layer_UserinfoUsername", 1); } self.submit_UserinfoUsername = function () { if (spngvld.submit("#layer_UserinfoUsername")) { var postData = { "userid": self.userId, "username": self.frameArray_UserinfoUsername_new.replace(/\s+/g, "") }; $http.post(apiurljs.login + "g2work/user/saveUserinfoUsername", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); sp.dialog("用户名称修改成功,请重新登录!"); $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"); localStorage.removeItem("GlWorkPlatform-userInfoJsonStr"); }, 1500); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) } } self.cancel_UserinfoUsername = function () { spngvld.clear("#layer_UserinfoUsername"); sp.closeCenter('#layer_UserinfoUsername'); } ////加载用户名称*********************************************************************************** ////用户的手机号*********************************************************************************** self.frameArray_UserinfoCellphone = "";///原账号 self.frameArray_UserinfoCellphone_new = "";///新账号 self.getData_UserinfoCellphone = function () { //self.loading = true; var postData = { "userid": self.userId }; //console.log(postData); //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData)) $http.post(apiurljs.login + "g2work/user/queryUserinfoCellphone", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { //self.loading = false; self.frameArray_UserinfoCellphone = res.data.CELLPHONE; } else { //self.loading = false; self.frameArray_UserinfoCellphone = ""; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) }; self.getData_UserinfoCellphone(); self.btnModify_UserinfoCellphone = function () { self.frameArray_UserinfoUsername_new = "";///新账号 sp.layer("#layer_UserinfoCellphone", 1); }; self.submit_UserinfoCellphone = function () { if (sp.isval(self.frameArray_UserinfoCellphone_new)) { if (spngvld.submit("#layer_UserinfoCellphone")) { var postData = { "userid": self.userId, "cellphone": self.frameArray_UserinfoCellphone_new.toString() }; //console.log(JSON.stringify(postData)); $http.post(apiurljs.login + "g2work/user/saveUserinfoCellphone", JSON.stringify(postData), postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); $timeout(function () { self.getData_UserinfoCellphone(); }, 200); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }); } } else { alert("手机号码不能为空!"); } }; self.cancel_UserinfoCellphone = function () { spngvld.clear("#layer_UserinfoCellphone_table"); sp.closeCenter('#layer_UserinfoCellphone'); }; ////用户的手机号*********************************************************************************** ////重置口令*********************************************************************************** // var key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgUCcDOMnAD6DXdRhPv7rsV3r9BTjFSog8IijWC9HqxxO2KrzQa_lDi9ox5_fwCSueifWykEfR55JyLdG-gnDywbErrdCMoNlq4-5aSFiieY1-0GsZYUmpN5FSvx_zPyjHzOQZgjoZ4ugzNG4cscRWbE6xH_BRfjUwQwhsecBBbzUw36KsXgpJD8UOadtx6LQTnHy93fWm1n-zmyiq3fuAOjv2VuJ8XOqfoVv6qljH_DgZ_e7CSGnhTEeKjGdys_qm2AVll3PejG4ufmj_bjMXIr0QY6YfQILK2NsLBLduqNWnH_wi8DTg4xfbcJi_Dm8SlXP4NiX8IVTTdlj4o-soQIDAQAB"; var jsencrypt = new JSEncrypt() jsencrypt.setPublicKey(key) self.info = { oldPwd: '', newPwd: '', newPwdConfirm: '' }; self.btnModify_Pwd = function () { self.info = { oldPwd: '', newPwd: '', newPwdConfirm: '' }; sp.layer("#layer_Pwd", 1); }; self.submit_Pwd = function () { if (spngvld.submit("#layer_Pwd")) { //大小写字母、数字、特殊符号,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 (pwdReg == false) { alert("密码必须同时包含:数字、大写字母、小写字母、特殊符号,并且8~16位"); } else if (self.info.newPwd !== self.info.newPwdConfirm) { alert("两次新密码输入不一致"); } else { //var postPwdData = { // "userid": self.userId, // "oldpassword": self.info.oldPwd, // "get_password": jsencrypt.encrypt(self.info.newPwd), // "newpassword": self.info.newPwd //} var postPwdData = { "token": localStorage.getItem("main-token"), "oldpassword": self.info.oldPwd, "rsapassword": jsencrypt.encrypt(self.info.newPwd), "newpassword": self.info.newPwd } //$http.post(apiurljs.login + "g2work/user/updatePasswordByUserid", { data: s4.encryptData_CBC(JSON.stringify(postPwdData)) }, postCfg) $http.post(apiurljs.login + "g2app/usercertification/updatePasswordByUserid", { data: s4.encryptData_CBC(JSON.stringify(postPwdData)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //var res = obj; //console.log(JSON.stringify(res)); if (res.success) { sp.closeCenter('.sp-layer'); 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/DangJian/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"); localStorage.removeItem("GlWorkPlatform-userInfoJsonStr"); }, 1500); } else { sp.closeCenter('.sp-layer'); sp.dialog(res.message); } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { if (textStatus != 200) { self.loading = false; } }) } } } self.cancel_Pwd = function () { spngvld.clear("#layer_Pwd"); sp.closeCenter('#layer_Pwd'); } ////重置口令*********************************************************************************** }]);