home.js 51 KB

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