(function ($ang, win) { 'use strict'; $ang.module('gtPartyApp', []) .controller('newswithpicdetailController', function ($scope, $http) { $scope.sysName = ""; $scope.dataModel = []; var url = location.search //获取url中"?"符后的字串 var theRequest = new Object() if (url.indexOf('?') != -1) { var str = url.substr(1) //substr()方法返回从参数值开始到结束的字符串; var strs = str.split('&') for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1] } } $scope.id = theRequest.id; $scope.modulename_in = decodeURI(theRequest.modulename); $scope.clearFlag = 1; $scope.selectdata = {pageindex: 1, pagesize: 15, ptotal: 0}; $scope.modulename = ''; $scope.menuLists = []; $scope.clearNum = function(){ if ($scope.clearFlag == 1){ $scope.clearFlag == 0; }else { $scope.clearFlag == 1; } } $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.getSingleMenu = function () { $http.get("../../api/news/getModule", { params: { 'moduleId': $scope.moduleid, } }).then(function (value) { $scope.menuInfo = value.data.item; }, function (reason) { console.log(reason); }); }; //获取图片 $scope.getImgList = function () { $http ({ method: 'get', url: '../../api/filemgr/getFileList', params: { filerefid: $scope.id , pageindex: 1, pagesize: 1000 } }).then(function (result) { $scope.imgList = result.data.item.list; console.log($scope.imgList) }); }; $scope.loadData = function () { $scope.getMenuList(); $scope.getSingleMenu(); $scope.getImgList(); $http.get("../../api/news/getNewsWithPic", { params: { 'ID': $scope.id, } }).then(function (result) { $scope.dataModel = result.data.item; }, function () { $scope.showMsg('错误', '服务器错误'); }); } $scope.loadData(); }).filter('trust2Html', ['$sce',function($sce) { return function(val) { return $sce.trustAsHtml(val); }; }]); })(angular, this);