my.js 8.7 KB

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