resourceMatchCtrl.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. angular.module('push')
  2. .controller('resourceMatchCtrl', function ($scope, $stateParams, CommentService, $timeout) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. var type = $stateParams.type;
  7. var title = $stateParams.title;
  8. var categorylabel = $stateParams.categorylabel;
  9. if (type == "1") {
  10. $scope.name = "匹配需求";
  11. } else if (type == "2") {
  12. $scope.name = "匹配成果";
  13. } else if (type == "6") {
  14. $scope.name = "匹配企业";
  15. } else if (type == "8") {
  16. $scope.name = "匹配人才";
  17. } else if (type == 81) {
  18. $scope.name = "匹配记录";
  19. }
  20. $scope.isload = false;
  21. var currentPage = 1;
  22. //获取相关资源
  23. $scope.getRelativeResource = function () {
  24. $scope.showLoadingToast();
  25. CommentService.getRelativeResource(type, title, categorylabel, "", $stateParams.unique, $stateParams.recordid).then(function (response) {
  26. // console.log(response);
  27. $scope.relativelist = response.resourcelibrary;
  28. $timeout(function () {
  29. if (currentPage >= response.page.totalPage) {
  30. $scope.isload = false;
  31. } else {
  32. $scope.isload = true;
  33. }
  34. currentPage = 2;
  35. }, 1000);
  36. $scope.hideLoadingToast();
  37. }, function () {
  38. $scope.hideLoadingToast();
  39. }).finally(function () {
  40. $scope.$broadcast('scroll.refreshComplete');
  41. });
  42. };
  43. $scope.getRelativeResource();
  44. //加载更多资源列表
  45. $scope.loadMore = function () {
  46. $scope.isload = false;
  47. $scope.showLoadingToast();
  48. CommentService.loadMoreRelativeResource(type, title, categorylabel, "", currentPage, $stateParams.unique, $stateParams.recordid).then(function (response) {
  49. // console.log(response);
  50. if (response.resourcelibrary.length > 0) {
  51. currentPage++;
  52. $scope.relativelist = $scope.relativelist.concat(response.resourcelibrary);
  53. }
  54. //判断是否有下一页
  55. $timeout(function () {
  56. if (currentPage >= response.page.totalPage) {
  57. $scope.isload = false;
  58. } else {
  59. $scope.isload = true;
  60. }
  61. }, 1000);
  62. $scope.hideLoadingToast();
  63. }, function () {
  64. $scope.hideLoadingToast();
  65. }).finally(function () {
  66. $scope.$broadcast('scroll.infiniteScrollComplete');
  67. });
  68. };
  69. //进入资源详情
  70. $scope.goResourceDetail = function (resource) {
  71. if (resource.type == 81) {
  72. $scope.go('cloudDockingdetail', {infoid: resource.id, creator: resource.creator});
  73. } else {
  74. if (resource.groupid == "0") {
  75. $scope.go('resourceDetails', {
  76. recourceid: resource.unique,
  77. recourcetype: resource.type,
  78. recourcecomefrom: resource.source
  79. });
  80. } else {
  81. $scope.go('resourcePrivateDetails', {
  82. recourceid: resource.unique,
  83. recourcetype: resource.type,
  84. recourcecomefrom: resource.source,
  85. creator: resource.clickthrough
  86. });
  87. }
  88. }
  89. };
  90. $scope.matchSearch = function () {
  91. $timeout(function () {
  92. $scope.go('resourceMatchSearch', {
  93. type: type,
  94. title: title,
  95. categorylabel: categorylabel,
  96. unique: $stateParams.unique,
  97. recordid: $stateParams.recordid
  98. })
  99. }, 320);
  100. };
  101. });