(function (app) { app.controller('myCtrl', ["$scope", "$state", "$http", "storage", "myService", "common", "config", "msg" , function ($scope, $state, $http, storage, myService, common, config, msg) { $scope.$on('$ionicView.beforeEnter', function (viewResult) { }); $scope.testuploadFile = function(files) { //单次提交图片的函数 console.log(files[0]); var formData = new FormData(); formData.append('file', files[0]); formData.append('tag', 'avatar'); $http({ method: 'POST', url: config.server + 'api/attachment/upload', transformRequest: angular.identity, data: formData, // headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' } headers: {'Content-Type': undefined} }).then(function (result) { // alert(JSON.stringify(result)); console.log("attachment upload result:"+JSON.stringify(result)); }, function (error) { console.log("attachment upload error:"+JSON.stringify(error)); }) } $scope.toprofile = function () { $state.go('app.my_profile'); }; $scope.setting = function(){ myService.setting().then(function(result){ },function(error){ }); }; $scope.collect = function(){ myService.collect().then(function(result){ },function(error){ }); }; $scope.myDream = function(){ myService.myDream().then(function(result){ },function(error){ }); } $scope.myMaterial = function(){ myService.myMaterial().then(function(result){ },function(error){ }) } }]); app.controller('profileCtrl', ["$scope", "$state", "storage", "myService", "msg", "common" , function ($scope, $state, storage, myService, msg, common) { $scope.setAvator = function () { common.setAvator().then(function (result) { debugger; var response = JSON.parse(result.response); $timeout(function () { $scope.vm.user.avatar = response.data.md5; }); }, function (error) { msg.error(JSON.stringify(error)); }); }; $scope.$on('$ionicView.beforeEnter', function () { msg.loading(); myService.myIndex().then(function(result){ // alert(JSON.stringify(result.data.data.user)); $scope.vm = result.data.data.user; msg.hide(); },function(error){ msg.hide(); msg.error(error.data.message); }) }); // $scope.vm={ // //pic:"", // sex:"1", // signture:"", // emotion:"1", // job:"", // tall:"" // }; $scope.saveMaterial = function(){ var data = { pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg', sex:$scope.vm.sex, signture:$scope.vm.signture, emotion:$scope.vm.emotion, job:$scope.vm.job, tall:$scope.vm.tall, city:$scope.vm.city } if($scope.vm.birthday1){ data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd"); } msg.loading('提交中...'); myService.saveMaterial(data).then(function(result){ msg.hide(); msg.success("保存成功!"); },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('rechargeCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { }); $scope.recharge = function(){ myService.recharge().then(function(result){ },function(error){ }); } }]); 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){ },function(error){ }); }; }]); app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); app.controller('collectCtrl', ["$scope", "$state", "myService", "msg" , function ($scope, $state, myService, msg) { $scope.$on('$ionicView.beforeEnter', function () { }); }]); 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:"" }; $scope.myReplay = function(){ var data = { content:$scope.vm.content, comment_id:'11' }; myService.myReplay(data).then(function(result){ },function(error){ }) $scope.modal.hide(); } }]); })(angular.module('app.controllers'));