home.js 53 KB

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