home.js 51 KB

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