home.js 51 KB

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