home.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  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(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. };
  28. $ionicPopover.fromTemplateUrl('my-popover.html', {
  29. scope: $scope
  30. }).then(function (popover) {
  31. $scope.popover = popover;
  32. });
  33. $scope.toggleLeftSideMenu = function () {
  34. $ionicSideMenuDelegate.toggleLeft();
  35. };
  36. $scope.openPopover = function ($event) {
  37. $scope.popover.show($event);
  38. };
  39. $scope.closePopover = function () {
  40. $scope.popover.hide();
  41. };
  42. $scope.changetype = function (type) {
  43. $scope.type = type;
  44. $scope.load(true);
  45. };
  46. $scope.toDetail = function (id) {
  47. $state.go('app.home_dreamdetail',{id:id});
  48. };
  49. $scope.toUserDetail = function (id) {
  50. homeService.toUserDetail(id).then(function(result){
  51. $scope.items = result.data.data;
  52. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  53. },function(error){
  54. //msg.error(msg.data.error)
  55. })
  56. };
  57. $scope.changeFilter = function (input) {
  58. switch (input) {
  59. case '1':
  60. if ($scope.filter.sex == 1) {
  61. $scope.filter.sex = 0;
  62. } else {
  63. $scope.filter.sex = 1;
  64. }
  65. break;
  66. case '2':
  67. if ($scope.filter.sex == 2) {
  68. $scope.filter.sex = 0;
  69. } else {
  70. $scope.filter.sex = 2;
  71. }
  72. break;
  73. default:
  74. }
  75. };
  76. $scope.filter = {
  77. hasMore: false,
  78. pageIndex: 1,
  79. pageSize: 20,
  80. sex: 0,//1男,2女,0:全部,
  81. age: 0,//0:全部,1:18-21,2:22-25,3:26-29,4:30-33,5:34-37,6:>38,
  82. city:''
  83. };
  84. $scope.doFilter = function () {
  85. homeService.doFilter($scope.filter.sex,$scope.filter.age,$scope.filter.city).then(function(result){
  86. $scope.index.dreams = result.data.data.dreams.data;
  87. },function(error){
  88. msg.error(data.error.message);
  89. });
  90. //$ionicSideMenuDelegate.toggleRight();
  91. };
  92. $scope.index = {
  93. banner: [],
  94. users: [],
  95. dreams:[]
  96. };
  97. $scope.next = function (type) {
  98. //type:1 前一个,type:2 后一个
  99. if($scope.index.users.length>0){
  100. if(type==1)
  101. {
  102. var temp= $scope.index.users.splice(0,1);
  103. $scope.index.users.push(temp[0]);
  104. }
  105. if (type==2){
  106. var temp= $scope.index.users.splice($scope.index.users.length-1,1);
  107. $scope.index.users.unshift(temp[0]);
  108. }
  109. }
  110. };
  111. $scope.load = function (init) {
  112. if (init) {
  113. $scope.filter.pageIndex = 1;
  114. $scope.index.dreams = [];
  115. }
  116. msg.loading();
  117. homeService.index($scope.type, $scope.filter.pageIndex).then(function (result) {
  118. msg.hide();
  119. $scope.index.banners = result.data.data.banners;
  120. $scope.index.users = result.data.data.users;
  121. $scope.filter.pageIndex++;
  122. var more = (result.data.data.dreams.data.length >= $scope.filter.pageSize);
  123. $scope.filter.hasMore = more;
  124. $scope.index.dreams = $scope.index.dreams.concat(result.data.data.dreams.data);
  125. if (init) {
  126. $scope.$broadcast('scroll.refreshComplete');
  127. } else {
  128. $scope.$broadcast('scroll.infiniteScrollComplete');
  129. }
  130. }, function (error) {
  131. msg.hide();
  132. });
  133. };
  134. $scope.qrscan = function () {
  135. cordova.plugins.barcodeScanner.scan(
  136. function (result) {
  137. //扫码成功后执行的回调函数
  138. alert("收到一个二维码\n" +
  139. "扫码文字结果: " + result.text + "\n" +
  140. "格式: " + result.format + "\n" +
  141. "是否在扫码页面取消扫码: " + result.cancelled);
  142. },
  143. function (error) {
  144. //扫码失败执行的回调函数
  145. alert("Scanning failed: " + error);
  146. }, {
  147. preferFrontCamera: false, // iOS and Android 设置前置摄像头
  148. showFlipCameraButton: true, // iOS and Android 显示旋转摄像头按钮
  149. showTorchButton: true, // iOS and Android 显示打开闪光灯按钮
  150. torchOn: false, // Android, launch with the torch switched on (if available)打开手电筒
  151. prompt: "在扫描区域内放置二维码", // Android提示语
  152. resultDisplayDuration: 500, // Android, display scanned text for X ms.
  153. //0 suppresses it entirely, default 1500 设置扫码时间的参数
  154. formats: "QR_CODE", // 二维码格式可设置多种类型
  155. orientation: "portrait", // Android only (portrait|landscape),
  156. //default unset so it rotates with the device在安卓上 landscape 是横屏状态
  157. disableAnimations: true, // iOS 是否禁止动画
  158. disableSuccessBeep: false // iOS 禁止成功后提示声音 “滴”
  159. }
  160. );
  161. };
  162. $scope.data = {};
  163. //$scope.load(true);
  164. $scope.$on('$ionicView.beforeLeave', function () {
  165. $scope.popover.hide();
  166. $scope.load(true);
  167. });
  168. }]);
  169. app.controller('dreamDetailCtrl', ["$scope", "$state", "WechatService","$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams","$ionicBackdrop", "$timeout", "$ionicScrollDelegate", "$interval"
  170. , function ($scope, $state,WechatService,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams,$ionicBackdrop, $timeout, $ionicScrollDelegate, $interval) {
  171. var id = $stateParams.id;
  172. var top3user = '';
  173. $scope.chosedIndex = 0;
  174. $scope.clickAvatar = function(index){
  175. $scope.chosedIndex = index;
  176. homeService.myInfo().then(function(result){
  177. $scope.user = result.data.data;
  178. });
  179. };
  180. // id=5;
  181. $scope.$on('$ionicView.beforeEnter', function () {
  182. $ionicTabsDelegate.showBar(false);
  183. $scope.load(id);
  184. $scope.thisUser = storage.getObject('user');
  185. homeService.myInfo().then(function(result){
  186. $scope.user = result.data.data;
  187. });
  188. homeService.messageInfo().then(function(result){
  189. $scope.infos = result.data.data;
  190. if($scope.infos.letter.is_read==0 && $scope.infos.reply.is_read==0 && $scope.infos.systemInfo.is_read==0){
  191. $scope.showMessage=0;
  192. }
  193. else {
  194. $scope.showMessage=1;
  195. }
  196. },function(error){
  197. });
  198. });
  199. $scope.$on('$ionicView.leave', function () {
  200. if($scope.multi.promise)$interval.cancel($scope.multi.promise);
  201. if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  202. });
  203. $scope.toSort = function(){
  204. //$scope.type = 3;
  205. $scope.changeType(3)
  206. };
  207. $scope.load = function (id) {
  208. msg.loading();
  209. homeService.dreamDetail(id).then(function (result) {
  210. msg.hide();
  211. console.log(result);
  212. $scope.showCode = function(codeName){
  213. $scope.url = codeName;
  214. $scope.code = true;
  215. };
  216. $scope.hideCode = function(){
  217. $scope.code = false;
  218. };
  219. $scope.dream = result.data.data;
  220. if($scope.timer=='已结束'|| 100*$scope.dream.get_coin/$scope.dream.coin>=100){
  221. $scope.codeBtn = true;
  222. }
  223. if($scope.dream.video){
  224. $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
  225. $scope.dream.video = config.imgServer+$scope.dream.video;
  226. }
  227. var reg = new RegExp("\n", "g");
  228. $scope.dream.about = $scope.dream.about.replace(reg, "<br/>");
  229. var end_time = new Date($scope.dream.end_time.replace(/-/g, "/"));
  230. var date = new Date();
  231. var inter = (end_time.getTime() - date.getTime()) / 1000;
  232. leftTimer(inter);
  233. $scope.multi.a = $scope.dream.a;
  234. $scope.multi.b = new Date($scope.dream.created_at.replace(/-/g, "/"));
  235. $scope.multi.c = $scope.dream.c;
  236. $scope.multi.promise = $scope.dream.a;
  237. var newtop3user = '' ;
  238. angular.forEach($scope.dream.top3user, function(user) {
  239. newtop3user= newtop3user +user.id+","
  240. });
  241. if(top3user!=''&&newtop3user!=top3user){
  242. //测试动画切换
  243. $timeout(function() {
  244. $scope.sort.slide1 = 'list-grow-animation';
  245. $scope.sort.slide2 = 'slide-in-both-ways';
  246. $scope.sort.slide3 = 'bounce-animation';
  247. }, 50);
  248. }
  249. top3user = newtop3user;
  250. if($scope.dream.top3user[0])$scope.sort.first = $scope.dream.top3user[0].avatar;
  251. if($scope.dream.top3user[1])$scope.sort.second = $scope.dream.top3user[1].avatar;
  252. if($scope.dream.top3user[2])$scope.sort.third = $scope.dream.top3user[2].avatar;
  253. $scope.calcmultiplier();
  254. }, function (error) {
  255. msg.hide();
  256. });
  257. };
  258. $scope.openSupport = function () {
  259. msg.alert("支持乘数说明","支持乘数支持乘数支持乘数支持乘数");
  260. };
  261. $scope.multi = {
  262. a: '',
  263. b: '',
  264. c: '',
  265. result: 1,
  266. promise:null
  267. };
  268. $scope.type = 1;//tab切换
  269. $scope.tosupport = false;
  270. $scope.support = function ($event) {
  271. $event.stopPropagation();
  272. $scope.tosupport = true;
  273. $scope.vm.coin = 0;
  274. $scope.index = 0;
  275. };
  276. $scope.cancelSupport = function () {
  277. $scope.tosupport = false;
  278. $scope.toshare = false;
  279. $scope.input.show = false;
  280. };
  281. $scope.toshare = false;
  282. $scope.toRecharge = function(){
  283. $state.go("app.recharge")
  284. };
  285. $scope.share = function (type,$event) {
  286. $scope.toshare = true;
  287. if (type==0) {//分享给朋友
  288. /* Wechat.share({
  289. text: "分享的文字",
  290. scene: Wechat.Scene.SESSION // share to 好友
  291. }, function () {
  292. alert("Success");
  293. }, function (reason) {
  294. alert("Failed: " + reason);
  295. });*/
  296. Wechat.share({
  297. message: {
  298. title:"瞄瞄",
  299. description:"HELLO,这是我的梦想,快来围观吧!",
  300. thumb:"img/icon_cat_h.png",
  301. media: {
  302. type: Wechat.Type.WEBPAGE,
  303. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  304. }
  305. },
  306. scene: Wechat.Scene.SESSION
  307. }, function () {
  308. alert("Success");
  309. }, function (reason) {
  310. alert("Failed: " + reason);
  311. });
  312. }
  313. if(type==1){
  314. Wechat.share({
  315. message: {
  316. title:"瞄瞄",
  317. description:"HELLO,这是我的梦想,快来围观吧!",
  318. thumb:"img/icon_cat_h.png",
  319. media: {
  320. type: Wechat.Type.WEBPAGE,
  321. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  322. }
  323. },
  324. scene: Wechat.Scene.TIMELINE
  325. }, function () {
  326. alert("Success");
  327. }, function (reason) {
  328. alert("Failed: " + reason);
  329. });
  330. }
  331. // $state.go("app.shareDream",{item:$scope.dream});
  332. };
  333. //实时排行
  334. $scope.sort = {
  335. slide: ''
  336. };
  337. $scope.changeType = function (type) {
  338. $ionicScrollDelegate.scrollTop(true);
  339. $scope.type = type;
  340. };
  341. $scope.index = 0;
  342. $scope.vm = {
  343. coin:"",
  344. title:""
  345. };
  346. $scope.timer = '';
  347. var leftTimer = function (countDown) {
  348. if (isNaN(countDown)) {
  349. $scope.timer = '已结束';
  350. return;
  351. }
  352. var day=parseInt(countDown/(24*60*60));
  353. var h=parseInt(countDown/(60*60)%24);
  354. var m=parseInt(countDown/60%60);
  355. var s=parseInt(countDown%60);
  356. //$scope.timer=(h<10?'0'+h:h)+'时'+(m<10?'0'+m:m)+'分'+(s<10?'0'+s:s)+'秒';
  357. if(day>0) $scope.timer = day+'天';
  358. if(day<0 && h>0) $scope.timer = h+'小时';
  359. if(day<0 && h<0 && m>0) $scope.timer = m+'分钟';
  360. if(day<0 && h<0 && m<0) $scope.timer = '已结束';
  361. /* if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  362. $scope.leftTimer = $interval(function () {
  363. if (countDown >= 1) leftTimer(countDown - 1);
  364. },1000);*/
  365. /*if(countDown<=0){
  366. $scope.timer='结束';
  367. }*/
  368. };
  369. $scope.changeIndex = function (index) {
  370. $scope.index = index;
  371. $scope.vm.coin = index*10;
  372. };
  373. $scope.vidEnded = function () {
  374. alert('播放完毕');
  375. };
  376. //实时计算支持乘数
  377. $scope.calcmultiplier = function () {
  378. $scope.multi.promise = $interval(function () {
  379. var date = new Date();
  380. var inter = date.getTime() - $scope.multi.b.getTime();
  381. var minutes = Math.floor(inter / (60 * 1000));
  382. var number = $scope.multi.a * minutes + $scope.multi.c;//js浮点运算会失真,根据muti.a的可能值范围,比如乘以100再除以100
  383. if (number<=1) {
  384. number = 1;
  385. }
  386. //$scope.multi.result = Math.round(number * 100) / 100;
  387. $scope.multi.result = Math.round(number * 100 / 100);
  388. },1000);
  389. // 点击支持取消 $interval.cancel($scope.multi.promise); 获取数据后重新开始执行
  390. };
  391. $scope.supportDream = function (data) {
  392. if(!$scope.vm.coin){
  393. msg.error("请选择梦想币数量!");
  394. return ;
  395. }
  396. var data = {
  397. id:id,
  398. coin:$scope.vm.coin
  399. };
  400. homeService.supportDream(data).then(function(result){
  401. $scope.tosupport = false;
  402. $scope.load(id);
  403. homeService.myInfo().then(function(result){
  404. $scope.user = result.data.data;
  405. });
  406. $interval.cancel($scope.multi.promise);
  407. msg.text("发送成功");
  408. })
  409. };
  410. $scope.collectionDream = function(is_collection){
  411. homeService.collectionDream(id,is_collection).then(function(result){
  412. $scope.dream.is_collection=result.data.data;
  413. })
  414. };
  415. $scope.add = function(is_collection){
  416. var data = {
  417. id:id,
  418. title:$scope.vm.title,
  419. pics:$scope.imgs,
  420. video:$scope.video.server
  421. };
  422. homeService.add_interaction(data).then(function(){
  423. $scope.load(id);
  424. $scope.closeModal();
  425. })
  426. };
  427. $scope.showAbout = true;
  428. $scope.hideAbout = false;
  429. $scope.showText = function(){
  430. $scope.aboutStyle = {
  431. "white-space" : "normal"
  432. };
  433. $scope.showAbout = false;
  434. $scope.hideAbout = true;
  435. };
  436. $scope.hideText = function(){
  437. $scope.aboutStyle = {
  438. "white-space" : "nowrap"
  439. };
  440. $scope.showAbout = true;
  441. $scope.hideAbout = false;
  442. };
  443. $scope.input = {
  444. placeholder: '评论',
  445. focus: false,
  446. show:false
  447. };
  448. $scope.showmore = function (index) {
  449. if ($scope.dream.interactions[index].showmore) {
  450. $scope.dream.interactions[index].showmore = false;
  451. } else {
  452. $scope.dream.interactions[index].showmore = true;
  453. }
  454. }
  455. $scope.replay = function ($event, name, index) {
  456. $event.stopPropagation();
  457. $scope.input.focus = true;
  458. $scope.input.show = true;
  459. angular.forEach($scope.dream.interactions, function (item) {
  460. item.show = false;
  461. })
  462. $scope.dream.interactions[index].show = true;
  463. $scope.input.placeholder = "评论" + name+":";
  464. $scope.vm.title='';
  465. };
  466. $scope.submitComment = function (index) {
  467. var interaction = $scope.dream.interactions[index];
  468. var iid = interaction.id;
  469. // $scope.dream.interactions[index].comments.push($scope.vm.comment);
  470. $scope.input.focus = true;
  471. if ($scope.vm.comment && $scope.vm.comment == '' || !iid) return;
  472. var data = {
  473. id:iid,
  474. content:$scope.vm.comment
  475. };
  476. console.log($scope.vm.comment+" "+iid);
  477. homeService.add_comment(data).then(function(){
  478. $scope.vm.comment = '' ;
  479. $scope.load(id);
  480. $scope.closeModal();
  481. })
  482. };
  483. $scope.bigImage = false;
  484. $scope.showBigImage = function ($event, imageName) {
  485. $event.stopPropagation();
  486. $scope.url = imageName;
  487. $scope.bigImage = true;
  488. };
  489. $scope.hideBigImage = function(){
  490. $scope.bigImage = false;
  491. };
  492. $ionicModal.fromTemplateUrl('qrCode.html', {
  493. scope: $scope,
  494. animation: 'slide-in-up'
  495. }).then(function(modal) {
  496. $scope.qrCodemodal = modal;
  497. });
  498. $scope.openCode = function() {
  499. $scope.qrCodemodal.show();
  500. $scope.vm.money = '';
  501. };
  502. $scope.closeCode = function() {
  503. $scope.qrCodemodal.hide();
  504. };
  505. $ionicModal.fromTemplateUrl('commentPic.html', {
  506. scope: $scope,
  507. animation: 'slide-in-up'
  508. }).then(function(modal) {
  509. $scope.CommentPicmodal = modal;
  510. });
  511. $scope.openCommentPic = function(pic) {
  512. $scope.CommentPicmodal.show();
  513. $scope.commentPicUrl = pic;
  514. };
  515. $scope.closeCommentPic = function() {
  516. $scope.CommentPicmodal.hide();
  517. };
  518. $scope.addpict = function () {
  519. common.chooseImage().then(function (img) {
  520. common.uploadFiles(img,1).then(function (result) {
  521. var response = JSON.parse(result.response);
  522. var file = response.data.file;
  523. $scope.imgs.push(config.imgServer+file);
  524. console.log(JSON.stringify(config.imgServer+file));
  525. }, function (error) {
  526. msg.error('图片上传失败');
  527. });
  528. }, function (error) {
  529. console.log('图片选择失败');
  530. });
  531. };
  532. $scope.deletefile = function (file) {
  533. var index = $scope.imgs.indexOf(file);
  534. $scope.imgs.splice(index, 1);
  535. common.deletefile(file).then(function () {
  536. })
  537. };
  538. $scope.addvideo = function () {
  539. common.chooseVideo().then(function (file) {
  540. common.uploadFiles(file, 2).then(function (result) {
  541. var response = JSON.parse(result.response);
  542. $scope.video.server = response.data.file;
  543. var file = config.imgServer+response.data.file;
  544. console.log("file:"+file);
  545. $scope.video.isOK = true;
  546. $scope.video.file = file;
  547. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  548. console.log("vpic:"+$scope.video.vpic);
  549. }, function (error) {
  550. msg.error('视频上传失败');
  551. });
  552. }, function (erro) {
  553. console.log('选择视频失败');
  554. });
  555. };
  556. $ionicModal.fromTemplateUrl('recharge-modal.html', {
  557. scope: $scope,
  558. animation: 'slide-in-up'
  559. }).then(function(modal) {
  560. $scope.rechagemodal = modal;
  561. });
  562. $scope.openRechargeModal = function() {
  563. $scope.rechagemodal.show();
  564. $scope.vm.money = '';
  565. };
  566. $scope.closeRechargeModal = function() {
  567. $scope.rechagemodal.hide();
  568. };
  569. $ionicModal.fromTemplateUrl('interaction-modal.html', {
  570. scope: $scope,
  571. animation: 'slide-in-up'
  572. }).then(function(modal) {
  573. $scope.modal = modal;
  574. });
  575. $scope.openModal = function() {
  576. $scope.modal.show();
  577. $scope.vm.title = '';
  578. $scope.imgs = [];
  579. $scope.video = {};
  580. };
  581. $scope.closeModal = function() {
  582. $scope.modal.hide();
  583. };
  584. //当我们用到模型时,清除它!
  585. $scope.$on('$destroy', function() {
  586. $scope.modal.remove();
  587. });
  588. $scope.toMessage = function(){
  589. $state.go("app.message");
  590. }
  591. }]);
  592. app.controller('myDreamDetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
  593. , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $ionicModal, $timeout, $ionicScrollDelegate, $interval) {
  594. var id = $stateParams.id;
  595. var top3user = '';
  596. $scope.chosedIndex = 0;
  597. $scope.clickAvatar = function(index){
  598. $scope.chosedIndex = index;
  599. homeService.myInfo().then(function(result){
  600. $scope.user = result.data.data;
  601. });
  602. };
  603. // id=5;
  604. $scope.$on('$ionicView.beforeEnter', function () {
  605. $ionicTabsDelegate.showBar(false);
  606. $scope.load(id);
  607. $scope.thisUser = storage.getObject('user');
  608. homeService.myInfo().then(function(result){
  609. $scope.user = result.data.data;
  610. });
  611. homeService.messageInfo().then(function(result){
  612. $scope.infos = result.data.data;
  613. if($scope.infos.letter.is_read==0 && $scope.infos.reply.is_read==0 && $scope.infos.systemInfo.is_read==0){
  614. $scope.showMessage=0;
  615. }
  616. else {
  617. $scope.showMessage=1;
  618. }
  619. },function(error){
  620. });
  621. });
  622. $scope.$on('$ionicView.leave', function () {
  623. if($scope.multi.promise)$interval.cancel($scope.multi.promise);
  624. if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  625. });
  626. $scope.toSort = function(){
  627. //$scope.type = 3;
  628. $scope.changeType(3)
  629. };
  630. $scope.load = function (id) {
  631. msg.loading();
  632. homeService.dreamDetail(id).then(function (result) {
  633. msg.hide();
  634. console.log(result);
  635. $scope.showCode = function(codeName){
  636. $scope.url = codeName;
  637. $scope.code = true;
  638. };
  639. $scope.hideCode = function(){
  640. $scope.code = false;
  641. };
  642. $scope.dream = result.data.data;
  643. if($scope.timer=='已结束'|| 100*$scope.dream.get_coin/$scope.dream.coin>=100){
  644. $scope.codeBtn = true;
  645. }
  646. if($scope.dream.video){
  647. $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
  648. $scope.dream.video = config.imgServer+$scope.dream.video;
  649. }
  650. var reg = new RegExp("\n", "g");
  651. $scope.dream.about = $scope.dream.about.replace(reg, "<br/>");
  652. var end_time = new Date($scope.dream.end_time.replace(/-/g, "/"));
  653. var date = new Date();
  654. var inter = (end_time.getTime() - date.getTime()) / 1000;
  655. leftTimer(inter);
  656. $scope.multi.a = $scope.dream.a;
  657. $scope.multi.b = new Date($scope.dream.created_at.replace(/-/g, "/"));
  658. $scope.multi.c = $scope.dream.c;
  659. $scope.multi.promise = $scope.dream.a;
  660. var newtop3user = '' ;
  661. angular.forEach($scope.dream.top3user, function(user) {
  662. newtop3user= newtop3user +user.id+","
  663. });
  664. if(top3user!=''&&newtop3user!=top3user){
  665. //测试动画切换
  666. $timeout(function() {
  667. $scope.sort.slide1 = 'list-grow-animation';
  668. $scope.sort.slide2 = 'slide-in-both-ways';
  669. $scope.sort.slide3 = 'bounce-animation';
  670. }, 50);
  671. }
  672. top3user = newtop3user;
  673. if($scope.dream.top3user[0])$scope.sort.first = $scope.dream.top3user[0].avatar;
  674. if($scope.dream.top3user[1])$scope.sort.second = $scope.dream.top3user[1].avatar;
  675. if($scope.dream.top3user[2])$scope.sort.third = $scope.dream.top3user[2].avatar;
  676. $scope.calcmultiplier();
  677. }, function (error) {
  678. msg.hide();
  679. });
  680. };
  681. $scope.openSupport = function () {
  682. msg.alert("支持乘数说明","支持乘数支持乘数支持乘数支持乘数");
  683. };
  684. $scope.multi = {
  685. a: '',
  686. b: '',
  687. c: '',
  688. result: 1,
  689. promise:null
  690. };
  691. $scope.type = 1;//tab切换
  692. $scope.tosupport = false;
  693. $scope.support = function ($event) {
  694. $event.stopPropagation();
  695. $scope.tosupport = true;
  696. $scope.vm.coin = 0;
  697. $scope.index = 0;
  698. };
  699. $scope.cancelSupport = function () {
  700. $scope.tosupport = false;
  701. $scope.toshare = false;
  702. $scope.input.show = false;
  703. };
  704. $scope.toshare = false;
  705. $scope.toRecharge = function(){
  706. $state.go("app.recharge")
  707. };
  708. $scope.share = function (type,$event) {
  709. $scope.toshare = true;
  710. if (type==0) {//分享给朋友
  711. /* Wechat.share({
  712. text: "分享的文字",
  713. scene: Wechat.Scene.SESSION // share to 好友
  714. }, function () {
  715. alert("Success");
  716. }, function (reason) {
  717. alert("Failed: " + reason);
  718. });*/
  719. Wechat.share({
  720. message: {
  721. title:"瞄瞄",
  722. description:"HELLO,这是我的梦想,快来围观吧!",
  723. thumb:"img/icon_cat_h.png",
  724. media: {
  725. type: Wechat.Type.WEBPAGE,
  726. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  727. }
  728. },
  729. scene: Wechat.Scene.SESSION
  730. }, function () {
  731. alert("Success");
  732. }, function (reason) {
  733. alert("Failed: " + reason);
  734. });
  735. }
  736. if(type==1){
  737. Wechat.share({
  738. message: {
  739. title:"瞄瞄",
  740. description:"HELLO,这是我的梦想,快来围观吧!",
  741. thumb:"img/icon_cat_h.png",
  742. media: {
  743. type: Wechat.Type.WEBPAGE,
  744. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  745. }
  746. },
  747. scene: Wechat.Scene.TIMELINE
  748. }, function () {
  749. alert("Success");
  750. }, function (reason) {
  751. alert("Failed: " + reason);
  752. });
  753. }
  754. // $state.go("app.shareDream",{item:$scope.dream});
  755. };
  756. //实时排行
  757. $scope.sort = {
  758. slide: ''
  759. };
  760. $scope.changeType = function (type) {
  761. $ionicScrollDelegate.scrollTop(true);
  762. $scope.type = type;
  763. };
  764. $scope.index = 0;
  765. $scope.vm = {
  766. coin:"",
  767. title:""
  768. };
  769. $scope.timer = '';
  770. var leftTimer = function (countDown) {
  771. if (isNaN(countDown)) {
  772. $scope.timer = '已结束';
  773. return;
  774. }
  775. var day=parseInt(countDown/(24*60*60));
  776. var h=parseInt(countDown/(60*60)%24);
  777. var m=parseInt(countDown/60%60);
  778. var s=parseInt(countDown%60);
  779. //$scope.timer=(h<10?'0'+h:h)+'时'+(m<10?'0'+m:m)+'分'+(s<10?'0'+s:s)+'秒';
  780. if(day>0) $scope.timer = day+'天';
  781. if(day<0 && h>0) $scope.timer = h+'小时';
  782. if(day<0 && h<0 && m>0) $scope.timer = m+'分钟';
  783. if(day<0 && h<0 && m<0) $scope.timer = '已结束';
  784. /* if($scope.leftTimer)$interval.cancel($scope.leftTimer);
  785. $scope.leftTimer = $interval(function () {
  786. if (countDown >= 1) leftTimer(countDown - 1);
  787. },1000);*/
  788. /*if(countDown<=0){
  789. $scope.timer='结束';
  790. }*/
  791. };
  792. $scope.changeIndex = function (index) {
  793. $scope.index = index;
  794. $scope.vm.coin = index*10;
  795. };
  796. $scope.vidEnded = function () {
  797. alert('播放完毕');
  798. };
  799. //实时计算支持乘数
  800. $scope.calcmultiplier = function () {
  801. $scope.multi.promise = $interval(function () {
  802. var date = new Date();
  803. var inter = date.getTime() - $scope.multi.b.getTime();
  804. var minutes = Math.floor(inter / (60 * 1000));
  805. var number = $scope.multi.a * minutes + $scope.multi.c;//js浮点运算会失真,根据muti.a的可能值范围,比如乘以100再除以100
  806. if (number<=1) {
  807. number = 1;
  808. }
  809. //$scope.multi.result = Math.round(number * 100) / 100;
  810. $scope.multi.result = Math.round(number * 100 / 100);
  811. },1000);
  812. // 点击支持取消 $interval.cancel($scope.multi.promise); 获取数据后重新开始执行
  813. };
  814. $scope.supportDream = function (data) {
  815. if(!$scope.vm.coin){
  816. msg.error("请选择梦想币数量!");
  817. return ;
  818. }
  819. var data = {
  820. id:id,
  821. coin:$scope.vm.coin
  822. };
  823. homeService.supportDream(data).then(function(result){
  824. $scope.tosupport = false;
  825. $scope.load(id);
  826. homeService.myInfo().then(function(result){
  827. $scope.user = result.data.data;
  828. });
  829. $interval.cancel($scope.multi.promise);
  830. msg.text("发送成功");
  831. })
  832. };
  833. $scope.collectionDream = function(is_collection){
  834. homeService.collectionDream(id,is_collection).then(function(result){
  835. $scope.dream.is_collection=result.data.data;
  836. })
  837. };
  838. $scope.add = function(is_collection){
  839. var data = {
  840. id:id,
  841. title:$scope.vm.title,
  842. pics:$scope.imgs,
  843. video:$scope.video.server
  844. };
  845. homeService.add_interaction(data).then(function(){
  846. $scope.load(id);
  847. $scope.closeModal();
  848. })
  849. };
  850. $scope.showAbout = true;
  851. $scope.hideAbout = false;
  852. $scope.showText = function(){
  853. $scope.aboutStyle = {
  854. "white-space" : "normal"
  855. };
  856. $scope.showAbout = false;
  857. $scope.hideAbout = true;
  858. };
  859. $scope.hideText = function(){
  860. $scope.aboutStyle = {
  861. "white-space" : "nowrap"
  862. };
  863. $scope.showAbout = true;
  864. $scope.hideAbout = false;
  865. };
  866. $scope.input = {
  867. placeholder: '评论',
  868. focus: false,
  869. show:false
  870. };
  871. $scope.replay = function ($event, name) {
  872. $event.stopPropagation();
  873. $scope.input.focus = true;
  874. $scope.input.show = true;
  875. $scope.input.placeholder = "评论" + name+":";
  876. $scope.vm.title='';
  877. };
  878. $scope.submitComment = function (index) {
  879. var interaction = $scope.dream.interactions[index];
  880. var iid = interaction.id;
  881. // $scope.dream.interactions[index].comments.push($scope.vm.comment);
  882. $scope.input.focus = true;
  883. if ($scope.vm.comment && $scope.vm.comment == '' || !iid) return;
  884. var data = {
  885. id:iid,
  886. content:$scope.vm.comment
  887. };
  888. console.log($scope.vm.comment+" "+iid);
  889. homeService.add_comment(data).then(function(){
  890. $scope.vm.comment = '' ;
  891. $scope.load(id);
  892. $scope.closeModal();
  893. })
  894. };
  895. $scope.bigImage = false;
  896. $scope.showBigImage = function ($event,imageName) {
  897. $event.stopPropagation();
  898. $scope.url = imageName;
  899. $scope.bigImage = true;
  900. };
  901. $scope.hideBigImage = function(){
  902. $scope.bigImage = false;
  903. };
  904. $ionicModal.fromTemplateUrl('qrCode.html', {
  905. scope: $scope,
  906. animation: 'slide-in-up'
  907. }).then(function(modal) {
  908. $scope.qrCodemodal = modal;
  909. });
  910. $ionicModal.fromTemplateUrl('commentPic.html', {
  911. scope: $scope,
  912. animation: 'slide-in-up'
  913. }).then(function(modal) {
  914. $scope.CommentPicmodal = modal;
  915. });
  916. $scope.openCode = function() {
  917. $scope.qrCodemodal.show();
  918. };
  919. $scope.closeCode = function() {
  920. $scope.qrCodemodal.hide();
  921. };
  922. $ionicModal.fromTemplateUrl('commentPic.html', {
  923. scope: $scope,
  924. animation: 'slide-in-up'
  925. }).then(function(modal) {
  926. $scope.CommentPicmodal = modal;
  927. });
  928. $scope.openCommentPic = function(pic) {
  929. $scope.CommentPicmodal.show();
  930. $scope.commentPicUrl = pic;
  931. };
  932. $scope.closeCommentPic = function() {
  933. $scope.CommentPicmodal.hide();
  934. };
  935. $scope.addpict = function () {
  936. common.chooseImage().then(function (img) {
  937. common.uploadFiles(img,1).then(function (result) {
  938. var response = JSON.parse(result.response);
  939. var file = response.data.file;
  940. $scope.imgs.push(config.imgServer+file);
  941. console.log(JSON.stringify(config.imgServer+file));
  942. }, function (error) {
  943. msg.error('图片上传失败');
  944. });
  945. }, function (error) {
  946. console.log('图片选择失败');
  947. });
  948. };
  949. $scope.deletefile = function (file) {
  950. var index = $scope.imgs.indexOf(file);
  951. $scope.imgs.splice(index, 1);
  952. common.deletefile(file).then(function () {
  953. })
  954. };
  955. $scope.addvideo = function () {
  956. common.chooseVideo().then(function (file) {
  957. common.uploadFiles(file, 2).then(function (result) {
  958. var response = JSON.parse(result.response);
  959. $scope.video.server = response.data.file;
  960. var file = config.imgServer+response.data.file;
  961. console.log("file:"+file);
  962. $scope.video.isOK = true;
  963. $scope.video.file = file;
  964. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  965. console.log("vpic:"+$scope.video.vpic);
  966. }, function (error) {
  967. msg.error('视频上传失败');
  968. });
  969. }, function (erro) {
  970. console.log('选择视频失败');
  971. });
  972. };
  973. $ionicModal.fromTemplateUrl('recharge-modal.html', {
  974. scope: $scope,
  975. animation: 'slide-in-up'
  976. }).then(function(modal) {
  977. $scope.rechagemodal = modal;
  978. });
  979. $scope.openRechargeModal = function() {
  980. $scope.rechagemodal.show();
  981. $scope.vm.money = '';
  982. };
  983. $scope.closeRechargeModal = function() {
  984. $scope.rechagemodal.hide();
  985. };
  986. $ionicModal.fromTemplateUrl('interaction-modal.html', {
  987. scope: $scope,
  988. animation: 'slide-in-up'
  989. }).then(function(modal) {
  990. $scope.modal = modal;
  991. });
  992. $scope.openModal = function() {
  993. $scope.modal.show();
  994. $scope.vm.title = '';
  995. $scope.imgs = [];
  996. $scope.video = {};
  997. };
  998. $scope.closeModal = function() {
  999. $scope.modal.hide();
  1000. };
  1001. //当我们用到模型时,清除它!
  1002. $scope.$on('$destroy', function() {
  1003. $scope.modal.remove();
  1004. });
  1005. $scope.toMessage = function(){
  1006. $state.go("app.my_message");
  1007. }
  1008. }]);
  1009. app.controller('userDetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
  1010. , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $ionicModal, $timeout, $ionicScrollDelegate, $interval) {
  1011. var id = $stateParams.id;
  1012. $scope.items = $stateParams.items;
  1013. $scope.$on('$ionicView.beforeEnter', function () {
  1014. $ionicTabsDelegate.showBar(false);
  1015. });
  1016. $scope.attentionUser = function(is_care){
  1017. homeService.attentionUser(id,is_care).then(function(result){
  1018. $scope.items.is_care=result.data.data;
  1019. })
  1020. };
  1021. $scope.next = function (type) {
  1022. //type:1 前一个,type:2 后一个
  1023. if($scope.items.imgs.length>0){
  1024. if(type==1)
  1025. {
  1026. var temp= $scope.items.imgs.splice(0,1);
  1027. $scope.items.imgs.push(temp[0]);
  1028. }
  1029. if (type==2){
  1030. var temp= $scope.items.imgs.splice($scope.items.imgs.length-1,1);
  1031. $scope.items.imgs.unshift(temp[0]);
  1032. }
  1033. }
  1034. };
  1035. $scope.bigImage = false;
  1036. $scope.showBigImage = function(imageName){
  1037. $scope.url = imageName;
  1038. $scope.bigImage = true;
  1039. };
  1040. $scope.hideBigImage = function(){
  1041. $scope.bigImage = false;
  1042. };
  1043. $scope.cancelSupport = function () {
  1044. $scope.tosupport = false;
  1045. $scope.toshare = false;
  1046. };
  1047. $scope.toshare = false;
  1048. $scope.toshare = false;
  1049. $scope.toRecharge = function(){
  1050. $state.go("app.recharge")
  1051. };
  1052. $scope.share = function (type,$event) {
  1053. $scope.toshare = true;
  1054. if (type==0) {//分享给朋友
  1055. /* Wechat.share({
  1056. text: "分享的文字",
  1057. scene: Wechat.Scene.SESSION // share to 好友
  1058. }, function () {
  1059. alert("Success");
  1060. }, function (reason) {
  1061. alert("Failed: " + reason);
  1062. });*/
  1063. Wechat.share({
  1064. message: {
  1065. title:"瞄瞄",
  1066. description:"HELLO,这是我的个人资料,快来围观吧!",
  1067. thumb:"img/icon_cat_h.png",
  1068. media: {
  1069. type: Wechat.Type.WEBPAGE,
  1070. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  1071. }
  1072. },
  1073. scene: Wechat.Scene.SESSION
  1074. }, function () {
  1075. alert("Success");
  1076. }, function (reason) {
  1077. alert("Failed: " + reason);
  1078. });
  1079. }
  1080. if(type==1){
  1081. Wechat.share({
  1082. message: {
  1083. title:"瞄瞄",
  1084. description:"HELLO,这是我的个人资料,快来围观吧!",
  1085. thumb:"img/icon_cat_h.png",
  1086. media: {
  1087. type: Wechat.Type.WEBPAGE,
  1088. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  1089. }
  1090. },
  1091. scene: Wechat.Scene.TIMELINE
  1092. }, function () {
  1093. alert("Success");
  1094. }, function (reason) {
  1095. alert("Failed: " + reason);
  1096. });
  1097. }
  1098. // $state.go("app.shareDream",{item:$scope.dream});
  1099. };
  1100. $scope.toDetail = function (dream_id) {
  1101. if($scope.items.near_dream==null){
  1102. msg.alert("当前梦想","该用户没有当前梦想");
  1103. }
  1104. if($scope.items.near_dream!=null){
  1105. var dream_id = $scope.items.near_dream.id;
  1106. $state.go('app.home_dreamdetail',{id:dream_id});
  1107. }
  1108. };
  1109. $scope.toOldDream = function(){
  1110. if($scope.items.dreams.length<2){
  1111. msg.alert("曾经的梦想","该用户没有曾经的梦想");
  1112. }
  1113. if($scope.items.dreams.length>1){
  1114. $state.go("app.oldDream",{user_id:$scope.items.user.id});
  1115. }
  1116. };
  1117. $scope.toSupportDream = function(){
  1118. if($scope.items.sup_dreams.length==0){
  1119. msg.alert("支持的梦想","该用户没有支持的梦想");
  1120. }
  1121. if($scope.items.sup_dreams.length!=0){
  1122. $state.go("app.supportDream",{user_id:$scope.items.user.id});
  1123. }
  1124. };
  1125. $scope.collectionDream = function(is_collection){
  1126. homeService.collectionDream(id,is_collection).then(function(result){
  1127. $scope.user.is_collection=result.data.data;
  1128. })
  1129. };
  1130. }]);
  1131. app.controller('homeCollectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  1132. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  1133. $scope.$on('$ionicView.beforeEnter', function () {
  1134. $ionicTabsDelegate.showBar(false);
  1135. myService.collect().then(function(result){
  1136. $scope.dreams = result.data.data.dreams;
  1137. });
  1138. });
  1139. $scope.toDetail = function (id) {
  1140. $state.go('app.home_dreamdetail',{id:id});
  1141. };
  1142. }]);
  1143. app.controller('shareDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1144. , function ($scope,homeService,$stateParams, $state, msg) {
  1145. $scope.dream = $stateParams.item;
  1146. $scope.showAbout = true;
  1147. $scope.hideAbout = false;
  1148. $scope.showText = function(){
  1149. $scope.aboutStyle = {
  1150. "white-space" : "normal"
  1151. };
  1152. $scope.showAbout = false;
  1153. $scope.hideAbout = true;
  1154. };
  1155. $scope.hideText = function(){
  1156. $scope.aboutStyle = {
  1157. "white-space" : "nowrap"
  1158. };
  1159. $scope.showAbout = true;
  1160. $scope.hideAbout = false;
  1161. };
  1162. }]);
  1163. app.controller('homeMessageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  1164. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  1165. $scope.$on('$ionicView.beforeEnter', function () {
  1166. $ionicTabsDelegate.showBar(false);
  1167. myService.messageInfo().then(function(result){
  1168. $scope.infos = result.data.data;
  1169. },function(error){
  1170. });
  1171. });
  1172. $scope.notRead = function(){
  1173. myService.notRead().then(function(result){
  1174. myService.messageInfo().then(function(result){
  1175. $scope.infos = result.data.data;
  1176. },function(error){
  1177. });
  1178. },function(error){
  1179. })
  1180. };
  1181. //系统消息
  1182. $scope.systemInfo = function(){
  1183. $state.go("app.message_sys");
  1184. myService.systemInfo().then(function(result){
  1185. },function(error){
  1186. });
  1187. };
  1188. //回复我的
  1189. $scope.replyMy = function(){
  1190. $state.go("app.message_reply");
  1191. myService.replyMy().then(function(result){
  1192. },function(error){
  1193. });
  1194. };
  1195. $scope.personalLetter = function(){
  1196. $state.go("app.letter");
  1197. }
  1198. }]);
  1199. app.controller('oldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1200. , function ($scope,homeService,$stateParams, $state, msg) {
  1201. var user_id = $stateParams.user_id;
  1202. $scope.$on('$ionicView.beforeEnter',function(){
  1203. $scope.toUserDetail(user_id);
  1204. });
  1205. $scope.toUserDetail = function(user_id){
  1206. homeService.toUserDetail(user_id).then(function(result){
  1207. $scope.items = result.data.data;
  1208. $scope.user = result.data.data.user;
  1209. $scope.dreams = $scope.user.dreams;
  1210. },function(error){
  1211. })
  1212. };
  1213. $scope.toDetail = function(){
  1214. $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
  1215. };
  1216. }]);
  1217. app.controller('supportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  1218. , function ($scope,homeService,$stateParams, $state, msg) {
  1219. var user_id = $stateParams.user_id;
  1220. $scope.$on('$ionicView.beforeEnter',function(){
  1221. $scope.toUserDetail(user_id);
  1222. });
  1223. $scope.toUserDetail = function(user_id){
  1224. homeService.toUserDetail(user_id).then(function(result){
  1225. $scope.items = result.data.data;
  1226. $scope.user = result.data.data.user;
  1227. $scope.dreams = $scope.user.sup_dream;
  1228. },function(error){
  1229. })
  1230. };
  1231. $scope.toDetail = function(){
  1232. $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
  1233. }
  1234. }]);
  1235. app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  1236. , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
  1237. $scope.showMore = function (keyword,index) {
  1238. if(!keyword)return;
  1239. $scope.index = index;
  1240. $scope.search(keyword);
  1241. };
  1242. $scope.search = function (keyword) {
  1243. $scope.vm.keyword = keyword;
  1244. homeService.search(keyword).then(function(result){
  1245. $scope.isResult = true;
  1246. $scope.dream_infos = result.data.data.dream_infos;
  1247. $scope.user_infos = result.data.data.user_infos;
  1248. });
  1249. };
  1250. $scope.toUserDetail = function (id) {
  1251. homeService.toUserDetail(id).then(function(result){
  1252. $scope.items = result.data.data;
  1253. $state.go('app.home_userDetail',{id:id,items:$scope.items});
  1254. },function(error){
  1255. //msg.error(msg.data.error)
  1256. })
  1257. };
  1258. $scope.toDetail = function (id) {
  1259. $state.go('app.home_dreamdetail',{id:id});
  1260. };
  1261. $scope.$on('$ionicView.beforeEnter', function () {
  1262. $scope.isResult = false;
  1263. $scope.index = 0;
  1264. $scope.vm = {
  1265. keyword : ""
  1266. };
  1267. $ionicTabsDelegate.showBar(false);
  1268. // $ionicNavBarDelegate.showBackButton(false);
  1269. homeService.search('').then(function(result){
  1270. $scope.hot_searches = result.data.data.hot_searches;
  1271. $scope.history_searches = result.data.data.history_searches;
  1272. });
  1273. });
  1274. }]);
  1275. app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate"
  1276. , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) {
  1277. }]);
  1278. app.controller('homeDreamsCtrl', ["$scope", "$state", "myService", "msg"
  1279. , function ($scope, $state, myService, msg) {
  1280. $scope.$on('$ionicView.beforeEnter', function () {
  1281. myService.myDream().then(function(result){
  1282. console.log(result.data.data);
  1283. $scope.dreams = result.data.data;
  1284. });
  1285. });
  1286. $scope.toDetail = function (id) {
  1287. $state.go('app.home_dreamdetail',{id:id});
  1288. };
  1289. }]);
  1290. })(angular.module('app.controllers'));