my.js 7.3 KB

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