my.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. (function (app) {
  2. app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common", "config", "msg","$timeout"
  3. , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common, config, msg, $timeout) {
  4. $scope.$on('$ionicView.beforeEnter', function (viewResult) {
  5. $ionicTabsDelegate.showBar(true);
  6. myService.myInfo().then(function(result){
  7. console.log(result.data.data);
  8. $scope.user = result.data.data
  9. });
  10. });
  11. $scope.setAvator = function () {
  12. common.setAvator().then(function (result) {
  13. var response = JSON.parse(result.response);
  14. $timeout(function () {
  15. $scope.vm.avatar = response.data.file;
  16. });
  17. });
  18. };
  19. }]);
  20. app.controller('profileCtrl', ["$scope", "$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "common"
  21. , function ($scope,$ionicTabsDelegate, $state, $filter, storage, myService, msg, common) {
  22. $scope.$on('$ionicView.beforeEnter', function () {
  23. $ionicTabsDelegate.showBar(false);
  24. });
  25. $scope.setAvator = function () {
  26. common.setAvator().then(function (result) {
  27. var response = JSON.parse(result.response);
  28. $timeout(function () {
  29. $scope.vm.avatar = response.data.file;
  30. });
  31. });
  32. };
  33. //保存个人信息
  34. $scope.vm={
  35. pic:"",
  36. sex:"",
  37. signture:"",
  38. emotion:"",
  39. job:"",
  40. tall:""
  41. };
  42. $scope.$on('$ionicView.beforeEnter', function () {
  43. msg.loading();
  44. myService.myInfo().then(function(result){
  45. // alert(JSON.stringify(result.data.data));
  46. $scope.vm = result.data.data;
  47. $scope.vm.sex = $scope.vm.sex+'';
  48. $scope.vm.emotion = $scope.vm.emotion+'';
  49. if($scope.vm.birthday){
  50. var arr1 = $scope.vm.birthday.split("-");
  51. $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]);
  52. }
  53. msg.hide();
  54. },function(error){
  55. msg.hide();
  56. // msg.error(error.data.message);
  57. })
  58. });
  59. $scope.saveMaterial = function(){
  60. var data = {
  61. sex:$scope.vm.sex,
  62. signture:$scope.vm.signture,
  63. emotion:$scope.vm.emotion,
  64. work:$scope.vm.work,
  65. height:$scope.vm.height,
  66. city:$scope.vm.city
  67. };
  68. if($scope.vm.birthday1){
  69. data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
  70. }
  71. if($scope.vm.avatar){
  72. data.pic = $scope.vm.avatar;
  73. }
  74. msg.loading('提交中...');
  75. myService.saveMaterial(data).then(function(result){
  76. msg.hide();
  77. msg.success("保存成功!");
  78. $state.go('app.my');
  79. myService.myInfo();
  80. },function(error){
  81. msg.hide();
  82. msg.error(error.data.message);
  83. })
  84. }
  85. }]);
  86. app.controller('settingCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  87. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  88. $scope.$on('$ionicView.beforeEnter', function () {
  89. $ionicTabsDelegate.showBar(false);
  90. });
  91. //退出登陆
  92. $scope.logout = function(){
  93. storage.remove("token");
  94. storage.remove("user");
  95. $state.go("login");
  96. }
  97. }]);
  98. app.controller('aboutMiaoCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  99. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  100. }]);
  101. app.controller('withdrawCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  102. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  103. }]);
  104. app.controller('payoutCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  105. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  106. }]);
  107. app.controller('payExplainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  108. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  109. }]);
  110. app.controller('explainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  111. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  112. }]);
  113. app.controller('contactCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  114. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  115. }]);
  116. app.controller('attentionCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  117. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  118. }]);
  119. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  120. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  121. }]);
  122. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  123. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  124. }]);
  125. app.controller('rechargeCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  126. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  127. $scope.$on('$ionicView.beforeEnter', function () {
  128. $ionicTabsDelegate.showBar(false);
  129. myService.myInfo().then(function(result){
  130. $scope.vm = result.data.data;
  131. $scope.vm.money = '';
  132. })
  133. });
  134. $scope.payExplain = function(){
  135. $state.go("app.payExplain")
  136. };
  137. $scope.withdraw = function(){
  138. $state.go("app.withdraw")
  139. };
  140. //充值
  141. $scope.recharge = function(money){
  142. myService.recharge(money).then(function(result){
  143. msg.text("充值成功");
  144. $state.go('app.my');
  145. });
  146. }
  147. }]);
  148. app.controller('payCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  149. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  150. $scope.$on('$ionicView.beforeEnter', function () {
  151. myService.myInfo().then(function(result){
  152. $scope.vm = result.data.data;
  153. $scope.vm.money = '';
  154. })
  155. });
  156. $scope.payExplain = function(){
  157. $state.go("app.explain")
  158. };
  159. $scope.withdraw = function(){
  160. $state.go("app.payout")
  161. };
  162. //充值
  163. $scope.recharge = function(money){
  164. myService.recharge(money).then(function(result){
  165. msg.text("充值成功");
  166. $state.go('app.my');
  167. });
  168. }
  169. }]);
  170. app.controller('messageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  171. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  172. $scope.$on('$ionicView.beforeEnter', function () {
  173. $ionicTabsDelegate.showBar(false);
  174. });
  175. //系统消息
  176. $scope.systemInfo = function(){
  177. $state.go("app.my_message_sys");
  178. myService.systemInfo().then(function(result){
  179. },function(error){
  180. });
  181. };
  182. //回复我的
  183. $scope.replyMy = function(){
  184. $state.go("app.my_message_reply");
  185. myService.replyMy().then(function(result){
  186. //$scope.comments = result;
  187. },function(error){
  188. });
  189. };
  190. $scope.personalLetter = function(){
  191. $state.go("app.personalLetter");
  192. }
  193. }]);
  194. app.controller('homeMessageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  195. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  196. $scope.$on('$ionicView.beforeEnter', function () {
  197. $ionicTabsDelegate.showBar(false);
  198. });
  199. //系统消息
  200. $scope.systemInfo = function(){
  201. $state.go("app.message_sys");
  202. myService.systemInfo().then(function(result){
  203. },function(error){
  204. });
  205. };
  206. //回复我的
  207. $scope.replyMy = function(){
  208. $state.go("app.message_reply");
  209. myService.replyMy().then(function(result){
  210. //$scope.comments = result;
  211. },function(error){
  212. });
  213. };
  214. $scope.personalLetter = function(){
  215. $state.go("app.letter");
  216. }
  217. }]);
  218. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  219. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  220. $scope.$on('$ionicView.beforeEnter', function () {
  221. $ionicTabsDelegate.showBar(false);
  222. myService.myDream().then(function(result){
  223. $scope.dreams = result.data.data;
  224. });
  225. myService.myInfo().then(function(result){
  226. $scope.user = result.data.data
  227. });
  228. });
  229. $scope.toDetail = function (id) {
  230. $state.go('app.my_dreamdetail',{id:id});
  231. };
  232. }]);
  233. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  234. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  235. $scope.$on('$ionicView.beforeEnter', function () {
  236. $ionicTabsDelegate.showBar(false);
  237. myService.collect().then(function(result){
  238. $scope.dreams = result.data.data.dreams;
  239. $scope.users = result.data.data.users;
  240. });
  241. });
  242. $scope.toDetail = function (id) {
  243. $state.go('app.my_dreamdetail',{id:id});
  244. };
  245. }]);
  246. app.controller('messageSysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  247. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  248. }]);
  249. app.controller('sysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  250. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  251. }]);
  252. app.controller('letterCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  253. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  254. }]);
  255. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  256. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  257. $ionicModal.fromTemplateUrl('my-modal.html', {
  258. scope: $scope,
  259. animation: 'slide-in-up'
  260. }).then(function (modal) {
  261. $scope.modal = modal;
  262. });
  263. $scope.openModal = function () {
  264. $scope.modal.show();
  265. };
  266. $scope.closeModal = function () {
  267. $scope.modal.hide();
  268. };
  269. //我的回复
  270. $scope.vm={
  271. content:"",
  272. comment_id:""
  273. };
  274. $scope.myReplay = function(){
  275. var data = {
  276. content:$scope.vm.content,
  277. comment_id:$scope.vm.id
  278. };
  279. myService.myReplay(data).then(function(result){
  280. },function(error){
  281. });
  282. $scope.modal.hide();
  283. }
  284. }]);
  285. })(angular.module('app.controllers'));