my.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. city:$scope.vm.city
  90. }
  91. if($scope.vm.birthday1){
  92. data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
  93. }
  94. msg.loading('提交中...');
  95. myService.saveMaterial(data).then(function(result){
  96. msg.hide();
  97. msg.success("保存成功!");
  98. },function(error){
  99. msg.hide();
  100. msg.error(error.data.message);
  101. })
  102. }
  103. }]);
  104. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage"
  105. , function ($scope, $state,myService, msg, storage) {
  106. $scope.$on('$ionicView.beforeEnter', function () {
  107. });
  108. $scope.logout = function(){
  109. storage.remove("token");
  110. storage.remove("user");
  111. $state.go("login");
  112. }
  113. }]);
  114. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  115. , function ($scope, $state, myService, msg) {
  116. $scope.$on('$ionicView.beforeEnter', function () {
  117. });
  118. $scope.recharge = function(){
  119. myService.recharge().then(function(result){
  120. },function(error){
  121. });
  122. }
  123. }]);
  124. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  125. , function ($scope, $state, myService, msg) {
  126. $scope.$on('$ionicView.beforeEnter', function () {
  127. });
  128. $scope.systemInfo = function(){
  129. myService.systemInfo().then(function(result){
  130. },function(error){
  131. });
  132. };
  133. $scope.replyMy = function(){
  134. myService.replyMy().then(function(result){
  135. },function(error){
  136. });
  137. };
  138. }]);
  139. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  140. , function ($scope, $state, myService, msg) {
  141. $scope.$on('$ionicView.beforeEnter', function () {
  142. });
  143. }]);
  144. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  145. , function ($scope, $state, myService, msg) {
  146. $scope.$on('$ionicView.beforeEnter', function () {
  147. });
  148. }]);
  149. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  150. , function ($scope, $state, myService, msg) {
  151. $scope.$on('$ionicView.beforeEnter', function () {
  152. });
  153. }]);
  154. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  155. , function ($scope, $state, myService, msg, $ionicModal) {
  156. $ionicModal.fromTemplateUrl('my-modal.html', {
  157. scope: $scope,
  158. animation: 'slide-in-up'
  159. }).then(function (modal) {
  160. $scope.modal = modal;
  161. });
  162. $scope.openModal = function () {
  163. $scope.modal.show();
  164. };
  165. $scope.closeModal = function () {
  166. $scope.modal.hide();
  167. };
  168. $scope.$on('$ionicView.beforeEnter', function () {
  169. });
  170. $scope.vm={
  171. content:""
  172. };
  173. $scope.myReplay = function(){
  174. var data = {
  175. content:$scope.vm.content,
  176. comment_id:'11'
  177. };
  178. myService.myReplay(data).then(function(result){
  179. },function(error){
  180. })
  181. $scope.modal.hide();
  182. }
  183. }]);
  184. })(angular.module('app.controllers'));