123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- (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 (id) {
- $state.go('app.home_dreamdetail',id);
- };
- $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 = [];
- }
- msg.loading();
- homeService.index($scope.type, $scope.filter.pageIndex).then(function (result) {
- msg.hide();
- $scope.index.banners = result.data.data.banners;
- $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 (error) {
- msg.hide();
- });
- }
- $scope.data = {};
- $scope.load(true);
- //$scope.$on('$ionicView.enter', function () {
-
-
- //});
- }]);
- app.controller('dreamDetailCtrl', ["$scope", "$state", "msg","common","config", "homeService", "$ionicTabsDelegate","$stateParams","$ionicModal","$timeout"
- , function ($scope, $state, msg,common, config, homeService, $ionicTabsDelegate,$stateParams,$ionicModal,$itemout) {
- var id = $stateParams.id;
- id=6;
- $scope.load = function (id) {
- homeService.dreamDetail(id).then(function (result) {
- console.log(result);
- }, function (error) {
- msg.error(error.data.message);
- });
- }
- $scope.load(6);
- $scope.type = 1;//tab切换
- $scope.tosupport = false;
- $scope.support = function ($event) {
- $event.stopPropagation();
- $scope.tosupport = true;
- $scope.vm.coin = 0;
- $scope.index = 0;
- }
- $scope.cancelsupport = function () {
- $scope.tosupport = false;
- }
- $scope.changetype = function (type) {
- $scope.type = type;
- }
- $scope.index = 0;
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- });
- $scope.$on('$ionicView.leave', function () {
- $ionicTabsDelegate.showBar(true);
- });
- $scope.vm = {
- coin:"",
- comment:""
- }
- $scope.changeindex = function (index) {
- $scope.index = index;
- $scope.vm.coin = index*5;
- }
- $scope.supportDream = function(data){
- if(!$scope.vm.coin){
- msg.error("请选择梦想币数量!");
- return ;
- }
- var data = {
- id:id,
- coin:$scope.vm.coin
- };
- homeService.supportDream(data).then(function(result){
- $scope.tosupport = false;
- number = result.data.data;
- //最新支持乘数
- })
- };
- $scope.collectionDream = function(){
- homeService.collectionDream(id).then(function(result){
- //最新支持乘数
- })
- }
- $scope.showText = function(){
- $scope.aboutStyle = {
- "white-space" : "normal"
- }
- $scope.ionDownStyle = {
- "display" : "none"
- }
- }
- $scope.placeholder="评论";
- $scope.replay = function($event){
- // $event.stopPropagation();
- $scope.placeholder="回复百川";
- $scope.addReplay=true;
- $scope.vm.comment='';
- }
- $scope.comment = function(){
- $event.stopPropagation();
- $scope.placeholder="评论";
- $scope.addReplay=true;
- $scope.vm.comment='';
- }
- $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('图片选择失败');
- });
- };
- $ionicModal.fromTemplateUrl('recharge-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.rechagemodal = modal;
- });
- $scope.openRechargeModal = function() {
- $scope.rechagemodal.show();
- $scope.rvm={
- dream:'',
- about:'',
- money:''
- };
- };
- $scope.closeRechargeModal = function() {
- $scope.rechagemodal.hide();
- };
- $ionicModal.fromTemplateUrl('interaction-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.modal = modal;
- });
- $scope.openModal = function() {
- $scope.modal.show();
- $scope.ivm={
- dream:'',
- about:'',
- money:''
- };
- $scope.iimgServer = config.imgServer;
- $scope.iimgs = [];
- };
- $scope.closeModal = function() {
- $scope.modal.hide();
- };
- //当我们用到模型时,清除它!
- $scope.$on('$destroy', function() {
- $scope.modal.remove();
- });
- }]);
- 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 () {
-
-
- });
- }]);
-
-
- })(angular.module('app.controllers'));
|