home.js 56 KB

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