my.js 14 KB

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