resourceLibraryPrivateCtrl.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. angular.module('push')
  2. .controller('resourceLibraryPrivateCtrl', function ($scope, $stateParams, $timeout, $ionicActionSheet, resourceLibraryTempData, ResourceLibraryService) {
  3. //TODO
  4. if($scope.app){
  5. $scope.setStatusBar(0);
  6. }
  7. $scope.reclib = angular.fromJson($stateParams.reclib);
  8. var getResourceLibrary = function () {
  9. ResourceLibraryService.getResourceLibrary("", $scope.reclib.id).then(function (response) {
  10. $scope.resourcelibraryclass = response;
  11. }, function () {
  12. //TODO
  13. if ($scope.resourcelibraryclass.length == 0) {
  14. $scope.shownone = true;
  15. }
  16. })
  17. };
  18. getResourceLibrary();
  19. //私人库资源库搜索
  20. $scope.goResourceSearch = function () {
  21. $timeout(function () {
  22. $scope.go('resourceSearch', {tabindex: 3});
  23. }, 350);
  24. };
  25. //网络异常时点击屏幕重新加载
  26. $scope.repeatLoad = function () {
  27. getResourceLibrary();
  28. };
  29. //进入私人资源库详情
  30. $scope.goResorceLibaryDetail = function (reclibc) {
  31. resourceLibraryTempData.setCategoryIndex(0);
  32. resourceLibraryTempData.resetChecked();
  33. if ($scope.reclib.fixtype == 1) {
  34. $scope.go('publicResource', {
  35. libtype: reclibc.moduleid,
  36. name: reclibc.name,
  37. reclibid: $scope.reclib.id,
  38. modlibid: reclibc.id
  39. });
  40. } else {
  41. $scope.go('privateResource', {
  42. reclib: angular.toJson($scope.reclib),
  43. privateName: reclibc.name,
  44. libtype: reclibc.moduleid,
  45. modlibid: reclibc.id
  46. });
  47. }
  48. };
  49. //打开操作表
  50. $scope.openActionSheet = function () {
  51. $ionicActionSheet.show({
  52. buttons: [
  53. {text: '设置'}
  54. ],
  55. cancelText: '取消',
  56. buttonClicked: function (index) {
  57. if (index == 0) {
  58. $scope.go("authoritySet", {
  59. reclibid: $scope.reclib.id,
  60. authorityid: $scope.reclib.authorityid,
  61. authoritycomefrom: $scope.reclib.authoritycomefrom,
  62. name: $scope.reclib.name,
  63. content: $scope.reclib.content,
  64. sort: $scope.reclib.sort,
  65. goflg: 1,
  66. type: 1,
  67. parentid: $scope.reclib.parentid
  68. });
  69. }
  70. return true;
  71. }
  72. });
  73. };
  74. //下拉刷新数据
  75. $scope.refreshData = function () {
  76. $scope.repeatLoad();
  77. $scope.$broadcast('scroll.refreshComplete');
  78. var trHtml = "<div class='refresh_tip_div'>更新了" + $scope.resourcelibraryclass.length + "条内容</div>";
  79. $timeout(function () {
  80. $(".calendarList-content-ul .list").prepend(trHtml);
  81. $(".refresh_tip_div").animate({width: 100 + "%"}, 150);
  82. }, 800);
  83. $timeout(function () {
  84. $(".refresh_tip_div").slideUp();
  85. }, 1200);
  86. };
  87. });