my.js 6.8 KB

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