home.js 54 KB

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