home.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  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", "WechatService","$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams","$ionicBackdrop", "$ionicScrollDelegate", "$interval"
  216. , function ($scope,$location, $ionicHistory,$timeout,$ionicLoading,$state,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){
  246. $scope.isTest = true;
  247. }
  248. else{
  249. $scope.isTest = false;
  250. }
  251. })
  252. });
  253. $scope.$on('$ionicView.afterLeave', function () {
  254. clearInterval(timerID);
  255. timerID = null;
  256. if($scope.multi.promise)$interval.cancel($scope.multi.promise);
  257. if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  258. });
  259. $scope.$on('$ionicView.beforeEnter', function () {
  260. $scope.step = storage.getObject('user').step;
  261. var width = window.screen.width;
  262. if(width>300&width<370){
  263. $scope.screenWidth = 0;
  264. }
  265. else if(width>=370&width<400){
  266. $scope.screenWidth = 1;
  267. }
  268. else{
  269. $scope.screenWidth = 2;
  270. }
  271. $scope.video = {};
  272. msg.loading();
  273. $ionicTabsDelegate.showBar(false);
  274. $scope.load(id,dream_user_id,interaction_id);
  275. $scope.thisUser = storage.getObject('user');
  276. $scope.vm.payType = 2;
  277. homeService.myInfo().then(function(result){
  278. $scope.user = result.data.data;
  279. });
  280. homeService.messageInfo().then(function(result){
  281. $scope.infos = result.data.data;
  282. if($scope.infos.dream_info.number==0 && $scope.infos.sup_info.number==0 && $scope.infos.system_info.number==0){
  283. $scope.showMessage=0;
  284. }
  285. else {
  286. $scope.showMessage=1;
  287. }
  288. },function(error){
  289. });
  290. });
  291. $scope.changeStep = function(){
  292. $scope.step = $scope.step + 1;
  293. homeService.changeStep().then(function(result){
  294. if(result.data.status_code==0){
  295. storage.setObject('user', result.data.data);
  296. }
  297. },function(error){
  298. })
  299. }
  300. $scope.toUserDetail = function (id) {
  301. homeService.toUserDetail(id).then(function(result){
  302. $scope.items = result.data.data;
  303. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  304. },function(error){
  305. //msg.error(msg.data.error)
  306. })
  307. };
  308. $scope.toSort = function(){
  309. //$scope.type = 3;
  310. $scope.changeType(3)
  311. };
  312. $scope.destroyInter = function(id,dream_id){
  313. msg.confirm("互动","是否删除该评论").then(function(result){
  314. if(result==true)
  315. {
  316. homeService.destroyInter(id).then(function(result){
  317. msg.text('删除成功');
  318. $scope.load(dream_id);
  319. },function(error){
  320. msg.error(error.data.message);
  321. });
  322. }
  323. });
  324. };
  325. // 举报或拉黑
  326. $scope.report = function(ev,dream_id,interaction_id,user_id){
  327. ev.stopPropagation();
  328. msg.confirm('举报或拉黑','','举报','拉黑').then(function(result){
  329. if(result==true){
  330. msg.confirm('确定拉黑?').then(function(result){
  331. if(result==true){
  332. homeService.report(dream_id,interaction_id,user_id).then(function(result){
  333. if(result.data.status_code==0){
  334. msg.text('已拉黑');
  335. $scope.load(dream_id);
  336. }
  337. },function(error){
  338. })
  339. }
  340. })
  341. }
  342. else {
  343. msg.confirm('确定举报?').then(function(result){
  344. if(result==true){
  345. $state.go('app.homeContact');
  346. }
  347. })
  348. }
  349. })
  350. };
  351. $scope.load = function (id,dream_user_id,interaction_id) {
  352. homeService.dreamDetail(id,dream_user_id,interaction_id).then(function (result) {
  353. console.log(result);
  354. $scope.showCode = function(codeName){
  355. $scope.url = codeName;
  356. $scope.code = true;
  357. };
  358. $scope.hideCode = function(){
  359. $scope.code = false;
  360. };
  361. $scope.dream = result.data.data;
  362. //if($scope.timer=='已结束'|| 100*$scope.dream.get_coin/$scope.dream.coin>=100){
  363. // $scope.codeBtn = true;
  364. //}
  365. if($scope.timer=='已结束'){
  366. $scope.codeBtn = true;
  367. }
  368. if($scope.dream.video){
  369. if($scope.dream.video.indexOf('http')<0){
  370. $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
  371. $scope.dream.video = config.imgServer+$scope.dream.video;
  372. }
  373. else {
  374. //$scope.dream.vpic = $scope.dream.video+'upload/vpic/'+'.jpg';
  375. $scope.dream.vpic = $scope.dream.video.replace(/attachment/,'upload/vpic/')+'.jpg';
  376. $scope.dream.video = $scope.dream.video;
  377. }
  378. }
  379. var reg = new RegExp("\n", "g");
  380. $scope.dream.about = $scope.dream.about.replace(reg, "<br/>");
  381. var end_time = new Date($scope.dream.end_time.replace(/-/g, "/"));
  382. var date = new Date();
  383. var inter = (end_time.getTime() - date.getTime()) / 1000;
  384. leftTimer(inter);
  385. $scope.multi.a = $scope.dream.a;
  386. $scope.multi.b = new Date($scope.dream.created_at.replace(/-/g, "/"));
  387. $scope.multi.c = $scope.dream.c;
  388. $scope.multi.promise = $scope.dream.a;
  389. var newtop3user = '' ;
  390. angular.forEach($scope.dream.top3user, function(user) {
  391. newtop3user= newtop3user +user.id+","
  392. });
  393. if(top3user!=''&&newtop3user!=top3user){
  394. //测试动画切换
  395. $timeout(function() {
  396. $scope.sort.slide1 = 'list-grow-animation';
  397. $scope.sort.slide2 = 'slide-in-both-ways';
  398. $scope.sort.slide3 = 'bounce-animation';
  399. }, 50);
  400. }
  401. top3user = newtop3user;
  402. if($scope.dream.top3user[0])$scope.sort.first = $scope.dream.top3user[0].avatar;
  403. if($scope.dream.top3user[1])$scope.sort.second = $scope.dream.top3user[1].avatar;
  404. if($scope.dream.top3user[2])$scope.sort.third = $scope.dream.top3user[2].avatar;
  405. //$scope.calcmultiplier();
  406. msg.hide();
  407. }, function (error) {
  408. msg.hide();
  409. });
  410. };
  411. $scope.openSupport = function () {
  412. msg.alert("支持乘数","为了支持您的梦想者,乘数越高,得到的梦想分越高,抓紧机会哟~喵!(梦想币x支持乘数=梦想分)");
  413. };
  414. $scope.multi = {
  415. a: '',
  416. b: '',
  417. c: '',
  418. result: 1,
  419. promise:null
  420. };
  421. $scope.tosupport = false;
  422. $scope.support = function ($event) {
  423. $event.stopPropagation();
  424. $scope.tosupport = true;
  425. $scope.vm.coin = 0;
  426. $scope.index = 0;
  427. };
  428. $scope.cancelSupport = function () {
  429. $scope.tosupport = false;
  430. $scope.toshare = false;
  431. $scope.input.show = false;
  432. };
  433. $scope.toshare = false;
  434. $scope.toRecharge = function(){
  435. $state.go("app.recharge")
  436. };
  437. $scope.share = function (type,$event) {
  438. $scope.toshare = true;
  439. if (type==0) {
  440. //分享给朋友
  441. Wechat.share({
  442. message: {
  443. title: $scope.dream.name,
  444. description: $scope.dream.user.nickname + '在瞄喵发布了一个新的梦想。' + '\n' + $scope.dream.about,
  445. thumb: $scope.dream.imgs[0].pic,
  446. media: {
  447. type: Wechat.Type.WEBPAGE,
  448. webpageUrl: config.server + "/admin/share/view?id=" + id + '&user_id = ' + $scope.user.id
  449. }
  450. },
  451. scene: Wechat.Scene.SESSION
  452. }, function () {
  453. //msg.alert('分享','分享成功');
  454. msg.success('分享成功');
  455. }, function (reason) {
  456. //msg.alert('分享','分享失败');
  457. msg.error('分享失败');
  458. });
  459. }
  460. if(type==1){
  461. Wechat.share({
  462. message: {
  463. title: $scope.dream.name,
  464. description: $scope.dream.user.nickname + '在瞄喵发布了一个新的梦想。' + '\n' + $scope.dream.about,
  465. thumb: $scope.dream.imgs[0].pic,
  466. media: {
  467. type: Wechat.Type.WEBPAGE,
  468. webpageUrl: config.server + "/admin/share/view?id=" + id
  469. }
  470. },
  471. scene: Wechat.Scene.TIMELINE
  472. }, function () {
  473. msg.success('分享成功');
  474. }, function (reason) {
  475. msg.error('分享失败');
  476. });
  477. }
  478. };
  479. //实时排行
  480. $scope.sort = {
  481. slide: ''
  482. };
  483. $scope.changeType = function (type) {
  484. $ionicScrollDelegate.scrollTop(true);
  485. $scope.type = type;
  486. };
  487. $scope.index = 0;
  488. $scope.vm = {
  489. coin:"",
  490. title:""
  491. };
  492. $scope.timer = '';
  493. var leftTimer = function (countDown) {
  494. if (isNaN(countDown)) {
  495. $scope.timer = '已结束';
  496. return;
  497. }
  498. if (countDown<=0) {
  499. $scope.timer = '已结束';
  500. return;
  501. }
  502. var day=parseInt(countDown/(24*60*60));
  503. var h=parseInt(countDown/(60*60)%24);
  504. var m=parseInt(countDown/60%60);
  505. var s=parseInt(countDown%60);
  506. //$scope.timer=(h<10?'0'+h:h)+'时'+(m<10?'0'+m:m)+'分'+(s<10?'0'+s:s)+'秒';
  507. if(day>0) $scope.timer = day+'天';
  508. if(day<0 && h>0) $scope.timer = h+'小时';
  509. if(day<0 && h<0 && m>0) $scope.timer = m+'分钟';
  510. if(day<0 && h<0 && m<0) $scope.timer = '已结束';
  511. /* if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  512. $scope.leftTimer = $interval(function () {
  513. if (countDown >= 1) leftTimer(countDown - 1);
  514. },1000);*/
  515. /*if(countDown<=0){
  516. $scope.timer='结束';
  517. }*/
  518. };
  519. $scope.changeIndex = function (index) {
  520. $scope.index = index;
  521. $scope.vm.coin = index*10;
  522. };
  523. $scope.vidEnded = function () {
  524. alert('播放完毕');
  525. };
  526. //实时计算支持乘数
  527. //$scope.calcmultiplier = function () {
  528. // $scope.multi.promise = $interval(function () {
  529. //
  530. // var date = new Date();
  531. // var inter = date.getTime() - $scope.multi.b.getTime();
  532. // var minutes = Math.floor(inter / (60 * 1000));
  533. // var number = $scope.multi.a * minutes + $scope.multi.c;//js浮点运算会失真,根据muti.a的可能值范围,比如乘以100再除以100
  534. // if (number<=1) {
  535. // number = 1;
  536. // }
  537. // $scope.multi.result = Math.round(number * 100 / 100);
  538. // },1000);
  539. //};
  540. $scope.supportDream = function (data) {
  541. if(!$scope.vm.coin){
  542. msg.error("请选择梦想币数量!");
  543. return ;
  544. }
  545. var data = {
  546. id:id,
  547. coin:$scope.vm.coin
  548. };
  549. homeService.supportDream(data).then(function(result){
  550. $scope.tosupport = false;
  551. $scope.load(id);
  552. homeService.myInfo().then(function(result){
  553. $scope.user = result.data.data;
  554. });
  555. $interval.cancel($scope.multi.promise);
  556. msg.text("发送成功",1000);
  557. });
  558. };
  559. $scope.collectionDream = function(is_collection){
  560. homeService.collectionDream(id,is_collection).then(function(result){
  561. $scope.dream.is_collection=result.data.data;
  562. })
  563. };
  564. $scope.add = function(is_collection){
  565. var data = {
  566. id:id,
  567. title:$scope.vm.title,
  568. pics:$scope.imgs,
  569. video:$scope.video.server
  570. };
  571. homeService.add_interaction(data).then(function(){
  572. $scope.load(id);
  573. $scope.closeModal();
  574. })
  575. };
  576. $scope.showAbout = true;
  577. $scope.hideAbout = false;
  578. $scope.showText = function(){
  579. $scope.aboutStyle = {
  580. "white-space" : "normal"
  581. };
  582. $scope.showAbout = false;
  583. $scope.hideAbout = true;
  584. };
  585. $scope.hideText = function(){
  586. $scope.aboutStyle = {
  587. "white-space" : "nowrap"
  588. };
  589. $scope.showAbout = true;
  590. $scope.hideAbout = false;
  591. };
  592. $scope.input = {
  593. placeholder: '评论',
  594. focus: false,
  595. show:false
  596. };
  597. $scope.showmore = function (index) {
  598. if ($scope.dream.interactions[index].showmore) {
  599. $scope.dream.interactions[index].showmore = false;
  600. } else {
  601. $scope.dream.interactions[index].showmore = true;
  602. }
  603. };
  604. $scope.replay = function ($event, name, to_userid, index) {
  605. $event.stopPropagation();
  606. $scope.input.focus = true;
  607. $scope.input.show = true;
  608. angular.forEach($scope.dream.interactions, function (item) {
  609. item.show = false;
  610. });
  611. $scope.dream.interactions[index].show = true;
  612. $scope.dream.interactions[index].focus = true;
  613. $scope.input.placeholder = "评论" + name+":";
  614. $scope.to_userid = to_userid;
  615. $scope.vm.title='';
  616. $scope.vm.comment='';
  617. };
  618. $scope.replayOther = function ($event, name, to_userid, index,currentindex) {
  619. debugger;
  620. $event.stopPropagation();
  621. if($scope.dream.interactions[index].comments[currentindex].user_id!=$scope.user.id){
  622. $scope.input.focus = true;
  623. $scope.input.show = true;
  624. angular.forEach($scope.dream.interactions, function (item) {
  625. item.show = false;
  626. });
  627. $scope.dream.interactions[index].show = true;
  628. $scope.dream.interactions[index].focus = true;
  629. $scope.input.placeholder = "评论" + name;
  630. $scope.to_userid = to_userid;
  631. $scope.vm.title='';
  632. $scope.vm.comment='';
  633. }
  634. else if($scope.timer!='已结束') {
  635. msg.confirm("评论","是否删除评论").then(function(result){
  636. if(result==true)
  637. {
  638. homeService.deleteComment($scope.dream.interactions[index].comments[currentindex].id).then(function(result){
  639. msg.text("删除成功");
  640. $scope.load(id);
  641. },function(error){
  642. msg.error(error.data.message);
  643. })
  644. }
  645. });
  646. }
  647. };
  648. $scope.ios={
  649. isIOS:ionic.Platform.isIOS(),
  650. productid:''
  651. }
  652. //充值
  653. $scope.charge = function(number){
  654. if($scope.ios.isIOS){
  655. if (number<2){
  656. msg.text('请选择充值金额');
  657. return;
  658. }
  659. console.log('购买productid:'+number);
  660. msg.loading();
  661. inAppPurchase
  662. .buy(number)
  663. .then(function (data) {
  664. msg.hide();
  665. console.log('购买then:'+JSON.stringify(data));
  666. return inAppPurchase.consume(data.productType, data.receipt, data.signature);
  667. })
  668. .then(function (data) {
  669. msg.hide();
  670. myService.orderIos(number).then(function (result) {
  671. console.log('服务器端购买成功:'+number);
  672. }, function (erro) {
  673. });
  674. console.log('购买成功:'+number);
  675. msg.success('购买成功');
  676. $timeout(function () {
  677. $scope.closeRechargeModal();
  678. }, 1000);
  679. })
  680. .catch(function (err) {
  681. msg.hide();
  682. console.log('购买失败:'+JSON.stringify(err));
  683. $timeout(function () {
  684. $scope.closeRechargeModal();
  685. }, 1000);
  686. // alert('购买失败:'+JSON.stringify(err));
  687. });
  688. }else{
  689. if (!number) {
  690. msg.text('请输入充值金额');
  691. return;
  692. }
  693. homeService.charge(number,2).then(function (result) {
  694. //todo:result需要返回支付宝或者微信的签名信息
  695. console.log("result: " + JSON.stringify(result));
  696. var payInfo = result.data.data;
  697. if ($scope.vm.payType == 1) { //支付宝
  698. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  699. $scope.clicksub = false;
  700. if (e.resultStatus == '9000') {
  701. alert(orderID);
  702. $timeout(function () {
  703. $scope.closeRechargeModal();
  704. }, 1000);
  705. homeService.myInfo().then(function (result) {
  706. $scope.user = result.data.data;
  707. });
  708. } else {
  709. msg.error("支付失败");
  710. // msg.error("支付失败:" + JSON.stringify(e));
  711. }
  712. }, function error(e) {
  713. $scope.clicksub = false;
  714. // msg.error("支付失败:" + JSON.stringify(e));
  715. msg.error("支付失败");
  716. });
  717. }
  718. if ($scope.vm.payType == 2) { //微信
  719. // var obj = JSON.parse(payInfo);
  720. var obj = payInfo.orderString;
  721. // console.log("obj: " + JSON.stringify(obj));
  722. var params = {
  723. partnerid: obj.partnerid, // merchant id
  724. prepayid: obj.prepayid, // prepay id
  725. noncestr: obj.noncestr, // nonce
  726. timestamp: obj.timestamp, // timestamp
  727. sign: obj.sign, // signed string
  728. };
  729. // console.log("result: " + JSON.stringify(params));
  730. Wechat.sendPaymentRequest(params, function (r) {
  731. // $scope.clicksub = false;
  732. $timeout(function () {
  733. $scope.closeRechargeModal();
  734. }, 1000);
  735. $scope.load(id,dream_user_id,interaction_id);
  736. // courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  737. // homeService.myInfo().then(function (result) {
  738. // $scope.user = result.data.data;
  739. // });
  740. // }, function (erro) {
  741. // // msg.alert("支付反馈失败:" + JSON.stringify(erro));
  742. // });
  743. }, function (reason) {
  744. $scope.clicksub = false;
  745. // msg.alert("支付失败:" + JSON.stringify(reason));
  746. });
  747. }
  748. });
  749. }
  750. };
  751. $scope.submitComment = function (index,to_userid) {
  752. var interaction = $scope.dream.interactions[index];
  753. var iid = interaction.id;
  754. // $scope.dream.interactions[index].comments.push($scope.vm.comment);
  755. $scope.input.focus = true;
  756. if ($scope.vm.comment && $scope.vm.comment == '' || !iid) return;
  757. var data = {
  758. id:iid,
  759. content:$scope.vm.comment,
  760. comment_user_id:to_userid,
  761. to_user_id: $scope.dream.user.id
  762. };
  763. if($scope.timer=='已结束'){
  764. msg.alert("评论","该梦想已结束,不支持评论");
  765. }
  766. else {
  767. homeService.add_comment(data).then(function(){
  768. msg.success('评论成功');
  769. $scope.vm.comment = '' ;
  770. $scope.load(id);
  771. $scope.closeModal();
  772. });
  773. }
  774. };
  775. $scope.bigImage = false;
  776. $scope.showBigImage = function ($event, imageName) {
  777. $event.stopPropagation();
  778. $scope.url = imageName;
  779. $scope.bigImage = true;
  780. };
  781. $scope.hideBigImage = function(){
  782. $scope.bigImage = false;
  783. };
  784. $ionicModal.fromTemplateUrl('qrCode.html', {
  785. scope: $scope,
  786. animation: 'slide-in-up'
  787. }).then(function(modal) {
  788. $scope.qrCodemodal = modal;
  789. });
  790. $scope.openCode = function($event) {
  791. $event.stopPropagation();
  792. $scope.qrCodemodal.show();
  793. $scope.vm.money = '';
  794. };
  795. $scope.closeCode = function() {
  796. $scope.qrCodemodal.hide();
  797. };
  798. $ionicModal.fromTemplateUrl('commentPic.html', {
  799. scope: $scope,
  800. animation: 'slide-in-up'
  801. }).then(function(modal) {
  802. $scope.CommentPicmodal = modal;
  803. });
  804. $scope.openCommentPic = function(pic,$event) {
  805. $event.stopPropagation();
  806. $scope.CommentPicmodal.show();
  807. $scope.commentPicUrl = pic;
  808. };
  809. $scope.closeCommentPic = function() {
  810. $scope.CommentPicmodal.hide();
  811. };
  812. $scope.addpict = function () {
  813. common.chooseImage().then(function (img) {
  814. common.uploadFiles(img,1).then(function (result) {
  815. var response = JSON.parse(result.response);
  816. var file = config.imgServer + response.data.file;
  817. $scope.imgs.push(file);
  818. }, function (error) {
  819. msg.error('图片上传失败');
  820. });
  821. }, function (error) {
  822. console.log('图片选择失败');
  823. });
  824. };
  825. $scope.deletefile = function (file) {
  826. var index = $scope.imgs.indexOf(file);
  827. $scope.imgs.splice(index, 1);
  828. common.deletefile(file).then(function () {
  829. })
  830. };
  831. $scope.addvideo = function () {
  832. common.chooseVideo().then(function (file) {
  833. msg.loading();
  834. common.uploadFiles(file, 2).then(function (result) {
  835. msg.hide();
  836. var response = JSON.parse(result.response);
  837. $scope.video.server = response.data.file;
  838. var file = config.imgServer+response.data.file;
  839. $scope.video.isOK = true;
  840. $scope.video.file = file;
  841. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  842. }, function (error) {
  843. //msg.error('视频上传失败');
  844. msg.hide();
  845. msg.error(JSON.stringify(error));
  846. });
  847. }, function (erro) {
  848. console.log('选择视频失败');
  849. });
  850. };
  851. $scope.deletevideo = function (file) {
  852. $scope.video = {};
  853. common.deletefile(file).then(function (res) {
  854. },function(erro){
  855. alert(JSON.stringify(erro));
  856. })
  857. };
  858. $ionicModal.fromTemplateUrl('recharge-modal.html', {
  859. scope: $scope,
  860. animation: 'slide-in-up'
  861. }).then(function(modal) {
  862. $scope.rechagemodal = modal;
  863. });
  864. $scope.openRechargeModal = function() {
  865. $scope.rechagemodal.show();
  866. $scope.vm.money = '';
  867. if($scope.ios.isIOS){
  868. var productIds = ['apple1001','apple1002','apple1003','apple1004']; // <- Add your product Ids here
  869. msg.loading();
  870. inAppPurchase.getProducts(productIds).then(function (products) {
  871. msg.hide();
  872. $scope.products = products;
  873. console.log('products:'+JSON.stringify(products));
  874. }).catch(function (err) {
  875. msg.hide();
  876. console.log(err);
  877. });
  878. }
  879. };
  880. $scope.closeRechargeModal = function() {
  881. $scope.rechagemodal.hide();
  882. };
  883. $ionicModal.fromTemplateUrl('interaction-modal.html', {
  884. scope: $scope,
  885. animation: 'slide-in-up'
  886. }).then(function(modal) {
  887. $scope.modal = modal;
  888. });
  889. $scope.openModal = function() {
  890. $scope.modal.show();
  891. $scope.vm.title = '';
  892. $scope.imgs = [];
  893. $scope.video = {};
  894. };
  895. $scope.closeModal = function() {
  896. $scope.modal.hide();
  897. };
  898. //当我们用到模型时,清除它!
  899. $scope.$on('$destroy', function() {
  900. $scope.modal.remove();
  901. $scope.rechagemodal.remove();
  902. });
  903. $scope.toMessage = function(){
  904. if($location.path()=="/app/home/dreamdetail"){
  905. $state.go("app.message");
  906. }
  907. else {
  908. $state.go("app.my_message");
  909. }
  910. }
  911. }]);
  912. app.controller('userDetailCtrl', ["$scope","$location", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$timeout", "$ionicScrollDelegate", "$interval"
  913. , function ($scope,$location, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $timeout, $ionicScrollDelegate, $interval) {
  914. var id = $stateParams.id;
  915. $scope.items = $stateParams.items;
  916. $scope.$on('$ionicView.beforeEnter', function () {
  917. $ionicTabsDelegate.showBar(false);
  918. });
  919. $scope.attentionUser = function(is_care){
  920. homeService.attentionUser(id,is_care).then(function(result){
  921. $scope.items.is_care=result.data.data;
  922. })
  923. };
  924. $scope.next = function (type) {
  925. //type:1 前一个,type:2 后一个
  926. if($scope.items.imgs.length>0){
  927. if(type==1)
  928. {
  929. var temp= $scope.items.imgs.splice(0,1);
  930. $scope.items.imgs.push(temp[0]);
  931. }
  932. if (type==2){
  933. var temp= $scope.items.imgs.splice($scope.items.imgs.length-1,1);
  934. $scope.items.imgs.unshift(temp[0]);
  935. }
  936. }
  937. };
  938. $scope.bigImage = false;
  939. $scope.showBigImage = function(imageName,imageIndex){
  940. $scope.url = imageName;
  941. $scope.imageIndex = imageIndex;
  942. $scope.bigImage = true;
  943. };
  944. $scope.hideBigImage = function(){
  945. $scope.bigImage = false;
  946. };
  947. $scope.swipeLeft = function (imageIndex) {
  948. if ($scope.imageIndex < $scope.items.imgs.length - 1 && $scope.imageIndex >= 0)
  949. $scope.imageIndex = $scope.imageIndex + 1;
  950. else {
  951. //如果图片已经是最后一张图片了,则取index = 0
  952. $scope.imageIndex = 0;
  953. }
  954. //替换url,展示图片
  955. $scope.url = $scope.items.imgs[$scope.imageIndex].pic; //$scope定义一个变量Url,这里会在大图出现后再次点击隐藏大图使用
  956. $scope.bigImage = true; //显示大图
  957. };
  958. $scope.swipeRight = function (imageIndex) {
  959. if ($scope.imageIndex <= $scope.items.imgs.length - 1 && $scope.imageIndex > 0)
  960. $scope.imageIndex = $scope.imageIndex - 1;
  961. else {
  962. //如果图片已经是第一张图片了,则取index = Images.length-1
  963. $scope.imageIndex = $scope.items.imgs.length - 1;
  964. }
  965. //替换url,展示图片
  966. $scope.url = $scope.items.imgs[$scope.imageIndex].pic; //$scope定义一个变量Url,这里会在大图出现后再次点击隐藏大图使用
  967. $scope.bigImage = true; //显示大图
  968. };
  969. $scope.cancelSupport = function () {
  970. $scope.tosupport = false;
  971. $scope.toshare = false;
  972. };
  973. $scope.toshare = false;
  974. $scope.toshare = false;
  975. $scope.toRecharge = function(){
  976. $state.go("app.recharge")
  977. };
  978. $scope.toDetail = function (dream_id) {
  979. if($scope.items.near_dream==null){
  980. msg.alert("当前梦想","该用户没有当前梦想");
  981. }
  982. if($scope.items.near_dream!=null){
  983. var dream_id = $scope.items.near_dream.id;
  984. if($location.path()=="/app/home/userDetail"){
  985. $state.go('app.home_dreamdetail',{id:dream_id});
  986. }
  987. else {
  988. $state.go('app.my_dreamdetail',{id:dream_id});
  989. }
  990. }
  991. };
  992. $scope.toOldDream = function(){
  993. if($scope.items.dreams.length<2){
  994. msg.alert("曾经的梦想","该用户没有曾经的梦想");
  995. }
  996. if($scope.items.dreams.length>1){
  997. if($location.path()=="/app/home/userDetail"){
  998. $state.go('app.oldDream',{user_id:$scope.items.user.id});
  999. }
  1000. else {
  1001. $state.go('app.myOldDream',{user_id:$scope.items.user.id});
  1002. }
  1003. }
  1004. };
  1005. $scope.toSupportDream = function(){
  1006. if($scope.items.sup_dreams.length==0){
  1007. msg.alert("支持的梦想","该用户没有支持的梦想");
  1008. }
  1009. if($scope.items.sup_dreams.length!=0){
  1010. if($scope.items.dreams.length>1){
  1011. if($location.path()=="/app/home/userDetail"){
  1012. $state.go('app.supportDream',{user_id:$scope.items.user.id});
  1013. }
  1014. else {
  1015. $state.go('app.mySupportDream',{user_id:$scope.items.user.id});
  1016. }
  1017. }
  1018. }
  1019. };
  1020. $scope.collectionDream = function(is_collection){
  1021. homeService.collectionDream(id,is_collection).then(function(result){
  1022. $scope.user.is_collection=result.data.data;
  1023. })
  1024. };
  1025. }]);
  1026. app.controller('homeCollectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  1027. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  1028. $scope.$on('$ionicView.beforeEnter', function () {
  1029. $ionicTabsDelegate.showBar(false);
  1030. myService.collect().then(function(result){
  1031. $scope.dreams = result.data.data.dreams;
  1032. });
  1033. });
  1034. $scope.toDetail = function (id) {
  1035. $state.go('app.home_dreamdetail',{id:id});
  1036. };
  1037. }]);
  1038. app.controller('shareDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1039. , function ($scope,homeService,$stateParams, $state, msg) {
  1040. $scope.dream = $stateParams.item;
  1041. $scope.showAbout = true;
  1042. $scope.hideAbout = false;
  1043. $scope.showText = function(){
  1044. $scope.aboutStyle = {
  1045. "white-space" : "normal"
  1046. };
  1047. $scope.showAbout = false;
  1048. $scope.hideAbout = true;
  1049. };
  1050. $scope.hideText = function(){
  1051. $scope.aboutStyle = {
  1052. "white-space" : "nowrap"
  1053. };
  1054. $scope.showAbout = true;
  1055. $scope.hideAbout = false;
  1056. };
  1057. }]);
  1058. //app.controller('homeMessageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  1059. // , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  1060. // $scope.$on('$ionicView.beforeEnter', function () {
  1061. // $ionicTabsDelegate.showBar(false);
  1062. // myService.messageInfo().then(function(result){
  1063. // $scope.infos = result.data.data;
  1064. // },function(error){
  1065. //
  1066. // });
  1067. // });
  1068. // $scope.notRead = function(){
  1069. // myService.notRead().then(function(result){
  1070. // myService.messageInfo().then(function(result){
  1071. // $scope.infos = result.data.data;
  1072. // },function(error){
  1073. //
  1074. // });
  1075. // },function(error){
  1076. //
  1077. // })
  1078. // };
  1079. // //系统消息
  1080. // $scope.systemInfo = function(){
  1081. // $state.go("app.message_sys");
  1082. // myService.systemInfo().then(function(result){
  1083. // },function(error){
  1084. //
  1085. // });
  1086. // };
  1087. // //回复我的
  1088. // $scope.replyMy = function(){
  1089. // $state.go("app.message_reply");
  1090. // myService.replyMy().then(function(result){
  1091. //
  1092. // },function(error){
  1093. //
  1094. // });
  1095. // };
  1096. // $scope.personalLetter = function(){
  1097. // $state.go("app.letter");
  1098. // }
  1099. // }]);
  1100. app.controller('oldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1101. , function ($scope,homeService,$stateParams, $state, msg) {
  1102. var user_id = $stateParams.user_id;
  1103. $scope.$on('$ionicView.beforeEnter',function(){
  1104. $scope.toUserDetail(user_id);
  1105. });
  1106. $scope.toUserDetail = function(user_id){
  1107. homeService.toUserDetail(user_id).then(function(result){
  1108. $scope.items = result.data.data;
  1109. $scope.user = result.data.data.user;
  1110. $scope.dreams = $scope.user.dreams;
  1111. },function(error){
  1112. })
  1113. };
  1114. $scope.toDetail = function(id){
  1115. $state.go('app.home_dreamdetail',{id:id});
  1116. // $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
  1117. };
  1118. }]);
  1119. app.controller('supportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1120. , function ($scope,homeService,$stateParams, $state, msg) {
  1121. var user_id = $stateParams.user_id;
  1122. $scope.$on('$ionicView.beforeEnter',function(){
  1123. $scope.toUserDetail(user_id);
  1124. });
  1125. $scope.toUserDetail = function(user_id){
  1126. homeService.toUserDetail(user_id).then(function(result){
  1127. $scope.items = result.data.data;
  1128. $scope.user = result.data.data.user;
  1129. $scope.dreams = $scope.user.sup_dream;
  1130. },function(error){
  1131. })
  1132. };
  1133. $scope.toDetail = function(id){
  1134. $state.go('app.home_dreamdetail',{id:id});
  1135. // $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
  1136. }
  1137. }]);
  1138. app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  1139. , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
  1140. $scope.showMore = function (keyword,index) {
  1141. if(!keyword)return;
  1142. $scope.index = index;
  1143. $scope.search(keyword);
  1144. };
  1145. $scope.search = function (keyword) {
  1146. $scope.vm.keyword = keyword;
  1147. homeService.search(keyword).then(function(result){
  1148. $scope.isResult = true;
  1149. $scope.dream_infos = result.data.data.dream_infos;
  1150. $scope.user_infos = result.data.data.user_infos;
  1151. });
  1152. };
  1153. $scope.toUserDetail = function (id) {
  1154. homeService.toUserDetail(id).then(function(result){
  1155. $scope.items = result.data.data;
  1156. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  1157. },function(error){
  1158. //msg.error(msg.data.error)
  1159. })
  1160. };
  1161. $scope.toDetail = function (id) {
  1162. $state.go('app.home_dreamdetail',{id:id});
  1163. };
  1164. $scope.$on('$ionicView.beforeEnter', function () {
  1165. $scope.isResult = false;
  1166. $scope.index = 0;
  1167. $scope.vm = {
  1168. keyword : ""
  1169. };
  1170. $ionicTabsDelegate.showBar(false);
  1171. // $ionicNavBarDelegate.showBackButton(false);
  1172. homeService.search('').then(function(result){
  1173. $scope.hot_searches = result.data.data.hot_searches;
  1174. $scope.history_searches = result.data.data.history_searches;
  1175. });
  1176. });
  1177. }]);
  1178. app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  1179. , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) {
  1180. }]);
  1181. app.controller('homeDreamsCtrl', ["$scope", "$state", "myService", "msg"
  1182. , function ($scope, $state, myService, msg) {
  1183. $scope.$on('$ionicView.beforeEnter', function () {
  1184. myService.myDream().then(function(result){
  1185. console.log(result.data.data);
  1186. $scope.dreams = result.data.data;
  1187. });
  1188. });
  1189. $scope.toDetail = function (id) {
  1190. $state.go('app.home_dreamdetail',{id:id});
  1191. };
  1192. }]);
  1193. })(angular.module('app.controllers'));