'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination', ]); app.controller("indexCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.keyword = ""; self.getCode = function () { $http.get("js/code.txt?t=" + new Date().getTime()) .success(function (res) { console.log(res) self.code = res.bzgf; self.active = self.code[0].code; self.load(); }) } self.getCode() self.pageno = 1; self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 20, 30, 40]; self.getData = function (str, pageno) { self.list = []; self.active = str; self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var data = { token: localStorage.getItem("main-token"), keyword: self.keyword, fllb: self.active, fllbp: "标准规范", page: self.pageno, pageSize: self.itemsPerPage } $http.post(apiurljs.login + "g2app/flfg/getFlfgbb", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); console.log(res.data) self.list = res.data.result.data; self.total_count = res.data.result.total_sizes; self.list.forEach(function (item) { if (self.keyword != "") { item.fBbmc1 = item.fBbmc.replaceAll(self.keyword, "" + self.keyword + "<\/span>"); } else { item.fBbmc1 = item.fBbmc } }) }) } self.load = function () { if (self.get_pageno == undefined || self.get_pageno == null || self.get_pageno == "") { self.getData(self.active, self.pageno); } else { $timeout(function () { self.getData(self.active, self.get_pageno); }, 1) } } self.goUrl = function (item) { //window.location.href="detail.html" if (item.fWjid == null) { sp.dialog("文件不存在!") return; } else { $.cookie("GlWorkPlatform-flfg-browse", JSON.stringify(item), { path: '/', expires: 1 }); window.location.href = "detail.html?flbs=" + item.fFlbs + "&frompage=bzgf&pageno=" + self.pageno; } } $scope.getData = function () { self.getData(self.active,1) } }]) app.filter('keyword', function ($sce) { return function (str) { return $sce.trustAsHtml(str); }; }); function keyLogin() { if (event.keyCode == 13) { //回车键的键值为13 angular.element(document.getElementById('app')).scope().getData(); } }