realUser-info.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("realUserInfoCtrl", ["$http", "$scope", "$timeout", function ($http, $scope, $timeout) {
  6. var self = this;
  7. self.webApiUrl2 = "";
  8. self.get_userid = $.cookie("GlWorkPlatform-userid");
  9. self.get_username = $.cookie("GlWorkPlatform-username"); //获取英文名
  10. self.get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名
  11. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  12. self.get_id = sp.getUrlName("id");
  13. self.backUrl = "lastReturnPageno=" + sp.getUrlName("lastReturnPageno");
  14. ///返回按钮事件
  15. self.btnGoBack = function () {
  16. window.location.href = "realUser.html?" + self.backUrl;
  17. }
  18. var postCfgJson = {
  19. headers: {
  20. 'Content-Type': 'application/json',
  21. 'Authorization': "Bearer " + self.get_AccessToken
  22. }
  23. };
  24. self.info = {
  25. ID: self.get_id,
  26. USERID: "",
  27. OPENID:"",
  28. USERREALNAME: "",
  29. GENDER: "",
  30. STREET:"",
  31. COMMUNITY: "",
  32. BLOCK: "",
  33. BUILDING: "",
  34. DOORNO: "",
  35. HOUSENO: ""
  36. };
  37. //////加载数据;只有编辑
  38. self.getEditInfo = function () {
  39. var data = {
  40. entity: "XG_USER",
  41. id: self.get_id,
  42. idName: "",
  43. fields: ""
  44. };
  45. $http.post(apiurljs.backend + "Data/Get", data, postCfgJson)
  46. .success(function (res) {
  47. //console.log(JSON.stringify(res));
  48. if (sp.isval(res)) {
  49. self.info = res;
  50. }
  51. });
  52. };
  53. self.getEditInfo();
  54. self.btnSave = function () {
  55. if (spngvld.submit("#tableAddData")) {
  56. var updateData = {
  57. userid: self.info.USERID,
  58. openid: self.info.OPENID,
  59. community: self.info.COMMUNITY,
  60. block: self.info.BLOCK,
  61. building: self.info.BUILDING,
  62. doorno: self.info.DOORNO,
  63. houseno: self.info.HOUSENO
  64. }
  65. $http.post(apiurljs.backend + "XinGuan/UpdateRegisterInfo", updateData, postCfgJson)
  66. .success(function (res) {
  67. //console.log(res);
  68. if (res.success) {
  69. sp.dialog(res.message);
  70. $timeout(function () {
  71. self.getEditInfo();
  72. sp.dialoghide();
  73. }, 500);
  74. } else {
  75. sp.dialog(res.message);
  76. }
  77. });
  78. };
  79. };
  80. }]);