var app = angular.module('app', ["angularUtils.directives.dirPagination"]); app.controller("indexCtrl", ["$scope", "$http", "$compile", "$timeout", function ($scope, $http, $compile, $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"); $("#content-box").height($("body").height() - 80); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; //获取一级类别 self.departList = []; self.getDepartData = function () { self.departList = []; var postData = {"pageno": "0", "pagesize": "0", "sectcode": ""} $http.post(apiurljs.login + "g2app/phonebook/querySectWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); res.data.forEach(function (item) { item.SECTIONNAME = item.SECTION + " (" + item.CHILDCOUNT + ") "; }) self.departList = res.data; //console.log(self.departList); }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } self.leftActive = "newF"; //默认newF oldF以及code\ self.leftActiveName = "新的朋友"; self.direction = ""; //user or depart //用于生成导航条的数组,只用与记录组织通讯录 self.passArray = []; self.passIndex = ""; self.changeActive = function (code, cname, item) { self.passArray = []; self.passIndex = ""; self.leftActive = code; self.leftActiveName = cname; if (code == "newF" || code == "oldF") { self.direction = ""; } else { if (parseInt(item.CHILDCOUNT) == 0) { self.direction = "user"; self.passArray.push({ level: 0, type: "user", code: code, cname: cname }); self.passIndex = 0; } else { self.direction = "depart"; self.passArray.push({ level: 0, type: "depart", code: code, cname: cname }); self.passIndex = 0; } } self.getData(1); // console.log(self.passArray); // console.log(self.passIndex); } self.noDataTip = 1; self.rows = []; self.pageno = 1; self.total_count = 0; self.itemsPerPage = 8; self.pageOptions = [8, 16, 24, 32]; self.getUserAddress = function (pageno) { self.pageno = pageno; $scope.__default__currentPage = self.pageno; var postData = { "pageno": self.pageno, "pagesize": self.itemsPerPage, "userid": self.userId, "status": "", "order": "cdate" } if (self.leftActive == "newF") { postData.status = "0"; } else if (self.leftActive == "oldF") { postData.status = "1"; } $http.post(apiurljs.login + "g2app/phonebook/queryFriendWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); //console.log(res); // res.data.forEach(function (item) { // item.SECTIONNAME = item.SECTION + " (" + item.CHILDCOUNT + ") "; // }) // self.departList = res.data; //console.log(res); if (sp.isval(res.data)) { self.noDataTip = 1; self.rows = res.data; self.total_count = res.totalCount; } else { self.rows = []; self.noDataTip = 0; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } self.getDepartList = function (pageno) { self.pageno = pageno; $scope.__default__currentPage = self.pageno; let nowItem = self.passArray[self.passIndex]; var postData = { "pageno": self.pageno, "pagesize": self.itemsPerPage, "sectcode": nowItem.code } $http.post(apiurljs.login + "g2app/phonebook/querySectUserinfoWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); console.log(res); if (sp.isval(res.data)) { self.noDataTip = 1; self.rows = res.data; self.total_count = res.totalCount; } else { self.rows = []; self.noDataTip = 0; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } self.getUserList = function (pageno) { self.pageno = pageno; $scope.__default__currentPage = self.pageno; let nowItem = self.passArray[self.passIndex]; var postData = { "pageno": self.pageno, "pagesize": self.itemsPerPage, "sectcode": nowItem.code, "userid":self.userId } $http.post(apiurljs.login + "g2app/phonebook/queryUserinfoWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); console.log(res); if (sp.isval(res.data)) { self.noDataTip = 1; self.rows = res.data; self.total_count = res.totalCount; } else { self.rows = []; self.noDataTip = 0; } }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } self.getData = function (pageno) { if (self.leftActive == "newF" || self.leftActive == "oldF") { self.getUserAddress(pageno); // } else { let nowItem = self.passArray[self.passIndex]; if (nowItem.type == "depart") { self.getDepartList(pageno); } else if (nowItem.type == "user") { self.direction = "user"; self.getUserList(pageno); } } } self.extendDepart = function (item) { if (parseInt(item.CHILDDPCOUNT) <= 0) { self.passArray.push({ level: 1, type: "user", code: item.CODE, cname: item.SECTION }); self.passIndex++; } else { self.passArray.push({ level: 1, type: "depart", code: item.CODE, cname: item.SECTION }); self.passIndex++; } self.getData(1); } //返回 self.goBack = function () { self.passIndex--; self.passArray = self.passArray.splice(0, self.passArray.length - 1); self.direction = "depart"; self.getData(1); } self.getDepartData(); self.getData(1); //删除朋友 self.deleteFirend = function (code) { var getDelID = code; var dialogHead = "温馨提示×"; var dialogBody = "