home.js 58 KB

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