my.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. (function (app) {
  2. app.controller('myCtrl', ["$scope", "$state", "$http", "storage", "myService", "common", "config", "msg"
  3. , function ($scope, $state, $http, storage, myService, common, config, msg) {
  4. $scope.$on('$ionicView.beforeEnter', function (viewResult) {
  5. });
  6. $scope.testuploadFile = function(files) { //单次提交图片的函数
  7. console.log(files[0]);
  8. var formData = new FormData();
  9. formData.append('file', files[0]);
  10. formData.append('tag', 'avatar');
  11. $http({
  12. method: 'POST',
  13. url: config.server + 'api/attachment/upload',
  14. transformRequest: angular.identity,
  15. data: formData,
  16. // headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }
  17. headers: {'Content-Type': undefined}
  18. }).then(function (result) {
  19. // alert(JSON.stringify(result));
  20. console.log("attachment upload result:"+JSON.stringify(result));
  21. }, function (erro) {
  22. console.log("attachment upload erro:"+JSON.stringify(erro));
  23. })
  24. }
  25. $scope.toprofile = function () {
  26. $state.go('app.my_profile');
  27. };
  28. $scope.setting = function(){
  29. myService.setting().then(function(result){
  30. },function(erro){
  31. });
  32. }
  33. }]);
  34. app.controller('profileCtrl', ["$scope", "$state", "storage", "myService", "msg", "common"
  35. , function ($scope, $state, storage, myService, msg, common) {
  36. $scope.setAvator = function () {
  37. common.setAvator().then(function (result) {
  38. debugger;
  39. var response = JSON.parse(result.response);
  40. $timeout(function () {
  41. $scope.vm.user.avatar = response.data.md5;
  42. });
  43. }, function (erro) {
  44. msg.erro(JSON.stringify(erro));
  45. });
  46. };
  47. $scope.$on('$ionicView.beforeEnter', function () {
  48. });
  49. $scope.reset = function(){
  50. var data = {
  51. pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg',
  52. };
  53. myService.reset(data).then(function(result){
  54. },function(erro){
  55. });
  56. }
  57. }]);
  58. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage"
  59. , function ($scope, $state,myService, msg, storage) {
  60. $scope.$on('$ionicView.beforeEnter', function () {
  61. });
  62. $scope.logout = function(){
  63. storage.remove("token");
  64. storage.remove("user");
  65. $state.go("login");
  66. }
  67. }]);
  68. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  69. , function ($scope, $state, myService, msg) {
  70. $scope.$on('$ionicView.beforeEnter', function () {
  71. });
  72. $scope.recharge = function(){
  73. myService.recharge().then(function(result){
  74. },function(erro){
  75. });
  76. }
  77. }]);
  78. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  79. , function ($scope, $state, myService, msg) {
  80. $scope.$on('$ionicView.beforeEnter', function () {
  81. });
  82. $scope.systemInfo = function(){
  83. myService.systemInfo().then(function(result){
  84. },function(erro){
  85. });
  86. };
  87. $scope.replyMy = function(){
  88. myService.replyMy().then(function(result){
  89. },function(erro){
  90. });
  91. }
  92. }]);
  93. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  94. , function ($scope, $state, myService, msg) {
  95. $scope.$on('$ionicView.beforeEnter', function () {
  96. });
  97. }]);
  98. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  99. , function ($scope, $state, myService, msg) {
  100. $scope.$on('$ionicView.beforeEnter', function () {
  101. });
  102. }]);
  103. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  104. , function ($scope, $state, myService, msg) {
  105. $scope.$on('$ionicView.beforeEnter', function () {
  106. });
  107. }]);
  108. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  109. , function ($scope, $state, myService, msg, $ionicModal) {
  110. $ionicModal.fromTemplateUrl('my-modal.html', {
  111. scope: $scope,
  112. animation: 'slide-in-up'
  113. }).then(function (modal) {
  114. $scope.modal = modal;
  115. });
  116. $scope.openModal = function () {
  117. $scope.modal.show();
  118. };
  119. $scope.closeModal = function () {
  120. $scope.modal.hide();
  121. };
  122. $scope.$on('$ionicView.beforeEnter', function () {
  123. });
  124. }]);
  125. })(angular.module('app.controllers'));