home.js 51 KB

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