home.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. (function (app) {
  2. app.controller('homeCtrl', ["$scope","$http", 'config', "$state", "msg", "$ionicPopover"
  3. , function ($scope, $http, config, $state, msg, $ionicPopover) {
  4. $scope.type = 1;//tab切换
  5. $scope.changetype = function (type) {
  6. $scope.type = type;
  7. if(type == 1){
  8. $http({
  9. method:"get",
  10. url:config.server + "api/index/hot"
  11. }).then(function (result){
  12. },function(error){
  13. })
  14. }
  15. else if(type == 2){
  16. $http({
  17. method:"get",
  18. url:config.server + "api/index/trend"
  19. }).then(function (result){
  20. },function(error){
  21. })
  22. }
  23. else if(type == 3){
  24. $http({
  25. method:"get",
  26. url:config.server + "api/index/new"
  27. }).then(function (result){
  28. },function(error){
  29. })
  30. }
  31. }
  32. $ionicPopover.fromTemplateUrl('my-popover.html', {
  33. scope: $scope
  34. }).then(function (popover) {
  35. $scope.popover = popover;
  36. });
  37. $scope.openPopover = function ($event) {
  38. $scope.popover.show($event);
  39. };
  40. $scope.closePopover = function () {
  41. $scope.popover.hide();
  42. };
  43. $scope.$on('$ionicView.beforeEnter', function () {
  44. });
  45. $scope.todetail = function () {
  46. $state.go('app.home_userdetail');
  47. };
  48. }]);
  49. app.controller('userDetailCtrl', ["$scope", "$state", "msg","homeService", "$ionicTabsDelegate"
  50. , function ($scope, $state, msg, homeService, $ionicTabsDelegate) {
  51. $scope.type = 1;//tab切换
  52. $scope.tosupport = false;
  53. $scope.support = function ($event) {
  54. $event.stopPropagation();
  55. $scope.tosupport = true;
  56. }
  57. $scope.cancelsupport = function () {
  58. $scope.tosupport = false;
  59. }
  60. $scope.changetype = function (type) {
  61. $scope.type = type;
  62. }
  63. $scope.index = 0;
  64. $scope.changeindex = function (index) {
  65. $scope.index = index;
  66. }
  67. $scope.$on('$ionicView.beforeEnter', function () {
  68. $ionicTabsDelegate.showBar(false);
  69. });
  70. $scope.$on('$ionicView.leave', function () {
  71. $ionicTabsDelegate.showBar(true);
  72. });
  73. $scope.vm = {
  74. coin:""
  75. }
  76. $scope.supportDream = function(data){
  77. var data = {
  78. dream_id:"11",
  79. coin:$scope.vm.coin
  80. };
  81. homeService.supportDream(data).then(function(result){
  82. },function(erro){
  83. })
  84. };
  85. $scope.show = function(){
  86. var obj = document.getElementById("box");
  87. obj.style = "white-space: normal;";
  88. }
  89. }]);
  90. app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  91. , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
  92. $scope.index = 0;
  93. $scope.index1 = 0;
  94. $scope.vm = {
  95. keywords : ""
  96. }
  97. $scope.ismore = true;
  98. $scope.selectHot = function (index) {
  99. $scope.index = index;
  100. }
  101. $scope.selectHistory = function (index) {
  102. $scope.index1 = index;
  103. }
  104. $scope.showmore = function () {
  105. $scope.ismore = true;
  106. }
  107. $scope.keychange = function () {
  108. $scope.ismore = false;
  109. }
  110. $scope.type = 1;
  111. $scope.changetype = function (type) {
  112. $scope.type = type;
  113. }
  114. $scope.$on('$ionicView.beforeEnter', function () {
  115. $ionicTabsDelegate.showBar(false);
  116. $ionicNavBarDelegate.showBackButton(false);
  117. });
  118. $scope.$on('$ionicView.leave', function () {
  119. $ionicTabsDelegate.showBar(true);
  120. });
  121. $scope.searchContent = function ()
  122. {
  123. homeService.searchContent($scope.vm.keywords).then(function(result){
  124. },function(error){
  125. });
  126. };
  127. }]);
  128. })(angular.module('app.controllers'));