my.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. msg.loading();
  64. myService.myIndex().then(function(result){
  65. // alert(JSON.stringify(result.data.data.user));
  66. $scope.vm = result.data.data.user;
  67. msg.hide();
  68. },function(error){
  69. msg.hide();
  70. msg.error(error.data.message);
  71. })
  72. });
  73. // $scope.vm={
  74. // //pic:"",
  75. // sex:"1",
  76. // signture:"",
  77. // emotion:"1",
  78. // job:"",
  79. // tall:""
  80. // };
  81. $scope.saveMaterial = function(){
  82. var data = {
  83. pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg',
  84. sex:$scope.vm.sex,
  85. signture:$scope.vm.signture,
  86. emotion:$scope.vm.emotion,
  87. job:$scope.vm.job,
  88. tall:$scope.vm.tall
  89. }
  90. msg.loading('提交中...');
  91. myService.saveMaterial(data).then(function(result){
  92. msg.hide();
  93. msg.success("保存成功!");
  94. },function(error){
  95. msg.hide();
  96. msg.error(error.data.message);
  97. })
  98. }
  99. }]);
  100. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage"
  101. , function ($scope, $state,myService, msg, storage) {
  102. $scope.$on('$ionicView.beforeEnter', function () {
  103. });
  104. $scope.logout = function(){
  105. storage.remove("token");
  106. storage.remove("user");
  107. $state.go("login");
  108. }
  109. }]);
  110. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  111. , function ($scope, $state, myService, msg) {
  112. $scope.$on('$ionicView.beforeEnter', function () {
  113. });
  114. $scope.recharge = function(){
  115. myService.recharge().then(function(result){
  116. },function(error){
  117. });
  118. }
  119. }]);
  120. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  121. , function ($scope, $state, myService, msg) {
  122. $scope.$on('$ionicView.beforeEnter', function () {
  123. });
  124. $scope.systemInfo = function(){
  125. myService.systemInfo().then(function(result){
  126. },function(error){
  127. });
  128. };
  129. $scope.replyMy = function(){
  130. myService.replyMy().then(function(result){
  131. },function(error){
  132. });
  133. };
  134. }]);
  135. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  136. , function ($scope, $state, myService, msg) {
  137. $scope.$on('$ionicView.beforeEnter', function () {
  138. });
  139. }]);
  140. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  141. , function ($scope, $state, myService, msg) {
  142. $scope.$on('$ionicView.beforeEnter', function () {
  143. });
  144. }]);
  145. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  146. , function ($scope, $state, myService, msg) {
  147. $scope.$on('$ionicView.beforeEnter', function () {
  148. });
  149. }]);
  150. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  151. , function ($scope, $state, myService, msg, $ionicModal) {
  152. $ionicModal.fromTemplateUrl('my-modal.html', {
  153. scope: $scope,
  154. animation: 'slide-in-up'
  155. }).then(function (modal) {
  156. $scope.modal = modal;
  157. });
  158. $scope.openModal = function () {
  159. $scope.modal.show();
  160. };
  161. $scope.closeModal = function () {
  162. $scope.modal.hide();
  163. };
  164. $scope.$on('$ionicView.beforeEnter', function () {
  165. });
  166. $scope.vm={
  167. content:""
  168. };
  169. $scope.myReplay = function(){
  170. var data = {
  171. content:$scope.vm.content,
  172. comment_id:'11'
  173. };
  174. myService.myReplay(data).then(function(result){
  175. },function(error){
  176. })
  177. $scope.modal.hide();
  178. }
  179. }]);
  180. })(angular.module('app.controllers'));