123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- var app = angular.module('app', [
- ]);
- app.controller("personalDataPhone", ["$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.userinfoAddress = {
- "CARDID": "",///身份证号码
- "FAX": "",///传真号
- "ROOM": "",///房间号
- "CELLPHONE": "",
- "TELPHONE": "",
- "EMAIL": ""
- };
-
- self.getData_frame = 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/queryUserinfoAddress", 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.userinfoAddress = {
- "CARDID": res.data.CARDID,///身份证号码
- "FAX": res.data.FAX,///传真号
- "ROOM": res.data.ROOM,///房间号
- "CELLPHONE": res.data.CELLPHONE,
- "TELPHONE": res.data.TELPHONE,
- "EMAIL": res.data.EMAIL
- };
- } else {
- self.loading = false;
- self.userinfoAddress = {
- "CARDID": "",///身份证号码
- "FAX": "",///传真号
- "ROOM": "",///房间号
- "CELLPHONE": "",
- "TELPHONE": "",
- "EMAIL": ""
- };
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- if (textStatus != 200) {
- self.loading = false;
- }
- })
- };
- self.getData_frame();
- self.btnSave = function () {
- if (sp.isval(self.userinfoAddress.CARDID)) {
- var pwdReg = !!self.userinfoAddress.CARDID.match(/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/);
- if (pwdReg == false) {
- sp.dialog("身份证号码错误");
- return;
- }
- }
- if (sp.isval(self.userinfoAddress.TELPHONE)) {
- var pwdReg = !!self.userinfoAddress.TELPHONE.match(/^(?:(?:0\d{2,3})-)?(?:\d{7,8})(-(?:\d{3,}))?$/);
- if (pwdReg == false) {
- sp.dialog("固定电话错误");
- return;
- }
- }
- 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='delDataTrue' 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.closeCenter(".sp-dialog");
- event.preventDefault(); event.stopPropagation();
- });
- //post消息的id
- $("#delDataTrue").click(function () {
- var getid = $(this).attr("data-id");
- var data = {
- userid: self.userId,///角色编码
- cellphone: self.userinfoAddress.CELLPHONE,
- telphone: self.userinfoAddress.TELPHONE,
- email: self.userinfoAddress.EMAIL,
- cardid: self.userinfoAddress.CARDID,
- fax: self.userinfoAddress.FAX,
- room: self.userinfoAddress.ROOM
- };
- //console.log(data);
- $http.post(apiurljs.login + "g2work/user/saveUserinfoAddress", JSON.stringify(data), postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //var res = obj;
- if (res.success) {
- self.getData_frame();
- sp.dialoghide();
- sp.dialog("修改成功")
- $timeout(function () {
- sp.dialoghide()
- },2000)
- } else {
- sp.dialog(res.message);
- }
- });
- });
- };
- }]);
|