'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination', ]); app.controller("indexCtrl", ["$scope", "$http", "$interval", "$timeout", "$sce", function ($scope, $http, $interval, $timeout, $sce) { var self = this; self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-username"); self.userChineseName = $.cookie("GlWorkPlatform-chineseName") self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; /*新闻*/ self.getDataImg = function () { var data = { tablename: "WJFB_TPXW", pagesize: 10, pageno: 1, colums: "ID,BT,FBRQ,IMAGEDATA", order: "ID", sqlwhere: { FBZT: "1" }, sqlorwhere: "", sqlinwhere: "", sqllikewhere: "" }; $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.newsImg = res.data; console.log(self.newsImg) $.each(self.newsImg, function (index, item) { if (item.IMAGEDATA != "[]" && item.IMAGEDATA != "") { item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + JSON.parse(item.IMAGEDATA)[0].FILEURL) } else { item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + JSON.parse(item.IMAGESDATA)[0].FILEURL) } }) if (self.newsImg.length > 1) { $timeout(function () { var swiper = new Swiper('.swiper-container', { loop: true, autoplay: { delay: 2000, disableOnInteraction: false, }, slidesPerView: 1, centeredSlides: true, pagination: { el: '.swiper-pagination', clickable: true, } }) }, 1) } }) } self.getDataImg() $timeout(function () { var swiper = new Swiper('.swiper-container', { loop: true, autoplay: { delay: 3000, disableOnInteraction: false, }, slidesPerView: 1, centeredSlides: true, spaceBetween: 30, pagination: { el: '.swiper-pagination', clickable: true, } }) }, 1) $('#newsList').settabs({ event: 'click' }); self.check = 1; self.getData = function () { var sqlwhere = "", TABLENAME = "", BT = ""; switch (self.check) { case 1: sqlwhere = { GGBK: "C03", FBZT: "1" }; BT = "GGBT,FBSJ"; TABLENAME = "SX_TZGG"; break; case 2: sqlwhere = { LX: "C04", FBZT: "1" }; BT = "WJBT,FBRQ"; TABLENAME = "WJFB_CB"; break; case 3: sqlwhere = { LX: "C12", FBZT: "1" }; BT = "WJBT,FBRQ"; TABLENAME = "WJFB_CB"; break; } var data = { tablename: TABLENAME, pagesize: 7, pageno: 1, colums: "ID," + BT, order: "ID", sqlwhere: sqlwhere, sqlorwhere: "", sqlinwhere: "", sqllikewhere: "" }; $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.list = res.data; self.list.forEach(function (item) { item.BT = item.WJBT ? item.WJBT : item.GGBT; }) }) } self.getData() }])