'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("indexRealCtrl", ["$http", "$scope", "$timeout", function ($http, $scope, $timeout) { var self = this; self.webApiUrl2 = ""; self.get_userid = $.cookie("GlWorkPlatform-userid"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno") || 1; ///接收传过来的第几页 self.get_name = decodeURI(sp.getUrlName("name")); self.get_idno = sp.getUrlName("idno"); //alert(self.get_idno); ///返回按钮事件 self.btnGoBack = function () { window.location.href = "index.html" } var postCfgJson = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; ///声明 self.noDataTip = 1; self.rows = []; //声明空数组 self.pageno = 1; // 初始化 当前页为 1 self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 15, 20, 25, 30]; // 初始化分页数据 self.getData = function (pageno) { self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var set_like = "USERREALNAME=" + self.get_name + "&IDNO=" + self.get_idno; ///查询这条记录,生成数组,赋值给表 //得到返回的数据的id let postSearchData = { "entity": "XG_USER", "fields": "", "orderby": "id asc", "eqparams": "", "likeparams": set_like, "dateparams": "", "inparams": "", "page": self.pageno, "pagesize": self.itemsPerPage } $http.post(apiurljs.backend + "Data/List", postSearchData, postCfgJson) .success(function (res) { if (sp.isval(res.items)) { self.noDataTip = 1; angular.forEach(res.items, function (item, index) { item.CREATETIME = sp.formatMinute(item.CREATETIME); if (item.STATUS == "1") { item.STATUS_SET = "已实名"; } else if (item.STATUS == "-1") { item.STATUS_SET = "正在申请注销"; } else { item.STATUS_SET = "未实名"; } }); self.rows = res.items; self.total_count = res.total; } else { self.rows = []; self.noDataTip = 0; self.total_count = 1; } }).error(function (err) { sp.dialog(JSON.stringify(err)); }); } $timeout(function () { self.getData(self.get_lastReturnPageno); }, 200) ///刷新 self.btnRefresh = function () { self.getData(self.pageno); }; self.info = { ID: self.get_id, USERID: "", OPENID: "", USERREALNAME: "", GENDER: "", STREET: "", COMMUNITY: "", BLOCK: "", BUILDING: "", DOORNO: "", HOUSENO: "" }; //////加载数据;只有编辑 self.getEditInfo = function (idnum) { var data = { entity: "XG_USER", id: idnum, 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; sp.layer("#layer_search"); } }); }; //确认 self.btnSearchTrue = 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.layerhide(); sp.dialog(res.message); $timeout(function () { self.getData(self.pageno); sp.dialoghide(); }, 500); } else { sp.layerhide(); sp.dialog(res.message); } }); }; }; //取消 self.btnSearchCancel = function () { sp.layerhide(); }; self.edit = {}; ////修改身份证号 self.btnEditIDNO = function (idnum) { var data = { entity: "XG_USER", id: idnum, idName: "", fields: "" }; $http.post(apiurljs.backend + "Data/Get", data, postCfgJson) .success(function (res) { //console.log(JSON.stringify(res)); if (sp.isval(res)) { self.edit = res; sp.layer("#layer_edit_idno"); } }); }; //确认 self.btnEditTrue = function () { if (spngvld.submit("#layer_edit_idno")) { var updateData = { userid: self.edit.USERID, openid: self.edit.OPENID, idno: self.edit.idno, newidno: self.edit.IDNO_New } $http.post(apiurljs.backend + "XinGuan/UpdateRegisterIdNo", updateData, postCfgJson) .success(function (res) { //console.log(res); if (res.success) { sp.layerhide(); sp.dialog(res.message); $timeout(function () { self.get_idno = self.edit.IDNO_New; self.getData(self.pageno); sp.dialoghide(); }, 500); } else { sp.layerhide(); sp.dialog(res.message); } }); }; }; //取消 self.btnEditCancel = function () { sp.layerhide(); }; }]);