(function (app) { app.controller('homeCtrl', ["$scope", "$http", 'config', "$state", "msg", "$ionicPopover", "homeService" , function ($scope, $http, config, $state, msg, $ionicPopover, homeService) { $scope.type = 'hot';//tab切换 $ionicPopover.fromTemplateUrl('my-popover.html', { scope: $scope }).then(function (popover) { $scope.popover = popover; }); $scope.openPopover = function ($event) { $scope.popover.show($event); }; $scope.closePopover = function () { $scope.popover.hide(); }; $scope.changetype = function (type) { $scope.type = type; $scope.load(true); } $scope.todetail = function () { $state.go('app.home_dreamdetail'); }; $scope.filter = { hasMore: false, pageIndex: 1, pageSize: 20, } $scope.index = { banner: [], users: [], dreams:[] }; $scope.load = function (init) { if (init) { $scope.filter.pageIndex = 1; $scope.index.dreams = []; } homeService.index($scope.type, $scope.filter.pageIndex).then(function (result) { $scope.index.banner = result.data.data.banner; $scope.index.users = result.data.data.users; $scope.filter.pageIndex++; var more = (result.data.data.dreams.data.length >= $scope.filter.pageSize); $scope.filter.hasMore = more; $scope.index.dreams = $scope.index.dreams.concat(result.data.data.dreams.data); if (init) { $scope.$broadcast('scroll.refreshComplete'); } else { $scope.$broadcast('scroll.infiniteScrollComplete'); } }, function (erro) { msg.error(erro.data.Message); }); } $scope.data = {}; $scope.load(true); //$scope.$on('$ionicView.enter', function () { //}); }]); app.controller('dreamDetailCtrl', ["$scope", "$state", "msg", "homeService", "$ionicTabsDelegate" , function ($scope, $state, msg, homeService, $ionicTabsDelegate) { $scope.type = 1;//tab切换 $scope.tosupport = false; $scope.support = function ($event) { $event.stopPropagation(); $scope.tosupport = true; } $scope.cancelsupport = function () { $scope.tosupport = false; } $scope.changetype = function (type) { $scope.type = type; } $scope.index = 0; $scope.changeindex = function (index) { $scope.index = index; } $scope.$on('$ionicView.beforeEnter', function () { $ionicTabsDelegate.showBar(false); }); $scope.$on('$ionicView.leave', function () { $ionicTabsDelegate.showBar(true); }); $scope.vm = { coin:"" } $scope.supportDream = function(data){ var data = { dream_id:"11", coin:$scope.vm.coin }; homeService.supportDream(data).then(function(result){ },function(erro){ }) }; $scope.showText = function(){ $scope.aboutStyle = { "white-space" : "normal" } $scope.ionDownStyle = { "display" : "none" } } }]); app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate" , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) { $scope.index = 0; $scope.index1 = 0; $scope.vm = { keywords : "" } $scope.ismore = true; $scope.selectHot = function (index) { $scope.index = index; } $scope.selectHistory = function (index) { $scope.index1 = index; } $scope.showmore = function () { $scope.ismore = true; } $scope.keychange = function () { $scope.ismore = false; } $scope.type = 1; $scope.changetype = function (type) { $scope.type = type; } $scope.$on('$ionicView.beforeEnter', function () { $ionicTabsDelegate.showBar(false); $ionicNavBarDelegate.showBackButton(false); }); $scope.$on('$ionicView.leave', function () { $ionicTabsDelegate.showBar(true); }); $scope.searchContent = function () { homeService.searchContent($scope.vm.keywords).then(function(result){ },function(error){ }); }; }]); app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate" , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) { $scope.$on('$ionicView.beforeEnter', function () { $ionicTabsDelegate.showBar(false); $ionicNavBarDelegate.showBackButton(false); $scope.vm={ dream:'', about:'', money:'' }; $scope.imgServer = config.imgServer; $scope.imgs = []; }); $scope.addpict = function () { common.chooseImage().then(function (img) { common.uploadFiles(img,1).then(function (result) { var response = JSON.parse(result.response); var file = response.data.file; $scope.imgs.push(file); }, function (error) { msg.error('图片上传失败'); }); }, function (error) { console.log('图片选择失败'); }); }; $scope.add = function () { }; }]); })(angular.module('app.controllers'));