home.js 56 KB

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