angular.module('push') .controller('resourceMatchCtrl', function ($scope, $stateParams, CommentService, $timeout) { if($scope.app){ $scope.setStatusBar(0); } var type = $stateParams.type; var title = $stateParams.title; var categorylabel = $stateParams.categorylabel; if (type == "1") { $scope.name = "匹配需求"; } else if (type == "2") { $scope.name = "匹配成果"; } else if (type == "6") { $scope.name = "匹配企业"; } else if (type == "8") { $scope.name = "匹配人才"; } else if (type == 81) { $scope.name = "匹配记录"; } $scope.isload = false; var currentPage = 1; //获取相关资源 $scope.getRelativeResource = function () { $scope.showLoadingToast(); CommentService.getRelativeResource(type, title, categorylabel, "", $stateParams.unique, $stateParams.recordid).then(function (response) { // console.log(response); $scope.relativelist = response.resourcelibrary; $timeout(function () { if (currentPage >= response.page.totalPage) { $scope.isload = false; } else { $scope.isload = true; } currentPage = 2; }, 1000); $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); }).finally(function () { $scope.$broadcast('scroll.refreshComplete'); }); }; $scope.getRelativeResource(); //加载更多资源列表 $scope.loadMore = function () { $scope.isload = false; $scope.showLoadingToast(); CommentService.loadMoreRelativeResource(type, title, categorylabel, "", currentPage, $stateParams.unique, $stateParams.recordid).then(function (response) { // console.log(response); if (response.resourcelibrary.length > 0) { currentPage++; $scope.relativelist = $scope.relativelist.concat(response.resourcelibrary); } //判断是否有下一页 $timeout(function () { if (currentPage >= response.page.totalPage) { $scope.isload = false; } else { $scope.isload = true; } }, 1000); $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); }).finally(function () { $scope.$broadcast('scroll.infiniteScrollComplete'); }); }; //进入资源详情 $scope.goResourceDetail = function (resource) { if (resource.type == 81) { $scope.go('cloudDockingdetail', {infoid: resource.id, creator: resource.creator}); } else { if (resource.groupid == "0") { $scope.go('resourceDetails', { recourceid: resource.unique, recourcetype: resource.type, recourcecomefrom: resource.source }); } else { $scope.go('resourcePrivateDetails', { recourceid: resource.unique, recourcetype: resource.type, recourcecomefrom: resource.source, creator: resource.clickthrough }); } } }; $scope.matchSearch = function () { $timeout(function () { $scope.go('resourceMatchSearch', { type: type, title: title, categorylabel: categorylabel, unique: $stateParams.unique, recordid: $stateParams.recordid }) }, 320); }; });