text: /*
  * @description: 友情、热门链接js
  * @author: billy
  * @update: billy (2018-02-22 10:10)
  * @version: v1.0
  */
  var app = angular.module('myApp', ['tm.pagination','ngCookies']);
  app.controller('listController', function ($scope, $http,$cookies,$compile) {
      if($cookies.get("currentPage")!=''){
          $scope.currentPage=$cookies.get("currentPage");
      }
      var reSearch = function () {
          var postData = {
              type: 'list',
              name: $scope.name,
              typeId: $scope.typeId,
              currentPage: $scope.paginationConf.currentPage,
              itemsPerPage: $scope.paginationConf.itemsPerPage,
          };
          $http.post('../../Controller/article/linkListAction.php', postData).then(function (result) {  //正确请求成功时处理
          	$scope.paginationConf.totalItems = result.data.rowCount;
              $scope.list = result.data.data;
          }).catch(function () { //捕捉错误处理
              layer.msg('服务端请求错误！', {time: 3000});
          });
      }
      $scope.reSearch = reSearch;
      $scope.paginationConf = {//配置分页基本参数
          currentPage: $scope.currentPage ? $scope.currentPage : 1, //起始页
          itemsPerPage: 10, // 每页展示的数据条数
          perPageOptions: [10, 30, 50] //可选择显示条数的数组
      };
      $scope.$watch('paginationConf.currentPage + paginationConf.itemsPerPage', reSearch);
      $scope.editModel = function(type,id){
          var currentPage = $scope.paginationConf.currentPage;
          $cookies.put("currentPage", currentPage, {expires: new Date(new Date().getTime() + 36000)});
      	if(type=="添加"){
      		layer.open({
                  type: 2,
                  title: '添加链接',
                  area: ['100%', '100%'],
                  anim: '2',
                  resize: false,
                  move: false,
                  shadeClose: true,
                  offset: ['0', '0'],
                  content: 'reviceLink.php?type=add',
              });
      	}else{
      		layer.open({
                  type: 2,
                  title: '修改链接',
                  area: ['100%', '100%'],
                  anim: '2',
                  resize: false,
                  move: false,
                  shadeClose: true,
                  offset: ['0', '0'],
                  content: 'reviceLink.php?id='+id+'&type=modify',
              });
      	}
      }
      $scope.delModel=function (id,type){
      		if(type==1){
      			type = "友情链接";
      		}else if(type==2){
      			type = "热门链接";
      		}
  	        var postData = {type: 'del', id: id};
  	        layer.alert('您确定要删除该'+type+'吗?', {icon: 5, title: "删除", resize: false,}, function(){
  	            $http.post('../../Controller/article/linkListAction.php', postData).then(function (result) {  //正确请求成功时处理
  	            	if (result.data.code>0) { 
  	            		layer.msg(result.data.message, {icon: 6, time: 1500});
  	                    return reSearch();
  	                } else {
  	                	layer.msg(result.data.message, {icon: 5, time: 1500});
  	                }
  	            }).catch(function () { //捕捉错误处理
  	                layer.msg('服务端请求错误！', {time: 3000});
  	            });
  	        });
      }
      $scope.resetSearch = function(){
          $scope.currentPage = 0;
          $scope.name = '';
          $scope.typeId = '';
      }
  });