home.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. (function (app) {
  2. app.controller('homeCtrl', ["$scope", "$http", 'config', "$state", "msg", "$ionicPopover", "homeService"
  3. , function ($scope, $http, config, $state, msg, $ionicPopover, homeService) {
  4. $scope.type = 'hot';//tab切换
  5. $ionicPopover.fromTemplateUrl('my-popover.html', {
  6. scope: $scope
  7. }).then(function (popover) {
  8. $scope.popover = popover;
  9. });
  10. $scope.openPopover = function ($event) {
  11. $scope.popover.show($event);
  12. };
  13. $scope.closePopover = function () {
  14. $scope.popover.hide();
  15. };
  16. $scope.changetype = function (type) {
  17. $scope.type = type;
  18. $scope.load(true);
  19. }
  20. $scope.todetail = function () {
  21. $state.go('app.home_dreamdetail');
  22. };
  23. $scope.filter = {
  24. hasMore: false,
  25. pageIndex: 1,
  26. pageSize: 20,
  27. }
  28. $scope.index = {
  29. banner: [],
  30. users: [],
  31. dreams:[]
  32. };
  33. $scope.load = function (init) {
  34. if (init) {
  35. $scope.filter.pageIndex = 1;
  36. $scope.index.dreams = [];
  37. }
  38. homeService.index($scope.type, $scope.filter.pageIndex).then(function (result) {
  39. $scope.index.banner = result.data.data.banner;
  40. $scope.index.users = result.data.data.users;
  41. $scope.filter.pageIndex++;
  42. var more = (result.data.data.dreams.data.length >= $scope.filter.pageSize);
  43. $scope.filter.hasMore = more;
  44. $scope.index.dreams = $scope.index.dreams.concat(result.data.data.dreams.data);
  45. if (init) {
  46. $scope.$broadcast('scroll.refreshComplete');
  47. } else {
  48. $scope.$broadcast('scroll.infiniteScrollComplete');
  49. }
  50. }, function (erro) {
  51. msg.error(erro.data.Message);
  52. });
  53. }
  54. $scope.data = {};
  55. $scope.load(true);
  56. //$scope.$on('$ionicView.enter', function () {
  57. //});
  58. }]);
  59. app.controller('dreamDetailCtrl', ["$scope", "$state", "msg", "homeService", "$ionicTabsDelegate"
  60. , function ($scope, $state, msg, homeService, $ionicTabsDelegate) {
  61. $scope.type = 1;//tab切换
  62. $scope.tosupport = false;
  63. $scope.support = function ($event) {
  64. $event.stopPropagation();
  65. $scope.tosupport = true;
  66. }
  67. $scope.cancelsupport = function () {
  68. $scope.tosupport = false;
  69. }
  70. $scope.changetype = function (type) {
  71. $scope.type = type;
  72. }
  73. $scope.index = 0;
  74. $scope.changeindex = function (index) {
  75. $scope.index = index;
  76. }
  77. $scope.$on('$ionicView.beforeEnter', function () {
  78. $ionicTabsDelegate.showBar(false);
  79. });
  80. $scope.$on('$ionicView.leave', function () {
  81. $ionicTabsDelegate.showBar(true);
  82. });
  83. $scope.vm = {
  84. coin:""
  85. }
  86. $scope.supportDream = function(data){
  87. var data = {
  88. dream_id:"11",
  89. coin:$scope.vm.coin
  90. };
  91. homeService.supportDream(data).then(function(result){
  92. },function(erro){
  93. })
  94. };
  95. $scope.show = function(){
  96. var obj = document.getElementById("box");
  97. obj.style = "white-space: normal;";
  98. }
  99. }]);
  100. app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  101. , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
  102. $scope.index = 0;
  103. $scope.index1 = 0;
  104. $scope.vm = {
  105. keywords : ""
  106. }
  107. $scope.ismore = true;
  108. $scope.selectHot = function (index) {
  109. $scope.index = index;
  110. }
  111. $scope.selectHistory = function (index) {
  112. $scope.index1 = index;
  113. }
  114. $scope.showmore = function () {
  115. $scope.ismore = true;
  116. }
  117. $scope.keychange = function () {
  118. $scope.ismore = false;
  119. }
  120. $scope.type = 1;
  121. $scope.changetype = function (type) {
  122. $scope.type = type;
  123. }
  124. $scope.$on('$ionicView.beforeEnter', function () {
  125. $ionicTabsDelegate.showBar(false);
  126. $ionicNavBarDelegate.showBackButton(false);
  127. });
  128. $scope.$on('$ionicView.leave', function () {
  129. $ionicTabsDelegate.showBar(true);
  130. });
  131. $scope.searchContent = function ()
  132. {
  133. homeService.searchContent($scope.vm.keywords).then(function(result){
  134. },function(error){
  135. });
  136. };
  137. }]);
  138. app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  139. , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) {
  140. $scope.$on('$ionicView.beforeEnter', function () {
  141. $ionicTabsDelegate.showBar(false);
  142. $ionicNavBarDelegate.showBackButton(false);
  143. $scope.vm={
  144. dream:'',
  145. about:'',
  146. money:''
  147. };
  148. $scope.imgServer = config.imgServer;
  149. $scope.imgs = [];
  150. });
  151. $scope.addpict = function () {
  152. common.chooseImage().then(function (img) {
  153. common.uploadFiles(img,1).then(function (result) {
  154. var response = JSON.parse(result.response);
  155. var file = response.data.file;
  156. $scope.imgs.push(file);
  157. }, function (error) {
  158. msg.error('图片上传失败');
  159. });
  160. }, function (error) {
  161. console.log('图片选择失败');
  162. });
  163. };
  164. $scope.add = function () {
  165. };
  166. }]);
  167. })(angular.module('app.controllers'));