home.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.showText = function(){
  96. $scope.aboutStyle = {
  97. "white-space" : "normal"
  98. }
  99. $scope.ionDownStyle = {
  100. "display" : "none"
  101. }
  102. }
  103. }]);
  104. app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  105. , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
  106. $scope.index = 0;
  107. $scope.index1 = 0;
  108. $scope.vm = {
  109. keywords : ""
  110. }
  111. $scope.ismore = true;
  112. $scope.selectHot = function (index) {
  113. $scope.index = index;
  114. }
  115. $scope.selectHistory = function (index) {
  116. $scope.index1 = index;
  117. }
  118. $scope.showmore = function () {
  119. $scope.ismore = true;
  120. }
  121. $scope.keychange = function () {
  122. $scope.ismore = false;
  123. }
  124. $scope.type = 1;
  125. $scope.changetype = function (type) {
  126. $scope.type = type;
  127. }
  128. $scope.$on('$ionicView.beforeEnter', function () {
  129. $ionicTabsDelegate.showBar(false);
  130. $ionicNavBarDelegate.showBackButton(false);
  131. });
  132. $scope.$on('$ionicView.leave', function () {
  133. $ionicTabsDelegate.showBar(true);
  134. });
  135. $scope.searchContent = function ()
  136. {
  137. homeService.searchContent($scope.vm.keywords).then(function(result){
  138. },function(error){
  139. });
  140. };
  141. }]);
  142. app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  143. , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) {
  144. $scope.$on('$ionicView.beforeEnter', function () {
  145. $ionicTabsDelegate.showBar(false);
  146. $ionicNavBarDelegate.showBackButton(false);
  147. $scope.vm={
  148. dream:'',
  149. about:'',
  150. money:''
  151. };
  152. $scope.imgServer = config.imgServer;
  153. $scope.imgs = [];
  154. });
  155. $scope.addpict = function () {
  156. common.chooseImage().then(function (img) {
  157. common.uploadFiles(img,1).then(function (result) {
  158. var response = JSON.parse(result.response);
  159. var file = response.data.file;
  160. $scope.imgs.push(file);
  161. }, function (error) {
  162. msg.error('图片上传失败');
  163. });
  164. }, function (error) {
  165. console.log('图片选择失败');
  166. });
  167. };
  168. $scope.add = function () {
  169. };
  170. }]);
  171. })(angular.module('app.controllers'));