my.js 7.4 KB

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