home.js 51 KB

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