my.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.myInfo().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. });
  17. };
  18. $scope.toprofile = function () {
  19. $state.go('app.my_profile');
  20. };
  21. }]);
  22. app.controller('profileCtrl', ["$scope", "$state","$filter", "storage", "myService", "msg", "common"
  23. , function ($scope, $state, $filter, storage, myService, msg, common) {
  24. $scope.setAvator = function () {
  25. common.setAvator().then(function (result) {
  26. var response = JSON.parse(result.response);
  27. $timeout(function () {
  28. $scope.vm.user.avatar = response.data.md5;
  29. });
  30. });
  31. };
  32. //保存个人信息
  33. $scope.vm={
  34. pic:"",
  35. sex:"",
  36. signture:"",
  37. emotion:"",
  38. job:"",
  39. tall:""
  40. };
  41. $scope.$on('$ionicView.beforeEnter', function () {
  42. msg.loading();
  43. myService.myInfo().then(function(result){
  44. // alert(JSON.stringify(result.data.data));
  45. $scope.vm = result.data.data;
  46. $scope.vm.sex = $scope.vm.sex+'';
  47. $scope.vm.emotion = $scope.vm.emotion+'';
  48. if($scope.vm.birthday){
  49. var arr1 = $scope.vm.birthday.split("-");
  50. $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]);
  51. }
  52. msg.hide();
  53. },function(error){
  54. msg.hide();
  55. // msg.error(error.data.message);
  56. })
  57. });
  58. $scope.saveMaterial = function(){
  59. var data = {
  60. pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg',
  61. sex:$scope.vm.sex,
  62. signture:$scope.vm.signture,
  63. emotion:$scope.vm.emotion,
  64. job:$scope.vm.job,
  65. tall:$scope.vm.tall,
  66. city:$scope.vm.city
  67. };
  68. if($scope.vm.birthday1){
  69. data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
  70. }
  71. msg.loading('提交中...');
  72. myService.saveMaterial(data).then(function(result){
  73. msg.hide();
  74. msg.success("保存成功!");
  75. $state.go('app.my')
  76. },function(error){
  77. msg.hide();
  78. msg.error(error.data.message);
  79. })
  80. }
  81. }]);
  82. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg","storage"
  83. , function ($scope, $state,myService, msg, storage) {
  84. $scope.$on('$ionicView.beforeEnter', function () {
  85. });
  86. //退出登陆
  87. $scope.logout = function(){
  88. storage.remove("token");
  89. storage.remove("user");
  90. $state.go("login");
  91. }
  92. }]);
  93. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  94. , function ($scope, $state, myService, msg) {
  95. $scope.$on('$ionicView.beforeEnter', function () {
  96. myService.myInfo().then(function(result){
  97. // alert(JSON.stringify(result.data.data));
  98. $scope.vm = result.data.data;
  99. })
  100. $scope.vm = {
  101. money:"",
  102. }
  103. });
  104. //充值
  105. $scope.recharge = function(money){
  106. myService.recharge(money).then(function(result){
  107. $state.go('app.my');
  108. });
  109. }
  110. }]);
  111. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  112. , function ($scope, $state, myService, msg) {
  113. $scope.$on('$ionicView.beforeEnter', function () {
  114. });
  115. //系统消息
  116. $scope.systemInfo = function(){
  117. myService.systemInfo().then(function(result){
  118. },function(error){
  119. });
  120. };
  121. //回复我的
  122. $scope.replyMy = function(){
  123. myService.replyMy().then(function(result){
  124. //$scope.comments = result;
  125. },function(error){
  126. });
  127. };
  128. }]);
  129. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  130. , function ($scope, $state, myService, msg) {
  131. $scope.$on('$ionicView.beforeEnter', function () {
  132. myService.myDream().then(function(result){
  133. console.log(result.data.data);
  134. $scope.dreams = result.data.data;
  135. });
  136. });
  137. $scope.toDetail = function (id) {
  138. $state.go('app.my_dreamdetail',id);
  139. };
  140. }]);
  141. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  142. , function ($scope, $state, myService, msg) {
  143. $scope.$on('$ionicView.beforeEnter', function () {
  144. myService.collect().then(function(result){
  145. console.log(result.data.data);
  146. });
  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. //我的回复
  171. $scope.vm={
  172. content:"",
  173. comment_id:""
  174. };
  175. $scope.myReplay = function(){
  176. var data = {
  177. content:$scope.vm.content,
  178. comment_id:$scope.vm.id
  179. };
  180. myService.myReplay(data).then(function(result){
  181. },function(error){
  182. });
  183. $scope.modal.hide();
  184. }
  185. }]);
  186. })(angular.module('app.controllers'));