my.js 7.4 KB

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