my.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. $scope.toDetail = function(){
  119. $state.go("app.attention_Detail");
  120. }
  121. }]);
  122. app.controller('attention_DetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
  123. , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $ionicModal, $timeout, $ionicScrollDelegate, $interval) {
  124. var id = $stateParams.id;
  125. $scope.$on('$ionicView.beforeEnter', function () {
  126. $ionicTabsDelegate.showBar(false);
  127. });
  128. $scope.load = function (id) {
  129. msg.loading();
  130. homeService.dreamDetail(id).then(function (result) {
  131. msg.hide();
  132. $scope.user = result.data.data;
  133. }, function (error) {
  134. msg.hide();
  135. });
  136. };
  137. $scope.load(id);
  138. $scope.cancelSupport = function () {
  139. $scope.tosupport = false;
  140. $scope.toshare = false;
  141. };
  142. $scope.toshare = false;
  143. $scope.share = function ($event) {
  144. $event.stopPropagation();
  145. $scope.toshare = true;
  146. };
  147. $scope.shareDream = function(){
  148. $state.go("app.shareDream",{item:$scope.user});
  149. };
  150. $scope.toDetail = function (id) {
  151. $state.go('app.my_dreamdetail',{id:id});
  152. };
  153. $scope.toOldDream = function(){
  154. $state.go("app.myOldDream");
  155. };
  156. $scope.toSupportDream = function(){
  157. $state.go("app.mySupportDream");
  158. };
  159. }]);
  160. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  161. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  162. }]);
  163. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  164. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  165. }]);
  166. app.controller('rechargeCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  167. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  168. $scope.$on('$ionicView.beforeEnter', function () {
  169. $ionicTabsDelegate.showBar(false);
  170. myService.myInfo().then(function(result){
  171. $scope.vm = result.data.data;
  172. $scope.vm.money = '';
  173. })
  174. });
  175. $scope.payExplain = function(){
  176. $state.go("app.payExplain")
  177. };
  178. $scope.withdraw = function(){
  179. $state.go("app.withdraw")
  180. };
  181. //充值
  182. $scope.recharge = function(money){
  183. myService.recharge(money).then(function(result){
  184. msg.text("充值成功");
  185. $state.go('app.my');
  186. });
  187. }
  188. }]);
  189. app.controller('payCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  190. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  191. $scope.$on('$ionicView.beforeEnter', function () {
  192. myService.myInfo().then(function(result){
  193. $scope.vm = result.data.data;
  194. $scope.vm.money = '';
  195. })
  196. });
  197. $scope.payExplain = function(){
  198. $state.go("app.explain")
  199. };
  200. $scope.withdraw = function(){
  201. $state.go("app.payout")
  202. };
  203. //充值
  204. $scope.recharge = function(money){
  205. myService.recharge(money).then(function(result){
  206. msg.text("充值成功");
  207. $state.go('app.my');
  208. });
  209. }
  210. }]);
  211. app.controller('messageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  212. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  213. $scope.$on('$ionicView.beforeEnter', function () {
  214. $ionicTabsDelegate.showBar(false);
  215. });
  216. //系统消息
  217. $scope.systemInfo = function(){
  218. $state.go("app.my_message_sys");
  219. myService.systemInfo().then(function(result){
  220. },function(error){
  221. });
  222. };
  223. //回复我的
  224. $scope.replyMy = function(){
  225. $state.go("app.my_message_reply");
  226. myService.replyMy().then(function(result){
  227. //$scope.comments = result;
  228. },function(error){
  229. });
  230. };
  231. $scope.personalLetter = function(){
  232. $state.go("app.personalLetter");
  233. }
  234. }]);
  235. app.controller('homeMessageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  236. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  237. $scope.$on('$ionicView.beforeEnter', function () {
  238. $ionicTabsDelegate.showBar(false);
  239. });
  240. //系统消息
  241. $scope.systemInfo = function(){
  242. $state.go("app.message_sys");
  243. myService.systemInfo().then(function(result){
  244. },function(error){
  245. });
  246. };
  247. //回复我的
  248. $scope.replyMy = function(){
  249. $state.go("app.message_reply");
  250. myService.replyMy().then(function(result){
  251. //$scope.comments = result;
  252. },function(error){
  253. });
  254. };
  255. $scope.personalLetter = function(){
  256. $state.go("app.letter");
  257. }
  258. }]);
  259. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  260. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  261. $scope.$on('$ionicView.beforeEnter', function () {
  262. $ionicTabsDelegate.showBar(false);
  263. myService.myDream().then(function(result){
  264. $scope.dreams = result.data.data;
  265. });
  266. myService.myInfo().then(function(result){
  267. $scope.user = result.data.data
  268. });
  269. });
  270. $scope.toDetail = function (id) {
  271. $state.go('app.my_dreamdetail',{id:id});
  272. };
  273. }]);
  274. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  275. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  276. $scope.$on('$ionicView.beforeEnter', function () {
  277. $ionicTabsDelegate.showBar(false);
  278. myService.collect().then(function(result){
  279. $scope.dreams = result.data.data.dreams;
  280. $scope.users = result.data.data.users;
  281. });
  282. });
  283. $scope.toDetail = function (id) {
  284. $state.go('app.my_dreamdetail',{id:id});
  285. };
  286. }]);
  287. app.controller('messageSysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  288. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  289. }]);
  290. app.controller('sysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  291. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  292. }]);
  293. app.controller('letterCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  294. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  295. }]);
  296. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  297. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  298. $ionicModal.fromTemplateUrl('my-modal.html', {
  299. scope: $scope,
  300. animation: 'slide-in-up'
  301. }).then(function (modal) {
  302. $scope.modal = modal;
  303. });
  304. $scope.openModal = function () {
  305. $scope.modal.show();
  306. };
  307. $scope.closeModal = function () {
  308. $scope.modal.hide();
  309. };
  310. //我的回复
  311. $scope.vm={
  312. content:"",
  313. comment_id:""
  314. };
  315. $scope.myReplay = function(){
  316. var data = {
  317. content:$scope.vm.content,
  318. comment_id:$scope.vm.id
  319. };
  320. myService.myReplay(data).then(function(result){
  321. },function(error){
  322. });
  323. $scope.modal.hide();
  324. }
  325. }]);
  326. })(angular.module('app.controllers'));