'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("realUserInfoCtrl", ["$http", "$scope", "$timeout", function ($http, $scope, $timeout) { var self = this; self.webApiUrl2 = ""; self.get_userid = $.cookie("GlWorkPlatform-userid"); self.get_username = $.cookie("GlWorkPlatform-username"); //获取英文名 self.get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名 self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.get_id = sp.getUrlName("id"); self.backUrl = "lastReturnPageno=" + sp.getUrlName("lastReturnPageno"); ///返回按钮事件 self.btnGoBack = function () { window.location.href = "realUser.html?" + self.backUrl; } var postCfgJson = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.info = { ID: self.get_id, USERID: "", OPENID:"", USERREALNAME: "", GENDER: "", STREET:"", COMMUNITY: "", BLOCK: "", BUILDING: "", DOORNO: "", HOUSENO: "" }; //////加载数据;只有编辑 self.getEditInfo = function () { var data = { entity: "XG_USER", id: self.get_id, idName: "", fields: "" }; $http.post(apiurljs.backend + "Data/Get", data, postCfgJson) .success(function (res) { //console.log(JSON.stringify(res)); if (sp.isval(res)) { self.info = res; } }); }; self.getEditInfo(); self.btnSave = function () { if (spngvld.submit("#tableAddData")) { var updateData = { userid: self.info.USERID, openid: self.info.OPENID, community: self.info.COMMUNITY, block: self.info.BLOCK, building: self.info.BUILDING, doorno: self.info.DOORNO, houseno: self.info.HOUSENO } $http.post(apiurljs.backend + "XinGuan/UpdateRegisterInfo", updateData, postCfgJson) .success(function (res) { //console.log(res); if (res.success) { sp.dialog(res.message); $timeout(function () { self.getEditInfo(); sp.dialoghide(); }, 500); } else { sp.dialog(res.message); } }); }; }; }]);