my.js 6.4 KB

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