my.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. myService.myIndex().then(function(result){
  6. console.log(result.data.data);
  7. $scope.user = result.data.data
  8. });
  9. });
  10. $scope.setAvator = function () {
  11. common.setAvator().then(function (result) {
  12. var response = JSON.parse(result.response);
  13. $timeout(function () {
  14. $scope.vm.user.avatar = response.data.md5;
  15. });
  16. }, function (erro) {
  17. msg.erro(JSON.stringify(erro));
  18. });
  19. };
  20. $scope.toprofile = function () {
  21. $state.go('app.my_profile');
  22. };
  23. //我的设置
  24. $scope.setting = function(){
  25. myService.setting().then(function(result){
  26. },function(error){
  27. });
  28. };
  29. //我的收藏
  30. $scope.collect = function(){
  31. myService.collect().then(function(result){
  32. },function(error){
  33. });
  34. };
  35. //我的梦想
  36. $scope.myDream = function(){
  37. myService.myDream().then(function(result){
  38. },function(error){
  39. });
  40. };
  41. //修改个人信息
  42. $scope.myMaterial = function(){
  43. myService.myMaterial().then(function(result){
  44. },function(error){
  45. })
  46. }
  47. }]);
  48. app.controller('profileCtrl', ["$scope", "$state","$filter", "storage", "myService", "msg", "common"
  49. , function ($scope, $state, $filter, storage, myService, msg, common) {
  50. $scope.setAvator = function () {
  51. common.setAvator().then(function (result) {
  52. debugger;
  53. var response = JSON.parse(result.response);
  54. $timeout(function () {
  55. $scope.vm.user.avatar = response.data.md5;
  56. });
  57. }, function (error) {
  58. msg.error(JSON.stringify(error));
  59. });
  60. };
  61. //保存个人信息
  62. $scope.vm={
  63. pic:"",
  64. sex:"",
  65. signture:"",
  66. emotion:"",
  67. job:"",
  68. tall:""
  69. };
  70. $scope.$on('$ionicView.beforeEnter', function () {
  71. msg.loading();
  72. myService.myIndex().then(function(result){
  73. // alert(JSON.stringify(result.data.data));
  74. $scope.vm = result.data.data;
  75. $scope.vm.sex = $scope.vm.sex+'';
  76. $scope.vm.emotion = $scope.vm.emotion+'';
  77. if($scope.vm.birthday){
  78. var arr1 = $scope.vm.birthday.split("-");
  79. $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]);
  80. }
  81. msg.hide();
  82. },function(error){
  83. msg.hide();
  84. msg.error(error.data.message);
  85. })
  86. });
  87. $scope.saveMaterial = function(){
  88. var data = {
  89. pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg',
  90. sex:$scope.vm.sex,
  91. signture:$scope.vm.signture,
  92. emotion:$scope.vm.emotion,
  93. job:$scope.vm.job,
  94. tall:$scope.vm.tall,
  95. city:$scope.vm.city
  96. };
  97. if($scope.vm.birthday1){
  98. data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
  99. }
  100. msg.loading('提交中...');
  101. myService.saveMaterial(data).then(function(result){
  102. msg.hide();
  103. msg.success("保存成功!");
  104. $state.go('app.my')
  105. },function(error){
  106. msg.hide();
  107. msg.error(error.data.message);
  108. })
  109. }
  110. }]);
  111. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage"
  112. , function ($scope, $state,myService, msg, storage) {
  113. $scope.$on('$ionicView.beforeEnter', function () {
  114. });
  115. //退出登陆
  116. $scope.logout = function(){
  117. storage.remove("token");
  118. storage.remove("user");
  119. $state.go("login");
  120. }
  121. }]);
  122. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  123. , function ($scope, $state, myService, msg) {
  124. $scope.$on('$ionicView.beforeEnter', function () {
  125. $scope.vm = {
  126. money:"",
  127. }
  128. });
  129. //充值
  130. $scope.recharge = function(money){
  131. myService.recharge(money).then(function(result){
  132. $state.go('app.my');
  133. });
  134. }
  135. }]);
  136. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  137. , function ($scope, $state, myService, msg) {
  138. $scope.$on('$ionicView.beforeEnter', function () {
  139. });
  140. //系统消息
  141. $scope.systemInfo = function(){
  142. myService.systemInfo().then(function(result){
  143. },function(error){
  144. });
  145. };
  146. //回复我的
  147. $scope.replyMy = function(){
  148. myService.replyMy().then(function(result){
  149. //$scope.comments = result;
  150. },function(error){
  151. });
  152. };
  153. }]);
  154. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  155. , function ($scope, $state, myService, msg) {
  156. $scope.$on('$ionicView.beforeEnter', function () {
  157. });
  158. }]);
  159. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  160. , function ($scope, $state, myService, msg) {
  161. $scope.$on('$ionicView.beforeEnter', function () {
  162. });
  163. }]);
  164. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  165. , function ($scope, $state, myService, msg) {
  166. $scope.$on('$ionicView.beforeEnter', function () {
  167. });
  168. }]);
  169. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  170. , function ($scope, $state, myService, msg, $ionicModal) {
  171. $ionicModal.fromTemplateUrl('my-modal.html', {
  172. scope: $scope,
  173. animation: 'slide-in-up'
  174. }).then(function (modal) {
  175. $scope.modal = modal;
  176. });
  177. $scope.openModal = function () {
  178. $scope.modal.show();
  179. };
  180. $scope.closeModal = function () {
  181. $scope.modal.hide();
  182. };
  183. $scope.$on('$ionicView.beforeEnter', function () {
  184. });
  185. //我的回复
  186. $scope.vm={
  187. content:"",
  188. comment_id:""
  189. };
  190. $scope.myReplay = function(){
  191. var data = {
  192. content:$scope.vm.content,
  193. comment_id:$scope.vm.id
  194. };
  195. myService.myReplay(data).then(function(result){
  196. },function(error){
  197. });
  198. $scope.modal.hide();
  199. }
  200. }]);
  201. })(angular.module('app.controllers'));