my.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 (error) {
  22. console.log("attachment upload erro:"+JSON.stringify(error));
  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(error){
  31. });
  32. };
  33. $scope.collect = function(){
  34. myService.collect().then(function(result){
  35. },function(erro){
  36. });
  37. };
  38. $scope.myDream = function(){
  39. myService.myDream().then(function(result){
  40. },function(erro){
  41. });
  42. }
  43. }]);
  44. app.controller('profileCtrl', ["$scope", "$state", "storage", "myService", "msg", "common"
  45. , function ($scope, $state, storage, myService, msg, common) {
  46. $scope.setAvator = function () {
  47. common.setAvator().then(function (result) {
  48. debugger;
  49. var response = JSON.parse(result.response);
  50. $timeout(function () {
  51. $scope.vm.user.avatar = response.data.md5;
  52. });
  53. }, function (error) {
  54. msg.error(JSON.stringify(error));
  55. });
  56. };
  57. $scope.$on('$ionicView.beforeEnter', function () {
  58. });
  59. $scope.reset = function(){
  60. var data = {
  61. pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg',
  62. };
  63. myService.reset(data).then(function(result){
  64. },function(error){
  65. });
  66. }
  67. }]);
  68. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage"
  69. , function ($scope, $state,myService, msg, storage) {
  70. $scope.$on('$ionicView.beforeEnter', function () {
  71. });
  72. $scope.logout = function(){
  73. storage.remove("token");
  74. storage.remove("user");
  75. $state.go("login");
  76. }
  77. }]);
  78. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  79. , function ($scope, $state, myService, msg) {
  80. $scope.$on('$ionicView.beforeEnter', function () {
  81. });
  82. $scope.recharge = function(){
  83. myService.recharge().then(function(result){
  84. },function(erro){
  85. });
  86. }
  87. }]);
  88. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  89. , function ($scope, $state, myService, msg) {
  90. $scope.$on('$ionicView.beforeEnter', function () {
  91. });
  92. $scope.systemInfo = function(){
  93. myService.systemInfo().then(function(result){
  94. },function(error){
  95. });
  96. };
  97. $scope.replyMy = function(){
  98. myService.replyMy().then(function(result){
  99. },function(error){
  100. });
  101. };
  102. }]);
  103. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  104. , function ($scope, $state, myService, msg) {
  105. $scope.$on('$ionicView.beforeEnter', function () {
  106. });
  107. }]);
  108. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  109. , function ($scope, $state, myService, msg) {
  110. $scope.$on('$ionicView.beforeEnter', function () {
  111. });
  112. }]);
  113. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  114. , function ($scope, $state, myService, msg) {
  115. $scope.$on('$ionicView.beforeEnter', function () {
  116. });
  117. }]);
  118. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  119. , function ($scope, $state, myService, msg, $ionicModal) {
  120. $ionicModal.fromTemplateUrl('my-modal.html', {
  121. scope: $scope,
  122. animation: 'slide-in-up'
  123. }).then(function (modal) {
  124. $scope.modal = modal;
  125. });
  126. $scope.openModal = function () {
  127. $scope.modal.show();
  128. };
  129. $scope.closeModal = function () {
  130. $scope.modal.hide();
  131. };
  132. $scope.$on('$ionicView.beforeEnter', function () {
  133. });
  134. $scope.vm={
  135. content:""
  136. };
  137. $scope.myReplay = function(){
  138. var data = {
  139. content:$scope.vm.content,
  140. comment_id:'11'
  141. };
  142. myService.myReplay(data).then(function(result){
  143. },function(erro){
  144. })
  145. $scope.modal.hide();
  146. }
  147. }]);
  148. })(angular.module('app.controllers'));