my.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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('aboutMiaoCtrl', ["$scope", "$state", "myService", "msg","storage"
  93. , function ($scope, $state,myService, msg, storage) {
  94. $scope.$on('$ionicView.beforeEnter', function () {
  95. });
  96. }]);
  97. app.controller('withdrawCtrl', ["$scope", "$state", "myService", "msg","storage"
  98. , function ($scope, $state,myService, msg, storage) {
  99. $scope.$on('$ionicView.beforeEnter', function () {
  100. });
  101. }]);
  102. app.controller('payExplainCtrl', ["$scope", "$state", "myService", "msg","storage"
  103. , function ($scope, $state,myService, msg, storage) {
  104. $scope.$on('$ionicView.beforeEnter', function () {
  105. });
  106. }]);
  107. app.controller('contactCtrl', ["$scope", "$state", "myService", "msg","storage"
  108. , function ($scope, $state,myService, msg, storage) {
  109. $scope.$on('$ionicView.beforeEnter', function () {
  110. });
  111. }]);
  112. app.controller('attentionCtrl', ["$scope", "$state", "myService", "msg","storage"
  113. , function ($scope, $state,myService, msg, storage) {
  114. $scope.$on('$ionicView.beforeEnter', function () {
  115. });
  116. }]);
  117. app.controller('personalLetterCtrl', ["$scope", "$state", "myService", "msg","storage"
  118. , function ($scope, $state,myService, msg, storage) {
  119. $scope.$on('$ionicView.beforeEnter', function () {
  120. });
  121. }]);
  122. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  123. , function ($scope, $state, myService, msg) {
  124. $scope.$on('$ionicView.beforeEnter', function () {
  125. myService.myInfo().then(function(result){
  126. // alert(JSON.stringify(result.data.data));
  127. $scope.vm = result.data.data;
  128. $scope.vm.money = '';
  129. })
  130. });
  131. //充值
  132. $scope.recharge = function(money){
  133. myService.recharge(money).then(function(result){
  134. $state.go('app.my');
  135. });
  136. }
  137. }]);
  138. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  139. , function ($scope, $state, myService, msg) {
  140. $scope.$on('$ionicView.beforeEnter', function () {
  141. });
  142. //系统消息
  143. $scope.systemInfo = function(){
  144. myService.systemInfo().then(function(result){
  145. },function(error){
  146. });
  147. };
  148. //回复我的
  149. $scope.replyMy = function(){
  150. myService.replyMy().then(function(result){
  151. //$scope.comments = result;
  152. },function(error){
  153. });
  154. };
  155. }]);
  156. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  157. , function ($scope, $state, myService, msg) {
  158. $scope.$on('$ionicView.beforeEnter', function () {
  159. myService.myDream().then(function(result){
  160. $scope.dreams = result.data.data;
  161. });
  162. myService.myInfo().then(function(result){
  163. $scope.user = result.data.data
  164. });
  165. });
  166. $scope.toDetail = function (id) {
  167. $state.go('app.my_dreamdetail',{id:id});
  168. };
  169. }]);
  170. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  171. , function ($scope, $state, myService, msg) {
  172. $scope.$on('$ionicView.beforeEnter', function () {
  173. myService.collect().then(function(result){
  174. $scope.dreams = result.data.data.dreams;
  175. $scope.users = result.data.data.users;
  176. });
  177. });
  178. $scope.toDetail = function (id) {
  179. $state.go('app.my_dreamdetail',{id:id});
  180. };
  181. }]);
  182. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  183. , function ($scope, $state, myService, msg) {
  184. $scope.$on('$ionicView.beforeEnter', function () {
  185. });
  186. }]);
  187. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  188. , function ($scope, $state, myService, msg, $ionicModal) {
  189. $ionicModal.fromTemplateUrl('my-modal.html', {
  190. scope: $scope,
  191. animation: 'slide-in-up'
  192. }).then(function (modal) {
  193. $scope.modal = modal;
  194. });
  195. $scope.openModal = function () {
  196. $scope.modal.show();
  197. };
  198. $scope.closeModal = function () {
  199. $scope.modal.hide();
  200. };
  201. $scope.$on('$ionicView.beforeEnter', function () {
  202. });
  203. //我的回复
  204. $scope.vm={
  205. content:"",
  206. comment_id:""
  207. };
  208. $scope.myReplay = function(){
  209. var data = {
  210. content:$scope.vm.content,
  211. comment_id:$scope.vm.id
  212. };
  213. myService.myReplay(data).then(function(result){
  214. },function(error){
  215. });
  216. $scope.modal.hide();
  217. }
  218. }]);
  219. })(angular.module('app.controllers'));