(function (app) { app.controller('myCtrl', ["$scope", "$state", "$http", "storage", "myService", "common", "config", "msg","$timeout" , function ($scope, $state, $http, storage, myService, common, config, msg, $timeout) { $scope.$on('$ionicView.beforeEnter', function (viewResult) { myService.myInfo().then(function(result){ console.log(result.data.data); $scope.user = result.data.data }); }); $scope.setAvator = function () { common.setAvator().then(function (result) { var response = JSON.parse(result.response); $timeout(function () { $scope.vm.avatar = response.data.file; }); }); }; }]); app.controller('profileCtrl', ["$scope", "$state","$filter", "storage", "myService", "msg", "common" , function ($scope, $state, $filter, storage, myService, msg, common) { $scope.setAvator = function () { common.setAvator().then(function (result) { var response = JSON.parse(result.response); $timeout(function () { $scope.vm.avatar = response.data.file; }); }); }; //保存个人信息 $scope.vm={ pic:"", sex:"", signture:"", emotion:"", job:"", tall:"" }; $scope.$on('$ionicView.beforeEnter', function () { msg.loading(); myService.myInfo().then(function(result){ // alert(JSON.stringify(result.data.data)); $scope.vm = result.data.data; $scope.vm.sex = $scope.vm.sex+''; $scope.vm.emotion = $scope.vm.emotion+''; if($scope.vm.birthday){ var arr1 = $scope.vm.birthday.split("-"); $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]); } msg.hide(); },function(error){ msg.hide(); // msg.error(error.data.message); }) }); $scope.saveMaterial = function(){ var data = { sex:$scope.vm.sex, signture:$scope.vm.signture, emotion:$scope.vm.emotion, work:$scope.vm.work, height:$scope.vm.height, city:$scope.vm.city }; if($scope.vm.birthday1){ data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd"); } if($scope.vm.avatar){ data.pic = $scope.vm.avatar; } msg.loading('提交中...'); myService.saveMaterial(data).then(function(result){ msg.hide(); msg.success("保存成功!"); $state.go('app.my') },function(error){ msg.hide(); msg.error(error.data.message); }) } }]); app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); //退出登陆 $scope.logout = function(){ storage.remove("token"); storage.remove("user"); $state.go("login"); } }]); app.controller('aboutMiaoCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('withdrawCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('payExplainCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('contactCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('attentionCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('personalLetterCtrl', ["$scope", "$state", "myService", "msg","storage" , function ($scope, $state,myService, msg, storage) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { myService.myInfo().then(function(result){ // alert(JSON.stringify(result.data.data)); $scope.vm = result.data.data; $scope.vm.money = ''; }) }); //充值 $scope.recharge = function(money){ myService.recharge(money).then(function(result){ $state.go('app.my'); }); } }]); app.controller('messageCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { }); //系统消息 $scope.systemInfo = function(){ myService.systemInfo().then(function(result){ },function(error){ }); }; //回复我的 $scope.replyMy = function(){ myService.replyMy().then(function(result){ //$scope.comments = result; },function(error){ }); }; }]); app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { myService.myDream().then(function(result){ $scope.dreams = result.data.data; }); myService.myInfo().then(function(result){ $scope.user = result.data.data }); }); $scope.toDetail = function (id) { $state.go('app.my_dreamdetail',{id:id}); }; }]); app.controller('collectCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { myService.collect().then(function(result){ $scope.dreams = result.data.data.dreams; $scope.users = result.data.data.users; }); }); $scope.toDetail = function (id) { $state.go('app.my_dreamdetail',{id:id}); }; }]); app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal" , function ($scope, $state, myService, msg, $ionicModal) { $ionicModal.fromTemplateUrl('my-modal.html', { scope: $scope, animation: 'slide-in-up' }).then(function (modal) { $scope.modal = modal; }); $scope.openModal = function () { $scope.modal.show(); }; $scope.closeModal = function () { $scope.modal.hide(); }; $scope.$on('$ionicView.beforeEnter', function () { }); //我的回复 $scope.vm={ content:"", comment_id:"" }; $scope.myReplay = function(){ var data = { content:$scope.vm.content, comment_id:$scope.vm.id }; myService.myReplay(data).then(function(result){ },function(error){ }); $scope.modal.hide(); } }]); })(angular.module('app.controllers'));