my.js 7.7 KB

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