home.js 51 KB

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