resourceListCtrl.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. angular.module('push')
  2. .controller('resourceListCtrl', function ($scope, UserService, $timeout, $stateParams, DockingService, $ionicPopup, UtilService, ModelService, $ionicListDelegate, SqliteStorageService, HandleService, $ionicActionSheet) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. var libtype = $stateParams.libtype;
  7. var reclibid = $stateParams.reclibid;
  8. $scope.privateName = $stateParams.privateName;
  9. $scope.name = $stateParams.name;
  10. var modlibid = $stateParams.modlibid;
  11. var isCloud = $stateParams.isCloud;
  12. $scope.user = UserService.user.user;
  13. $scope.userid = UserService.id;
  14. $scope.isload = false;
  15. var pageindex = 0;
  16. //取本地记录
  17. $scope.initResourceList = function () {
  18. var sql = "select * from resource where localclaid = '" + reclibid + "' and type = " + libtype + " order by timestamp desc limit 10 offset 0";
  19. SqliteStorageService.queryData(sql).then(function (response) {
  20. $scope.resourceList = response;
  21. //判读是否有下一页
  22. $scope.isload = response.length >= 10;
  23. if ($scope.isload) {
  24. pageindex = 10;
  25. }
  26. }, function () {
  27. $scope.resourceList = [];
  28. }).finally(function () {
  29. $scope.$broadcast('scroll.refreshComplete');
  30. });
  31. };
  32. $scope.initResourceList();
  33. //加载更多记录
  34. $scope.loadMore = function () {
  35. $scope.isload = false;
  36. var sql = "select * from resource where localclaid = '" + reclibid + "' and type = " + libtype + " order by timestamp desc limit 10 offset " + pageindex;
  37. SqliteStorageService.queryData(sql).then(function (response) {
  38. $scope.resourceList = $scope.resourceList.concat(response);
  39. //判读是否有下一页
  40. $scope.isload = response.length >= 10;
  41. if ($scope.isload) {
  42. pageindex += 10;
  43. }
  44. }, function () {
  45. }).finally(function () {
  46. $scope.$broadcast('scroll.infiniteScrollComplete');
  47. });
  48. };
  49. //点击进入对接详情
  50. $scope.goResourceDetail = function (rec) {
  51. $scope.go('resourceLocalDetails', {
  52. recourceid: rec.localid,
  53. recourcetype: rec.type,
  54. recourcecomefrom: rec.source,
  55. creator: rec.creator
  56. });
  57. };
  58. $scope.shareflg = false;
  59. $scope.openShare = function (tempobj, ind) {
  60. $scope.go('chooseShareResource', {
  61. chereslist: angular.toJson([tempobj.localid]),
  62. folderid: reclibid,
  63. isCloud: isCloud,
  64. recourcetype: tempobj.type,
  65. recourcecomefrom: tempobj.source
  66. });
  67. };
  68. //跳转工具搜索
  69. $scope.goToolsSearch = function () {
  70. //1:需求,2:成果,6:企业,8:人才
  71. var tabindex = 3;
  72. if (libtype == 1) {
  73. tabindex = 4;
  74. } else if (libtype == 2) {
  75. tabindex = 3;
  76. } else if (libtype == 6) {
  77. tabindex = 5;
  78. } else if (libtype == 8) {
  79. tabindex = 6;
  80. }
  81. $timeout(function () {
  82. $scope.go('resourceSearch', {resourcetype: 1001, reclibid: reclibid, tabindex: tabindex});
  83. }, 350);
  84. };
  85. $scope.refreshDate = function () {
  86. $scope.initResourceList();
  87. $scope.$broadcast('scroll.refreshComplete');
  88. var trHtml = "<div class='refresh_tip_div'>更新了" + $scope.recordList.length + "条内容</div>";
  89. $timeout(function () {
  90. $(".resourcelistDiv").prepend(trHtml);
  91. $(".refresh_tip_div").animate({width: 100 + "%"}, 150);
  92. }, 800);
  93. $timeout(function () {
  94. $(".refresh_tip_div").slideUp();
  95. }, 1200);
  96. }
  97. });