home.js 57 KB

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