12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- '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");
- self.get_pageno = sp.getUrlName("pageno");
- 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) {
- self.code = res.flgf;
- 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, "<span \class='sp-color-red'\>" + 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) {
- $.cookie("GlWorkPlatform-flfg-keywork", self.keyword, { path: '/', expires: 1 });
- window.location.href = "detail.html?flbs=" + item.fFlbs + "&frompage=flgf&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();
- }
- }
|