(function ($ang, win) { 'use strict'; $ang.module('gtPartyApp',[]) .controller('indexController', function ($scope, $http) { $scope.is = false; $scope.sysName=""; $scope.clearFlag = 1; $scope.selectdata = {pageindex: 1, pagesize: 15, ptotal: 0}; $scope.modulename = ''; $scope.menuLists = []; $scope.showModuleList_one = []; $scope.showModuleList_two = []; $scope.dataList_hdp = [1,2,3]; $scope.dataList_tp = [1,2,3]; $scope.dataList_wh = []; $scope.dataList_jb = []; $scope.dataList_ek = []; $scope.clearNum = function(){ if ($scope.clearFlag == 1){ $scope.clearFlag == 0; }else { $scope.clearFlag == 1; } } $scope.openUrl = function(id,dicvalue){ window.open("NewsWithPicDetail.html?id=" + id + "&modulename=" + dicvalue) } $scope.getHomeUrl=function(){ $http.get("../../api/news/GetHomeUrl", {} ).then(function (res) { $scope.homeUrl=res.data.item; }); }; $scope.getHomeUrl(); //加载所有的父菜单记录 $scope.getMenuList = function () { $http.get("../../api/news/moduleList", { params: { 'modulename': $scope.modulename, 'pageindex':$scope.selectdata.pageindex, 'pagesize':$scope.selectdata.pagesize } }).then(function (value) { $scope.menuLists = value.data.item.list; $scope.selectdata.total = value.data.item.total; }, function (reason) { console.log(reason); }); $http ({ method: 'get', url: '../../api/news/sysName', params: { } }).then(function (result) { $scope.sysName=result.data.item; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }) }; //根据当前项的menuID找到其所有的子菜单 $scope.getMenuByParentID = function (item) { if ($scope.clearFlag == 1){ $http.get("../../api/news/getmoduleList", { params: { 'parentModuleId': item.moduleid, pageindex : 1, pagesize : 999 } }).then(function (result) { item.childMenus = result.data.item.list; }, function (reason) { console.log("无匹配项"); }); } }; //获取需要展示的菜单 $scope.getShowMenuByParentID = function (flag,parentModuleId,pageSize_m,pageSize_i) { $http.get("../../api/news/getmoduleList", { params: { 'parentModuleId': parentModuleId, pageindex : 1, pagesize : pageSize_m } }).then(function (result) { if (flag == 1){ $scope.showModuleList_one = result.data.item.list; angular.forEach($scope.showModuleList_one,function(module,index,objs){ $scope.getNewsList(module,pageSize_i); }); }else { $scope.showModuleList_two = result.data.item.list; angular.forEach($scope.showModuleList_two,function(module,index,objs){ $scope.getNewsList(module,pageSize_i); }); } }, function (reason) { console.log("无匹配项"); }); }; $scope.getNewsList = function (item,pageSize){ $http ({ method: 'get', url: '../../api/news/newsList', params: { moduleId : item.moduleid, pageindex: 1, pagesize: pageSize } }).then(function (result) { item.newsList = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }) } $scope.getNewsWithPicList = function (){ $http ({ method: 'get', url: '../../api/news/newsWithPicList', params: { pageindex: 1, pagesize: 3, newstypedickey : 1, //幻灯片滚动 } }).then(function (result) { $scope.dataList_hdp = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }) $http ({ method: 'get', url: '../../api/news/newsWithPicList', params: { pageindex: 1, pagesize: 3, newstypedickey : 2, //图片滚动 } }).then(function (result) { $scope.dataList_tp = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }) $http ({ method: 'get', url: '../../api/news/newsWithPicList', params: { pageindex: 1, pagesize: 6, newstypedickey : 3, //尖兵先锋 } }).then(function (result) { $scope.dataList_jb = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }) $http ({ method: 'get', url: '../../api/news/newsWithPicList', params: { pageindex: 1, pagesize: 6, newstypedickey : 4, //文化视窗 } }).then(function (result) { $scope.dataList_wh = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }) $http ({ method: 'get', url: '../../api/news/newsWithPicList', params: { pageindex: 1, pagesize: 3, newstypedickey : 5, //E刊展示 } }).then(function (result) { $scope.dataList_ek = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }); $http ({ method: 'get', url: '../../api/mh/getLinkList', params: { pageindex: 1, pagesize: 6 } }).then(function (result) { $scope.dataList_link = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }); $http ({ method: 'get', url: '../../api/mh/getSubjectList', params: { pageindex: 1, pagesize: 6 } }).then(function (result) { $scope.dataList_subject = result.data.item.list; }, function (resp) { $scope.showMsg('错误', '服务器错误'); }); } $scope.loadData = function (){ $scope.getMenuList(); $scope.getShowMenuByParentID(1,'3889d73b-3f33-4022-b104-e33ee659748f',2,3); //党建要闻 $scope.getShowMenuByParentID(2,'75917224-df58-40bb-9e58-94630bd65078',4,5); //党建工作 $scope.getNewsWithPicList(); } $scope.loadData(); }); })(angular, this);