home.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. (function (app) {
  2. app.controller('homeCtrl', ["$scope", "$ionicTabsDelegate","storage", "$http", 'config', 'myService', "$state", "$ionicSlideBoxDelegate", "msg", "$ionicPopover", "homeService", "$ionicPopup", "$timeout", "$ionicSideMenuDelegate", "$rootScope"
  3. , function ($scope, $ionicTabsDelegate,storage, $http, config, myService, $state, $ionicSlideBoxDelegate, msg, $ionicPopover, homeService, $ionicPopup, $timeout, $ionicSideMenuDelegate, $rootScope) {
  4. $scope.$on('$ionicView.enter', function () {
  5. $ionicTabsDelegate.showBar(true);
  6. $scope.load(false);
  7. $ionicSlideBoxDelegate.start();
  8. $scope.step = storage.getObject('user').step;
  9. var width = window.screen.width;
  10. if(width>300&width<370){
  11. $scope.screenWidth = 0;
  12. }
  13. else if(width>=370&width<400){
  14. $scope.screenWidth = 1;
  15. }
  16. else{
  17. $scope.screenWidth = 2;
  18. }
  19. homeService.messageInfo().then(function(result){
  20. $scope.infos = result.data.data;
  21. if($scope.infos.dream_info.number==0 && $scope.infos.sup_info.number==0 && $scope.infos.system_info.number==0){
  22. $scope.showMessage=0;
  23. }
  24. else {
  25. $scope.showMessage=1;
  26. }
  27. },function(error){
  28. });
  29. });
  30. $rootScope.$on('msg-new', function (event, msg) {
  31. $scope.showMessage = 1;
  32. });
  33. $scope.type = 'hot';//tab切换
  34. $scope.changeStep = function(){
  35. $scope.step = $scope.step + 1;
  36. homeService.changeStep().then(function(result){
  37. if(result.data.status_code==0){
  38. storage.setObject('user', result.data.data);
  39. }
  40. },function(error){
  41. })
  42. }
  43. $ionicPopover.fromTemplateUrl('my-popover.html', {
  44. scope: $scope
  45. }).then(function (popover) {
  46. $scope.popover = popover;
  47. });
  48. $scope.toggleLeftSideMenu = function () {
  49. $ionicSideMenuDelegate.toggleLeft();
  50. };
  51. $scope.openPopover = function ($event) {
  52. $scope.popover.show($event);
  53. };
  54. $scope.closePopover = function () {
  55. $scope.popover.hide();
  56. };
  57. $scope.changetype = function (type) {
  58. $scope.type = type;
  59. $scope.load(true);
  60. };
  61. $scope.toDetail = function (id) {
  62. $state.go('app.home_dreamdetail',{id:id});
  63. };
  64. $scope.toUserDetail = function (id) {
  65. homeService.toUserDetail(id).then(function(result){
  66. $scope.items = result.data.data;
  67. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  68. },function(error){
  69. //msg.error(msg.data.error)
  70. })
  71. };
  72. $scope.changeFilter = function (input) {
  73. switch (input) {
  74. case '1':
  75. if ($scope.filter.sex == 1) {
  76. $scope.filter.sex = 0;
  77. } else {
  78. $scope.filter.sex = 1;
  79. }
  80. break;
  81. case '2':
  82. if ($scope.filter.sex == 2) {
  83. $scope.filter.sex = 0;
  84. } else {
  85. $scope.filter.sex = 2;
  86. }
  87. break;
  88. default:
  89. }
  90. };
  91. $scope.filter = {
  92. hasMore: false,
  93. pageIndex: 1,
  94. pageSize: 20,
  95. sex: 0,//1男,2女,0:全部,
  96. age: '',//0:全部,1:18-21,2:22-25,3:26-29,4:30-33,5:34-37,6:>38,7:>18
  97. city:''
  98. };
  99. $scope.ages = [
  100. {"value": 0, "age": "所有"},
  101. {"value": 7, "age": "<18"},
  102. {"value": 1, "age": "18-21"},
  103. {"value": 2, "age": "22-25"},
  104. {"value": 3, "age": "26-29"},
  105. {"value": 4, "age": "30-33"},
  106. {"value": 5, "age": "34-37"},
  107. {"value": 6, "age": ">37"}
  108. ];
  109. $scope.doFilter = function () {
  110. var obj=document.getElementsByName('age');
  111. for(var i=0; i<obj.length; i++){
  112. if(obj[i].checked){
  113. $scope.filter.age+=obj[i].value+',';
  114. obj[i].checked=false;
  115. }
  116. };
  117. homeService.doFilter($scope.filter.sex,$scope.filter.age,$scope.filter.city).then(function(result){
  118. $scope.index.dreams = result.data.data.dreams.data;
  119. },function(error){
  120. msg.error(data.error.message);
  121. });
  122. $scope.filter.age="";
  123. };
  124. $scope.index = {
  125. banner: [],
  126. users: [],
  127. dreams:[]
  128. };
  129. $scope.next = function (type) {
  130. //type:1 前一个,type:2 后一个
  131. if($scope.index.users.length>0){
  132. if(type==1)
  133. {
  134. var temp= $scope.index.users.splice(0,1);
  135. $scope.index.users.push(temp[0]);
  136. }
  137. if (type==2){
  138. var temp= $scope.index.users.splice($scope.index.users.length-1,1);
  139. $scope.index.users.unshift(temp[0]);
  140. }
  141. }
  142. };
  143. $scope.load = function (init) {
  144. if (init) {
  145. $scope.filter.pageIndex = 1;
  146. $scope.index.dreams = [];
  147. }
  148. msg.loading();
  149. homeService.index($scope.type, $scope.filter.pageIndex).then(function (result) {
  150. msg.hide();
  151. $scope.index.banners = result.data.data.banners;
  152. $ionicSlideBoxDelegate.update();
  153. $ionicSlideBoxDelegate.loop(true);
  154. $scope.index.users = result.data.data.users;
  155. $scope.filter.pageIndex++;
  156. var more = (result.data.data.dreams.data.length >= $scope.filter.pageSize);
  157. $scope.filter.hasMore = more;
  158. $scope.index.dreams = $scope.index.dreams.concat(result.data.data.dreams.data);
  159. if (init) {
  160. $scope.$broadcast('scroll.refreshComplete');
  161. } else {
  162. $scope.$broadcast('scroll.infiniteScrollComplete');
  163. }
  164. }, function (error) {
  165. msg.hide();
  166. });
  167. };
  168. $scope.clickAvatar = function(id,dream_id){
  169. $state.go('app.home_dreamdetail',{id:dream_id,dream_user_id:id,type:2});
  170. };
  171. $scope.qrscan = function () {
  172. cordova.plugins.barcodeScanner.scan(
  173. function (result) {
  174. //扫码成功后执行的回调函数
  175. //alert("收到一个二维码\n" +
  176. // "扫码文字结果: " + result.text + "\n" +
  177. // "格式: " + result.format + "\n" +
  178. // "是否在扫码页面取消扫码: " + result.cancelled);
  179. if (!result.cancelled) {
  180. $http({
  181. url: result.text,
  182. method: "get"
  183. }).then(function (res) {
  184. msg.success('扫码成功');
  185. }, function (erro) {
  186. //alert(JSON.stringify(erro));
  187. msg.error('扫码失败:'+erro.data.message);
  188. });
  189. }
  190. },
  191. function (error) {
  192. //扫码失败执行的回调函数
  193. // alert("Scanning failed: " + error);
  194. }, {
  195. preferFrontCamera: false, // iOS and Android 设置前置摄像头
  196. showFlipCameraButton: true, // iOS and Android 显示旋转摄像头按钮
  197. showTorchButton: true, // iOS and Android 显示打开闪光灯按钮
  198. torchOn: false, // Android, launch with the torch switched on (if available)打开手电筒
  199. prompt: "在扫描区域内放置二维码", // Android提示语
  200. resultDisplayDuration: 500, // Android, display scanned text for X ms.
  201. //0 suppresses it entirely, default 1500 设置扫码时间的参数
  202. formats: "QR_CODE", // 二维码格式可设置多种类型
  203. orientation: "portrait", // Android only (portrait|landscape),
  204. //default unset so it rotates with the device在安卓上 landscape 是横屏状态
  205. disableAnimations: true, // iOS 是否禁止动画
  206. disableSuccessBeep: false // iOS 禁止成功后提示声音 “滴”
  207. }
  208. );
  209. };
  210. $scope.$on('$ionicView.beforeLeave', function () {
  211. $scope.popover.hide();
  212. $scope.load(true);
  213. });
  214. }]);
  215. app.controller('dreamDetailCtrl', ["$scope","$location","$ionicHistory","$timeout","$ionicLoading", "$state", 'userService',"WechatService","$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams","$ionicBackdrop", "$ionicScrollDelegate", "$interval"
  216. , function ($scope,$location, $ionicHistory,$timeout,$ionicLoading,$state,userService,WechatService,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams,$ionicBackdrop, $ionicScrollDelegate, $interval) {
  217. var dream_user_id = $stateParams.dream_user_id;
  218. var id = $stateParams.id;
  219. var interaction_id = $stateParams.interaction_id;
  220. $scope.host = config.server;
  221. $scope.imghost = config.imgServer;
  222. var top3user = '';
  223. if($stateParams.type!=null){
  224. $scope.type = $stateParams.type;
  225. }
  226. else {
  227. $scope.type = 1;//tab切换
  228. }
  229. $scope.chosedIndex = 0;
  230. $scope.clickAvatar = function (index) {
  231. $scope.chosedIndex = index;
  232. homeService.myInfo().then(function (result) {
  233. $scope.user = result.data.data;
  234. });
  235. };
  236. // id=5;
  237. $scope.$on('$ionicView.afterEnter', function () {
  238. timerID = setInterval(function() {
  239. $scope.$apply(function(){
  240. $scope.load(id,dream_user_id,interaction_id);
  241. });
  242. }, 50000);
  243. $scope.isTest = true;
  244. userService.isTest().then(function(res){
  245. if(res.data.data==1){
  246. $scope.isTest = false;
  247. }else{
  248. $scope.isTest = true;
  249. }
  250. })
  251. });
  252. $scope.$on('$ionicView.afterLeave', function () {
  253. clearInterval(timerID);
  254. timerID = null;
  255. if($scope.multi.promise)$interval.cancel($scope.multi.promise);
  256. if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  257. });
  258. $scope.$on('$ionicView.beforeEnter', function () {
  259. $scope.step = storage.getObject('user').step;
  260. var width = window.screen.width;
  261. if(width>300&width<370){
  262. $scope.screenWidth = 0;
  263. }
  264. else if(width>=370&width<400){
  265. $scope.screenWidth = 1;
  266. }
  267. else{
  268. $scope.screenWidth = 2;
  269. }
  270. $scope.video = {};
  271. msg.loading();
  272. $ionicTabsDelegate.showBar(false);
  273. $scope.load(id,dream_user_id,interaction_id);
  274. $scope.thisUser = storage.getObject('user');
  275. $scope.vm.payType = 2;
  276. homeService.myInfo().then(function(result){
  277. $scope.user = result.data.data;
  278. });
  279. homeService.messageInfo().then(function(result){
  280. $scope.infos = result.data.data;
  281. if($scope.infos.dream_info.number==0 && $scope.infos.sup_info.number==0 && $scope.infos.system_info.number==0){
  282. $scope.showMessage=0;
  283. }
  284. else {
  285. $scope.showMessage=1;
  286. }
  287. },function(error){
  288. });
  289. });
  290. $scope.changeStep = function(){
  291. $scope.step = $scope.step + 1;
  292. homeService.changeStep().then(function(result){
  293. if(result.data.status_code==0){
  294. storage.setObject('user', result.data.data);
  295. }
  296. },function(error){
  297. })
  298. }
  299. $scope.toUserDetail = function (id) {
  300. homeService.toUserDetail(id).then(function(result){
  301. $scope.items = result.data.data;
  302. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  303. },function(error){
  304. //msg.error(msg.data.error)
  305. })
  306. };
  307. $scope.toSort = function(){
  308. //$scope.type = 3;
  309. $scope.changeType(3)
  310. };
  311. $scope.destroyInter = function(id,dream_id){
  312. msg.confirm("互动","是否删除该评论").then(function(result){
  313. if(result==true)
  314. {
  315. homeService.destroyInter(id).then(function(result){
  316. msg.text('删除成功');
  317. $scope.load(dream_id);
  318. },function(error){
  319. msg.error(error.data.message);
  320. });
  321. }
  322. });
  323. };
  324. // 举报或拉黑
  325. $scope.report = function(ev,dream_id,interaction_id,user_id){
  326. ev.stopPropagation();
  327. msg.confirm('举报或拉黑','','举报','拉黑').then(function(result){
  328. if(result==true){
  329. msg.confirm('确定拉黑?').then(function(result){
  330. if(result==true){
  331. homeService.report(dream_id,interaction_id,user_id).then(function(result){
  332. if(result.data.status_code==0){
  333. msg.text('已拉黑');
  334. $scope.load(dream_id);
  335. }
  336. },function(error){
  337. })
  338. }
  339. })
  340. }
  341. else {
  342. msg.confirm('确定举报?').then(function(result){
  343. if(result==true){
  344. $state.go('app.homeContact');
  345. }
  346. })
  347. }
  348. })
  349. };
  350. $scope.load = function (id,dream_user_id,interaction_id) {
  351. homeService.dreamDetail(id,dream_user_id,interaction_id).then(function (result) {
  352. console.log(result);
  353. $scope.showCode = function(codeName){
  354. $scope.url = codeName;
  355. $scope.code = true;
  356. };
  357. $scope.hideCode = function(){
  358. $scope.code = false;
  359. };
  360. $scope.dream = result.data.data;
  361. //if($scope.timer=='已结束'|| 100*$scope.dream.get_coin/$scope.dream.coin>=100){
  362. // $scope.codeBtn = true;
  363. //}
  364. if($scope.timer=='已结束'){
  365. $scope.codeBtn = true;
  366. }
  367. if($scope.dream.video){
  368. if($scope.dream.video.indexOf('http')<0){
  369. $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
  370. $scope.dream.video = config.imgServer+$scope.dream.video;
  371. }
  372. else {
  373. //$scope.dream.vpic = $scope.dream.video+'upload/vpic/'+'.jpg';
  374. $scope.dream.vpic = $scope.dream.video.replace(/attachment/,'upload/vpic/')+'.jpg';
  375. $scope.dream.video = $scope.dream.video;
  376. }
  377. }
  378. var reg = new RegExp("\n", "g");
  379. $scope.dream.about = $scope.dream.about.replace(reg, "<br/>");
  380. var end_time = new Date($scope.dream.end_time.replace(/-/g, "/"));
  381. var date = new Date();
  382. var inter = (end_time.getTime() - date.getTime()) / 1000;
  383. leftTimer(inter);
  384. $scope.multi.a = $scope.dream.a;
  385. $scope.multi.b = new Date($scope.dream.created_at.replace(/-/g, "/"));
  386. $scope.multi.c = $scope.dream.c;
  387. $scope.multi.promise = $scope.dream.a;
  388. var newtop3user = '' ;
  389. angular.forEach($scope.dream.top3user, function(user) {
  390. newtop3user= newtop3user +user.id+","
  391. });
  392. if(top3user!=''&&newtop3user!=top3user){
  393. //测试动画切换
  394. $timeout(function() {
  395. $scope.sort.slide1 = 'list-grow-animation';
  396. $scope.sort.slide2 = 'slide-in-both-ways';
  397. $scope.sort.slide3 = 'bounce-animation';
  398. }, 50);
  399. }
  400. top3user = newtop3user;
  401. if($scope.dream.top3user[0])$scope.sort.first = $scope.dream.top3user[0].avatar;
  402. if($scope.dream.top3user[1])$scope.sort.second = $scope.dream.top3user[1].avatar;
  403. if($scope.dream.top3user[2])$scope.sort.third = $scope.dream.top3user[2].avatar;
  404. //$scope.calcmultiplier();
  405. msg.hide();
  406. }, function (error) {
  407. msg.hide();
  408. });
  409. };
  410. $scope.openSupport = function () {
  411. msg.alert("支持乘数","为了支持您的梦想者,乘数越高,得到的梦想分越高,抓紧机会哟~喵!(梦想币x支持乘数=梦想分)");
  412. };
  413. $scope.multi = {
  414. a: '',
  415. b: '',
  416. c: '',
  417. result: 1,
  418. promise:null
  419. };
  420. $scope.tosupport = false;
  421. $scope.support = function ($event) {
  422. $event.stopPropagation();
  423. $scope.tosupport = true;
  424. $scope.vm.coin = 0;
  425. $scope.index = 0;
  426. };
  427. $scope.cancelSupport = function () {
  428. $scope.tosupport = false;
  429. $scope.toshare = false;
  430. $scope.input.show = false;
  431. };
  432. $scope.toshare = false;
  433. $scope.toRecharge = function(){
  434. $state.go("app.recharge")
  435. };
  436. $scope.share = function (type,$event) {
  437. $scope.toshare = true;
  438. if (type==0) {
  439. //分享给朋友
  440. Wechat.share({
  441. message: {
  442. title: $scope.dream.name,
  443. description: $scope.dream.user.nickname + '在瞄喵发布了一个新的梦想。' + '\n' + $scope.dream.about,
  444. thumb: $scope.dream.imgs[0].pic,
  445. media: {
  446. type: Wechat.Type.WEBPAGE,
  447. webpageUrl: config.server + "/admin/share/view?id=" + id + '&user_id = ' + $scope.user.id
  448. }
  449. },
  450. scene: Wechat.Scene.SESSION
  451. }, function () {
  452. //msg.alert('分享','分享成功');
  453. msg.success('分享成功');
  454. }, function (reason) {
  455. //msg.alert('分享','分享失败');
  456. msg.error('分享失败');
  457. });
  458. }
  459. if(type==1){
  460. Wechat.share({
  461. message: {
  462. title: $scope.dream.name,
  463. description: $scope.dream.user.nickname + '在瞄喵发布了一个新的梦想。' + '\n' + $scope.dream.about,
  464. thumb: $scope.dream.imgs[0].pic,
  465. media: {
  466. type: Wechat.Type.WEBPAGE,
  467. webpageUrl: config.server + "/admin/share/view?id=" + id
  468. }
  469. },
  470. scene: Wechat.Scene.TIMELINE
  471. }, function () {
  472. msg.success('分享成功');
  473. }, function (reason) {
  474. msg.error('分享失败');
  475. });
  476. }
  477. };
  478. //实时排行
  479. $scope.sort = {
  480. slide: ''
  481. };
  482. $scope.changeType = function (type) {
  483. $ionicScrollDelegate.scrollTop(true);
  484. $scope.type = type;
  485. };
  486. $scope.index = 0;
  487. $scope.vm = {
  488. coin:"",
  489. title:""
  490. };
  491. $scope.timer = '';
  492. var leftTimer = function (countDown) {
  493. if (isNaN(countDown)) {
  494. $scope.timer = '已结束';
  495. return;
  496. }
  497. if (countDown<=0) {
  498. $scope.timer = '已结束';
  499. return;
  500. }
  501. var day=parseInt(countDown/(24*60*60));
  502. var h=parseInt(countDown/(60*60)%24);
  503. var m=parseInt(countDown/60%60);
  504. var s=parseInt(countDown%60);
  505. //$scope.timer=(h<10?'0'+h:h)+'时'+(m<10?'0'+m:m)+'分'+(s<10?'0'+s:s)+'秒';
  506. if(day>0) $scope.timer = day+'天';
  507. if(day<0 && h>0) $scope.timer = h+'小时';
  508. if(day<0 && h<0 && m>0) $scope.timer = m+'分钟';
  509. if(day<0 && h<0 && m<0) $scope.timer = '已结束';
  510. /* if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  511. $scope.leftTimer = $interval(function () {
  512. if (countDown >= 1) leftTimer(countDown - 1);
  513. },1000);*/
  514. /*if(countDown<=0){
  515. $scope.timer='结束';
  516. }*/
  517. };
  518. $scope.changeIndex = function (index) {
  519. $scope.index = index;
  520. $scope.vm.coin = index*10;
  521. };
  522. $scope.vidEnded = function () {
  523. alert('播放完毕');
  524. };
  525. //实时计算支持乘数
  526. //$scope.calcmultiplier = function () {
  527. // $scope.multi.promise = $interval(function () {
  528. //
  529. // var date = new Date();
  530. // var inter = date.getTime() - $scope.multi.b.getTime();
  531. // var minutes = Math.floor(inter / (60 * 1000));
  532. // var number = $scope.multi.a * minutes + $scope.multi.c;//js浮点运算会失真,根据muti.a的可能值范围,比如乘以100再除以100
  533. // if (number<=1) {
  534. // number = 1;
  535. // }
  536. // $scope.multi.result = Math.round(number * 100 / 100);
  537. // },1000);
  538. //};
  539. $scope.supportDream = function (data) {
  540. if(!$scope.vm.coin){
  541. msg.error("请选择梦想币数量!");
  542. return ;
  543. }
  544. var data = {
  545. id:id,
  546. coin:$scope.vm.coin
  547. };
  548. homeService.supportDream(data).then(function(result){
  549. $scope.tosupport = false;
  550. $scope.load(id);
  551. homeService.myInfo().then(function(result){
  552. $scope.user = result.data.data;
  553. });
  554. $interval.cancel($scope.multi.promise);
  555. msg.text("发送成功",1000);
  556. });
  557. };
  558. $scope.collectionDream = function(is_collection){
  559. homeService.collectionDream(id,is_collection).then(function(result){
  560. $scope.dream.is_collection=result.data.data;
  561. })
  562. };
  563. $scope.add = function(is_collection){
  564. var data = {
  565. id:id,
  566. title:$scope.vm.title,
  567. pics:$scope.imgs,
  568. video:$scope.video.server
  569. };
  570. homeService.add_interaction(data).then(function(){
  571. $scope.load(id);
  572. $scope.closeModal();
  573. })
  574. };
  575. $scope.showAbout = true;
  576. $scope.hideAbout = false;
  577. $scope.showText = function(){
  578. $scope.aboutStyle = {
  579. "white-space" : "normal"
  580. };
  581. $scope.showAbout = false;
  582. $scope.hideAbout = true;
  583. };
  584. $scope.hideText = function(){
  585. $scope.aboutStyle = {
  586. "white-space" : "nowrap"
  587. };
  588. $scope.showAbout = true;
  589. $scope.hideAbout = false;
  590. };
  591. $scope.input = {
  592. placeholder: '评论',
  593. focus: false,
  594. show:false
  595. };
  596. $scope.showmore = function (index) {
  597. if ($scope.dream.interactions[index].showmore) {
  598. $scope.dream.interactions[index].showmore = false;
  599. } else {
  600. $scope.dream.interactions[index].showmore = true;
  601. }
  602. };
  603. $scope.replay = function ($event, name, to_userid, index) {
  604. $event.stopPropagation();
  605. $scope.input.focus = true;
  606. $scope.input.show = true;
  607. angular.forEach($scope.dream.interactions, function (item) {
  608. item.show = false;
  609. });
  610. $scope.dream.interactions[index].show = true;
  611. $scope.dream.interactions[index].focus = true;
  612. $scope.input.placeholder = "评论" + name+":";
  613. $scope.to_userid = to_userid;
  614. $scope.vm.title='';
  615. $scope.vm.comment='';
  616. };
  617. $scope.replayOther = function ($event, name, to_userid, index,currentindex) {
  618. debugger;
  619. $event.stopPropagation();
  620. if($scope.dream.interactions[index].comments[currentindex].user_id!=$scope.user.id){
  621. $scope.input.focus = true;
  622. $scope.input.show = true;
  623. angular.forEach($scope.dream.interactions, function (item) {
  624. item.show = false;
  625. });
  626. $scope.dream.interactions[index].show = true;
  627. $scope.dream.interactions[index].focus = true;
  628. $scope.input.placeholder = "评论" + name;
  629. $scope.to_userid = to_userid;
  630. $scope.vm.title='';
  631. $scope.vm.comment='';
  632. }
  633. else if($scope.timer!='已结束') {
  634. msg.confirm("评论","是否删除评论").then(function(result){
  635. if(result==true)
  636. {
  637. homeService.deleteComment($scope.dream.interactions[index].comments[currentindex].id).then(function(result){
  638. msg.text("删除成功");
  639. $scope.load(id);
  640. },function(error){
  641. msg.error(error.data.message);
  642. })
  643. }
  644. });
  645. }
  646. };
  647. $scope.ios={
  648. isIOS:ionic.Platform.isIOS(),
  649. productid:''
  650. }
  651. //充值
  652. $scope.charge = function(number){
  653. if($scope.ios.isIOS){
  654. if (number<2){
  655. msg.text('请选择充值金额');
  656. return;
  657. }
  658. console.log('购买productid:'+number);
  659. msg.loading();
  660. inAppPurchase
  661. .buy(number)
  662. .then(function (data) {
  663. msg.hide();
  664. console.log('购买then:'+JSON.stringify(data));
  665. return inAppPurchase.consume(data.productType, data.receipt, data.signature);
  666. })
  667. .then(function (data) {
  668. msg.hide();
  669. myService.orderIos(number).then(function (result) {
  670. console.log('服务器端购买成功:'+number);
  671. }, function (erro) {
  672. });
  673. console.log('购买成功:'+number);
  674. msg.success('购买成功');
  675. $timeout(function () {
  676. $scope.closeRechargeModal();
  677. }, 1000);
  678. })
  679. .catch(function (err) {
  680. msg.hide();
  681. console.log('购买失败:'+JSON.stringify(err));
  682. $timeout(function () {
  683. $scope.closeRechargeModal();
  684. }, 1000);
  685. // alert('购买失败:'+JSON.stringify(err));
  686. });
  687. }else{
  688. if (!number) {
  689. msg.text('请输入充值金额');
  690. return;
  691. }
  692. homeService.charge(number,2).then(function (result) {
  693. //todo:result需要返回支付宝或者微信的签名信息
  694. console.log("result: " + JSON.stringify(result));
  695. var payInfo = result.data.data;
  696. if ($scope.vm.payType == 1) { //支付宝
  697. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  698. $scope.clicksub = false;
  699. if (e.resultStatus == '9000') {
  700. alert(orderID);
  701. $timeout(function () {
  702. $scope.closeRechargeModal();
  703. }, 1000);
  704. homeService.myInfo().then(function (result) {
  705. $scope.user = result.data.data;
  706. });
  707. } else {
  708. msg.error("支付失败");
  709. // msg.error("支付失败:" + JSON.stringify(e));
  710. }
  711. }, function error(e) {
  712. $scope.clicksub = false;
  713. // msg.error("支付失败:" + JSON.stringify(e));
  714. msg.error("支付失败");
  715. });
  716. }
  717. if ($scope.vm.payType == 2) { //微信
  718. // var obj = JSON.parse(payInfo);
  719. var obj = payInfo.orderString;
  720. // console.log("obj: " + JSON.stringify(obj));
  721. var params = {
  722. partnerid: obj.partnerid, // merchant id
  723. prepayid: obj.prepayid, // prepay id
  724. noncestr: obj.noncestr, // nonce
  725. timestamp: obj.timestamp, // timestamp
  726. sign: obj.sign, // signed string
  727. };
  728. // console.log("result: " + JSON.stringify(params));
  729. Wechat.sendPaymentRequest(params, function (r) {
  730. // $scope.clicksub = false;
  731. $timeout(function () {
  732. $scope.closeRechargeModal();
  733. }, 1000);
  734. $scope.load(id,dream_user_id,interaction_id);
  735. // courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  736. // homeService.myInfo().then(function (result) {
  737. // $scope.user = result.data.data;
  738. // });
  739. // }, function (erro) {
  740. // // msg.alert("支付反馈失败:" + JSON.stringify(erro));
  741. // });
  742. }, function (reason) {
  743. $scope.clicksub = false;
  744. // msg.alert("支付失败:" + JSON.stringify(reason));
  745. });
  746. }
  747. });
  748. }
  749. };
  750. $scope.submitComment = function (index,to_userid) {
  751. var interaction = $scope.dream.interactions[index];
  752. var iid = interaction.id;
  753. // $scope.dream.interactions[index].comments.push($scope.vm.comment);
  754. $scope.input.focus = true;
  755. if ($scope.vm.comment && $scope.vm.comment == '' || !iid) return;
  756. var data = {
  757. id:iid,
  758. content:$scope.vm.comment,
  759. comment_user_id:to_userid,
  760. to_user_id: $scope.dream.user.id
  761. };
  762. if($scope.timer=='已结束'){
  763. msg.alert("评论","该梦想已结束,不支持评论");
  764. }
  765. else {
  766. homeService.add_comment(data).then(function(){
  767. msg.success('评论成功');
  768. $scope.vm.comment = '' ;
  769. $scope.load(id);
  770. $scope.closeModal();
  771. });
  772. }
  773. };
  774. $scope.bigImage = false;
  775. $scope.showBigImage = function ($event, imageName) {
  776. $event.stopPropagation();
  777. $scope.url = imageName;
  778. $scope.bigImage = true;
  779. };
  780. $scope.hideBigImage = function(){
  781. $scope.bigImage = false;
  782. };
  783. $ionicModal.fromTemplateUrl('qrCode.html', {
  784. scope: $scope,
  785. animation: 'slide-in-up'
  786. }).then(function(modal) {
  787. $scope.qrCodemodal = modal;
  788. });
  789. $scope.openCode = function($event) {
  790. $event.stopPropagation();
  791. $scope.qrCodemodal.show();
  792. $scope.vm.money = '';
  793. };
  794. $scope.closeCode = function() {
  795. $scope.qrCodemodal.hide();
  796. };
  797. $ionicModal.fromTemplateUrl('commentPic.html', {
  798. scope: $scope,
  799. animation: 'slide-in-up'
  800. }).then(function(modal) {
  801. $scope.CommentPicmodal = modal;
  802. });
  803. $scope.openCommentPic = function(pic,$event) {
  804. $event.stopPropagation();
  805. $scope.CommentPicmodal.show();
  806. $scope.commentPicUrl = pic;
  807. };
  808. $scope.closeCommentPic = function() {
  809. $scope.CommentPicmodal.hide();
  810. };
  811. $scope.addpict = function () {
  812. common.chooseImage().then(function (img) {
  813. common.uploadFiles(img,1).then(function (result) {
  814. var response = JSON.parse(result.response);
  815. var file = config.imgServer + response.data.file;
  816. $scope.imgs.push(file);
  817. }, function (error) {
  818. msg.error('图片上传失败');
  819. });
  820. }, function (error) {
  821. console.log('图片选择失败');
  822. });
  823. };
  824. $scope.deletefile = function (file) {
  825. var index = $scope.imgs.indexOf(file);
  826. $scope.imgs.splice(index, 1);
  827. common.deletefile(file).then(function () {
  828. })
  829. };
  830. $scope.addvideo = function () {
  831. common.chooseVideo().then(function (file) {
  832. msg.loading();
  833. common.uploadFiles(file, 2).then(function (result) {
  834. msg.hide();
  835. var response = JSON.parse(result.response);
  836. $scope.video.server = response.data.file;
  837. var file = config.imgServer+response.data.file;
  838. $scope.video.isOK = true;
  839. $scope.video.file = file;
  840. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  841. }, function (error) {
  842. //msg.error('视频上传失败');
  843. msg.hide();
  844. msg.error(JSON.stringify(error));
  845. });
  846. }, function (erro) {
  847. console.log('选择视频失败');
  848. });
  849. };
  850. $scope.deletevideo = function (file) {
  851. $scope.video = {};
  852. common.deletefile(file).then(function (res) {
  853. },function(erro){
  854. alert(JSON.stringify(erro));
  855. })
  856. };
  857. $ionicModal.fromTemplateUrl('recharge-modal.html', {
  858. scope: $scope,
  859. animation: 'slide-in-up'
  860. }).then(function(modal) {
  861. $scope.rechagemodal = modal;
  862. });
  863. $scope.openRechargeModal = function() {
  864. $scope.rechagemodal.show();
  865. $scope.vm.money = '';
  866. if($scope.ios.isIOS){
  867. var productIds = ['apple10001','apple102','apple103','apple104']; // <- Add your product Ids here
  868. msg.loading();
  869. inAppPurchase.getProducts(productIds).then(function (products) {
  870. msg.hide();
  871. $scope.products = products;
  872. console.log('products:'+JSON.stringify(products));
  873. }).catch(function (err) {
  874. msg.hide();
  875. console.log(err);
  876. });
  877. }
  878. };
  879. $scope.closeRechargeModal = function() {
  880. $scope.rechagemodal.hide();
  881. };
  882. $ionicModal.fromTemplateUrl('interaction-modal.html', {
  883. scope: $scope,
  884. animation: 'slide-in-up'
  885. }).then(function(modal) {
  886. $scope.modal = modal;
  887. });
  888. $scope.openModal = function() {
  889. $scope.modal.show();
  890. $scope.vm.title = '';
  891. $scope.imgs = [];
  892. $scope.video = {};
  893. };
  894. $scope.closeModal = function() {
  895. $scope.modal.hide();
  896. };
  897. //当我们用到模型时,清除它!
  898. $scope.$on('$destroy', function() {
  899. $scope.modal.remove();
  900. $scope.rechagemodal.remove();
  901. });
  902. $scope.toMessage = function(){
  903. if($location.path()=="/app/home/dreamdetail"){
  904. $state.go("app.message");
  905. }
  906. else {
  907. $state.go("app.my_message");
  908. }
  909. }
  910. }]);
  911. app.controller('userDetailCtrl', ["$scope","$location", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$timeout", "$ionicScrollDelegate", "$interval"
  912. , function ($scope,$location, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $timeout, $ionicScrollDelegate, $interval) {
  913. var id = $stateParams.id;
  914. $scope.items = $stateParams.items;
  915. $scope.$on('$ionicView.beforeEnter', function () {
  916. $ionicTabsDelegate.showBar(false);
  917. });
  918. $scope.attentionUser = function(is_care){
  919. homeService.attentionUser(id,is_care).then(function(result){
  920. $scope.items.is_care=result.data.data;
  921. })
  922. };
  923. $scope.next = function (type) {
  924. //type:1 前一个,type:2 后一个
  925. if($scope.items.imgs.length>0){
  926. if(type==1)
  927. {
  928. var temp= $scope.items.imgs.splice(0,1);
  929. $scope.items.imgs.push(temp[0]);
  930. }
  931. if (type==2){
  932. var temp= $scope.items.imgs.splice($scope.items.imgs.length-1,1);
  933. $scope.items.imgs.unshift(temp[0]);
  934. }
  935. }
  936. };
  937. $scope.bigImage = false;
  938. $scope.showBigImage = function(imageName,imageIndex){
  939. $scope.url = imageName;
  940. $scope.imageIndex = imageIndex;
  941. $scope.bigImage = true;
  942. };
  943. $scope.hideBigImage = function(){
  944. $scope.bigImage = false;
  945. };
  946. $scope.swipeLeft = function (imageIndex) {
  947. if ($scope.imageIndex < $scope.items.imgs.length - 1 && $scope.imageIndex >= 0)
  948. $scope.imageIndex = $scope.imageIndex + 1;
  949. else {
  950. //如果图片已经是最后一张图片了,则取index = 0
  951. $scope.imageIndex = 0;
  952. }
  953. //替换url,展示图片
  954. $scope.url = $scope.items.imgs[$scope.imageIndex].pic; //$scope定义一个变量Url,这里会在大图出现后再次点击隐藏大图使用
  955. $scope.bigImage = true; //显示大图
  956. };
  957. $scope.swipeRight = function (imageIndex) {
  958. if ($scope.imageIndex <= $scope.items.imgs.length - 1 && $scope.imageIndex > 0)
  959. $scope.imageIndex = $scope.imageIndex - 1;
  960. else {
  961. //如果图片已经是第一张图片了,则取index = Images.length-1
  962. $scope.imageIndex = $scope.items.imgs.length - 1;
  963. }
  964. //替换url,展示图片
  965. $scope.url = $scope.items.imgs[$scope.imageIndex].pic; //$scope定义一个变量Url,这里会在大图出现后再次点击隐藏大图使用
  966. $scope.bigImage = true; //显示大图
  967. };
  968. $scope.cancelSupport = function () {
  969. $scope.tosupport = false;
  970. $scope.toshare = false;
  971. };
  972. $scope.toshare = false;
  973. $scope.toshare = false;
  974. $scope.toRecharge = function(){
  975. $state.go("app.recharge")
  976. };
  977. $scope.toDetail = function (dream_id) {
  978. if($scope.items.near_dream==null){
  979. msg.alert("当前梦想","该用户没有当前梦想");
  980. }
  981. if($scope.items.near_dream!=null){
  982. var dream_id = $scope.items.near_dream.id;
  983. if($location.path()=="/app/home/userDetail"){
  984. $state.go('app.home_dreamdetail',{id:dream_id});
  985. }
  986. else {
  987. $state.go('app.my_dreamdetail',{id:dream_id});
  988. }
  989. }
  990. };
  991. $scope.toOldDream = function(){
  992. if($scope.items.dreams.length<2){
  993. msg.alert("曾经的梦想","该用户没有曾经的梦想");
  994. }
  995. if($scope.items.dreams.length>1){
  996. if($location.path()=="/app/home/userDetail"){
  997. $state.go('app.oldDream',{user_id:$scope.items.user.id});
  998. }
  999. else {
  1000. $state.go('app.myOldDream',{user_id:$scope.items.user.id});
  1001. }
  1002. }
  1003. };
  1004. $scope.toSupportDream = function(){
  1005. if($scope.items.sup_dreams.length==0){
  1006. msg.alert("支持的梦想","该用户没有支持的梦想");
  1007. }
  1008. if($scope.items.sup_dreams.length!=0){
  1009. if($scope.items.dreams.length>1){
  1010. if($location.path()=="/app/home/userDetail"){
  1011. $state.go('app.supportDream',{user_id:$scope.items.user.id});
  1012. }
  1013. else {
  1014. $state.go('app.mySupportDream',{user_id:$scope.items.user.id});
  1015. }
  1016. }
  1017. }
  1018. };
  1019. $scope.collectionDream = function(is_collection){
  1020. homeService.collectionDream(id,is_collection).then(function(result){
  1021. $scope.user.is_collection=result.data.data;
  1022. })
  1023. };
  1024. }]);
  1025. app.controller('homeCollectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  1026. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  1027. $scope.$on('$ionicView.beforeEnter', function () {
  1028. $ionicTabsDelegate.showBar(false);
  1029. myService.collect().then(function(result){
  1030. $scope.dreams = result.data.data.dreams;
  1031. });
  1032. });
  1033. $scope.toDetail = function (id) {
  1034. $state.go('app.home_dreamdetail',{id:id});
  1035. };
  1036. }]);
  1037. app.controller('shareDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1038. , function ($scope,homeService,$stateParams, $state, msg) {
  1039. $scope.dream = $stateParams.item;
  1040. $scope.showAbout = true;
  1041. $scope.hideAbout = false;
  1042. $scope.showText = function(){
  1043. $scope.aboutStyle = {
  1044. "white-space" : "normal"
  1045. };
  1046. $scope.showAbout = false;
  1047. $scope.hideAbout = true;
  1048. };
  1049. $scope.hideText = function(){
  1050. $scope.aboutStyle = {
  1051. "white-space" : "nowrap"
  1052. };
  1053. $scope.showAbout = true;
  1054. $scope.hideAbout = false;
  1055. };
  1056. }]);
  1057. //app.controller('homeMessageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  1058. // , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  1059. // $scope.$on('$ionicView.beforeEnter', function () {
  1060. // $ionicTabsDelegate.showBar(false);
  1061. // myService.messageInfo().then(function(result){
  1062. // $scope.infos = result.data.data;
  1063. // },function(error){
  1064. //
  1065. // });
  1066. // });
  1067. // $scope.notRead = function(){
  1068. // myService.notRead().then(function(result){
  1069. // myService.messageInfo().then(function(result){
  1070. // $scope.infos = result.data.data;
  1071. // },function(error){
  1072. //
  1073. // });
  1074. // },function(error){
  1075. //
  1076. // })
  1077. // };
  1078. // //系统消息
  1079. // $scope.systemInfo = function(){
  1080. // $state.go("app.message_sys");
  1081. // myService.systemInfo().then(function(result){
  1082. // },function(error){
  1083. //
  1084. // });
  1085. // };
  1086. // //回复我的
  1087. // $scope.replyMy = function(){
  1088. // $state.go("app.message_reply");
  1089. // myService.replyMy().then(function(result){
  1090. //
  1091. // },function(error){
  1092. //
  1093. // });
  1094. // };
  1095. // $scope.personalLetter = function(){
  1096. // $state.go("app.letter");
  1097. // }
  1098. // }]);
  1099. app.controller('oldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1100. , function ($scope,homeService,$stateParams, $state, msg) {
  1101. var user_id = $stateParams.user_id;
  1102. $scope.$on('$ionicView.beforeEnter',function(){
  1103. $scope.toUserDetail(user_id);
  1104. });
  1105. $scope.toUserDetail = function(user_id){
  1106. homeService.toUserDetail(user_id).then(function(result){
  1107. $scope.items = result.data.data;
  1108. $scope.user = result.data.data.user;
  1109. $scope.dreams = $scope.user.dreams;
  1110. },function(error){
  1111. })
  1112. };
  1113. $scope.toDetail = function(id){
  1114. $state.go('app.home_dreamdetail',{id:id});
  1115. // $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
  1116. };
  1117. }]);
  1118. app.controller('supportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1119. , function ($scope,homeService,$stateParams, $state, msg) {
  1120. var user_id = $stateParams.user_id;
  1121. $scope.$on('$ionicView.beforeEnter',function(){
  1122. $scope.toUserDetail(user_id);
  1123. });
  1124. $scope.toUserDetail = function(user_id){
  1125. homeService.toUserDetail(user_id).then(function(result){
  1126. $scope.items = result.data.data;
  1127. $scope.user = result.data.data.user;
  1128. $scope.dreams = $scope.user.sup_dream;
  1129. },function(error){
  1130. })
  1131. };
  1132. $scope.toDetail = function(id){
  1133. $state.go('app.home_dreamdetail',{id:id});
  1134. // $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
  1135. }
  1136. }]);
  1137. app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  1138. , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
  1139. $scope.showMore = function (keyword,index) {
  1140. if(!keyword)return;
  1141. $scope.index = index;
  1142. $scope.search(keyword);
  1143. };
  1144. $scope.search = function (keyword) {
  1145. $scope.vm.keyword = keyword;
  1146. homeService.search(keyword).then(function(result){
  1147. $scope.isResult = true;
  1148. $scope.dream_infos = result.data.data.dream_infos;
  1149. $scope.user_infos = result.data.data.user_infos;
  1150. });
  1151. };
  1152. $scope.toUserDetail = function (id) {
  1153. homeService.toUserDetail(id).then(function(result){
  1154. $scope.items = result.data.data;
  1155. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  1156. },function(error){
  1157. //msg.error(msg.data.error)
  1158. })
  1159. };
  1160. $scope.toDetail = function (id) {
  1161. $state.go('app.home_dreamdetail',{id:id});
  1162. };
  1163. $scope.$on('$ionicView.beforeEnter', function () {
  1164. $scope.isResult = false;
  1165. $scope.index = 0;
  1166. $scope.vm = {
  1167. keyword : ""
  1168. };
  1169. $ionicTabsDelegate.showBar(false);
  1170. // $ionicNavBarDelegate.showBackButton(false);
  1171. homeService.search('').then(function(result){
  1172. $scope.hot_searches = result.data.data.hot_searches;
  1173. $scope.history_searches = result.data.data.history_searches;
  1174. });
  1175. });
  1176. }]);
  1177. app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  1178. , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) {
  1179. }]);
  1180. app.controller('homeDreamsCtrl', ["$scope", "$state", "myService", "msg"
  1181. , function ($scope, $state, myService, msg) {
  1182. $scope.$on('$ionicView.beforeEnter', function () {
  1183. myService.myDream().then(function(result){
  1184. console.log(result.data.data);
  1185. $scope.dreams = result.data.data;
  1186. });
  1187. });
  1188. $scope.toDetail = function (id) {
  1189. $state.go('app.home_dreamdetail',{id:id});
  1190. };
  1191. }]);
  1192. })(angular.module('app.controllers'));