1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108 |
- (function (app) {
- app.controller('homeCtrl', ["$scope", "$ionicTabsDelegate", "$http", 'config', "$state", "msg", "$ionicPopover", "homeService", "$ionicPopup", "$timeout", "$ionicSideMenuDelegate"
- , function ($scope, $ionicTabsDelegate, $http, config, $state, msg, $ionicPopover, homeService, $ionicPopup, $timeout, $ionicSideMenuDelegate) {
- $scope.$on('$ionicView.beforeEnter', function (viewResult) {
- $ionicTabsDelegate.showBar(true);
- });
- $scope.type = 'hot';//tab切换
- $scope.chosedIndex = 0;
- $scope.clickAvatar = function(index){
- $scope.chosedIndex = index;
- };
- $ionicPopover.fromTemplateUrl('my-popover.html', {
- scope: $scope
- }).then(function (popover) {
- $scope.popover = popover;
- });
- $scope.toggleLeftSideMenu = function () {
- $ionicSideMenuDelegate.toggleLeft();
- };
- $scope.doFilter = function () {
- $ionicSideMenuDelegate.toggleRight();
- };
- $scope.openPopover = function ($event) {
- $scope.popover.show($event);
- };
- $scope.closePopover = function () {
- $scope.popover.hide();
- };
- $scope.changetype = function (type) {
- $scope.type = type;
- $scope.load(true);
- };
- $scope.toDetail = function (id) {
- $state.go('app.home_dreamdetail',{id:id});
- };
- $scope.toUserDetail = function (id) {
- homeService.toUserDetail(id).then(function(result){
- $scope.items = result.data.data;
- $state.go('app.home_userDetail',{id:id,items:$scope.items});
- },function(error){
- //msg.error(msg.data.error)
- })
- };
- $scope.changeFilter = function (input) {
- switch (input) {
- case '1':
- if ($scope.filter.sex == 1) {
- $scope.filter.sex = 0;
- } else {
- $scope.filter.sex = 1;
- }
- break;
- case '2':
- if ($scope.filter.sex == 2) {
- $scope.filter.sex = 0;
- } else {
- $scope.filter.sex = 2;
- }
- break;
- case '18-21':
- if ($scope.filter.age == 1) {
- $scope.filter.age = 0;
- } else {
- $scope.filter.age = 1;
- }
- break;
- case '22-25':
- if ($scope.filter.age == 2) {
- $scope.filter.age = 0;
- } else {
- $scope.filter.age = 2;
- }
- break;
- case '26-29':
- if ($scope.filter.age == 3) {
- $scope.filter.age = 0;
- } else {
- $scope.filter.age = 3;
- }
- break;
- case '30-33':
- if ($scope.filter.age == 4) {
- $scope.filter.age = 0;
- } else {
- $scope.filter.age = 4;
- }
- break;
- case '34-37':
- if ($scope.filter.age == 5) {
- $scope.filter.age = 0;
- } else {
- $scope.filter.age = 5;
- }
- break;
- case '>38':
- if ($scope.filter.age == 6) {
- $scope.filter.age = 0;
- } else {
- $scope.filter.age = 6;
- }
- break;
- default:
- }
-
- };
- $scope.filter = {
- hasMore: false,
- pageIndex: 1,
- pageSize: 20,
- sex: 0,//1男,2女,0:全部,
- age: 0,//0:全部,1:18-21,2:22-25,3:26-29,4:30-33,5:34-37,6:>38,
- city:''
- };
- $scope.index = {
- banner: [],
- users: [],
- dreams:[]
- };
- $scope.next = function (type) {
- //type:1 前一个,type:2 后一个
- if($scope.index.users.length>0){
- if(type==1)
- {
- var temp= $scope.index.users.splice(0,1);
- $scope.index.users.push(temp[0]);
- }
- if (type==2){
- var temp= $scope.index.users.splice($scope.index.users.length-1,1);
- $scope.index.users.unshift(temp[0]);
- }
- }
- };
- $scope.load = function (init) {
- if (init) {
- $scope.filter.pageIndex = 1;
- $scope.index.dreams = [];
- }
- msg.loading();
- homeService.index($scope.type, $scope.filter.pageIndex).then(function (result) {
- msg.hide();
- $scope.index.banners = result.data.data.banners;
- $scope.index.users = result.data.data.users;
- $scope.filter.pageIndex++;
- var more = (result.data.data.dreams.data.length >= $scope.filter.pageSize);
- $scope.filter.hasMore = more;
- $scope.index.dreams = $scope.index.dreams.concat(result.data.data.dreams.data);
- if (init) {
- $scope.$broadcast('scroll.refreshComplete');
- } else {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- }, function (error) {
- msg.hide();
- });
- };
- $scope.qrscan = function () {
- cordova.plugins.barcodeScanner.scan(
- function (result) {
- //扫码成功后执行的回调函数
- alert("收到一个二维码\n" +
- "扫码文字结果: " + result.text + "\n" +
- "格式: " + result.format + "\n" +
- "是否在扫码页面取消扫码: " + result.cancelled);
-
- },
- function (error) {
- //扫码失败执行的回调函数
- alert("Scanning failed: " + error);
- }, {
- preferFrontCamera: false, // iOS and Android 设置前置摄像头
- showFlipCameraButton: true, // iOS and Android 显示旋转摄像头按钮
- showTorchButton: true, // iOS and Android 显示打开闪光灯按钮
- torchOn: false, // Android, launch with the torch switched on (if available)打开手电筒
- prompt: "在扫描区域内放置二维码", // Android提示语
- resultDisplayDuration: 500, // Android, display scanned text for X ms.
- //0 suppresses it entirely, default 1500 设置扫码时间的参数
- formats: "QR_CODE", // 二维码格式可设置多种类型
- orientation: "portrait", // Android only (portrait|landscape),
- //default unset so it rotates with the device在安卓上 landscape 是横屏状态
- disableAnimations: true, // iOS 是否禁止动画
- disableSuccessBeep: false // iOS 禁止成功后提示声音 “滴”
- }
- );
- };
- $scope.data = {};
- $scope.load(true);
- $scope.$on('$ionicView.beforeLeave', function () {
- $scope.popover.hide();
- $scope.load(true);
- });
- }]);
- app.controller('dreamDetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams","$ionicBackdrop", "$timeout", "$ionicScrollDelegate", "$interval"
- , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams,$ionicBackdrop, $timeout, $ionicScrollDelegate, $interval) {
- var id = $stateParams.id;
- var top3user = '';
- $scope.chosedIndex = 0;
- $scope.clickAvatar = function(index){
- $scope.chosedIndex = index;
- };
- // id=5;
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- $scope.load(id);
- $scope.thisUser = storage.getObject('user');
- homeService.myInfo().then(function(result){
- $scope.user = result.data.data;
- });
- console.log($scope.user);
- });
- $scope.$on('$ionicView.leave', function () {
- if($scope.multi.promise)$interval.cancel($scope.multi.promise);
- if($scope.leftTimer)$interval.cancel($scope.leftTimer);
- });
- $scope.load = function (id) {
- msg.loading();
- homeService.dreamDetail(id).then(function (result) {
- msg.hide();
- console.log(result);
- $scope.dream = result.data.data;
- $scope.dream.video = config.imgServer+$scope.dream.video;
- $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
- var reg = new RegExp("\n", "g");
- $scope.dream.about = $scope.dream.about.replace(reg, "<br/>");
- var end_time = new Date($scope.dream.end_time.replace(/-/g, "/"));
- var date = new Date();
- var inter = (end_time.getTime() - date.getTime()) / 1000;
- leftTimer(inter);
- $scope.multi.a = $scope.dream.a;
- $scope.multi.b = new Date($scope.dream.created_at.replace(/-/g, "/"));
- $scope.multi.c = $scope.dream.c;
- $scope.multi.promise = $scope.dream.a;
- var newtop3user = '' ;
- angular.forEach($scope.dream.top3user, function(user) {
- newtop3user= newtop3user +user.id+","
- });
- if(top3user!=''&&newtop3user!=top3user){
- //测试动画切换
- $timeout(function() {
- $scope.sort.slide1 = 'list-grow-animation';
- $scope.sort.slide2 = 'slide-in-both-ways';
- $scope.sort.slide3 = 'bounce-animation';
- }, 50);
- }
- top3user = newtop3user;
- if($scope.dream.top3user[0])$scope.sort.first = $scope.dream.top3user[0].avatar;
- if($scope.dream.top3user[1])$scope.sort.second = $scope.dream.top3user[1].avatar;
- if($scope.dream.top3user[2])$scope.sort.third = $scope.dream.top3user[2].avatar;
- $scope.calcmultiplier();
- }, function (error) {
- msg.hide();
- });
- };
- $scope.openSupport = function () {
- msg.alert("支持乘数说明","支持乘数支持乘数支持乘数支持乘数");
- };
- // $ionicModal.fromTemplateUrl('supportExplain.html', {
- // scope: $scope
- // }).then(function(modal) {
- // $scope.supportmodal = modal;
- // });
- // $scope.openSupportmodal = function() {
- // $scope.supportmodal.show();
- // };
- // $scope.closeSupportmodal = function() {
- // $scope.supportmodal.hide();
- // };
- $scope.multi = {
- a: '',
- b: '',
- c: '',
- result: 1,
- promise:null
- };
- $scope.type = 1;//tab切换
- $scope.tosupport = false;
- $scope.support = function ($event) {
- $event.stopPropagation();
- $scope.tosupport = true;
- $scope.vm.coin = 0;
- $scope.index = 0;
- };
- $scope.cancelSupport = function () {
- $scope.tosupport = false;
- $scope.toshare = false;
- $scope.input.show = false;
- };
- $scope.toshare = false;
- $scope.share = function ($event) {
- $event.stopPropagation();
- $scope.toshare = true;
- };
- $scope.toRecharge = function(){
- $state.go("app.recharge")
- };
- $scope.shareDream = function (type) {
- if (type==1) {//微信
- Wechat.share({
- text: "微信分享",
- scene: Wechat.Scene.TIMELINE // share to Timeline
- }, function () {
- alert("Success");
- }, function (reason) {
- alert("Failed: " + reason);
- });
- //Wechat.share({
- // message: {
- // title: "微信分享",
- // description: "This is description.",
- // thumb: "www/img/thumbnail.png",
- // mediaTagName: "TEST-TAG-001",
- // messageExt: "这是第三方带的测试字段",
- // messageAction: "<action>dotalist</action>",
- // media: "YOUR_MEDIA_OBJECT_HERE"
- // },
- // scene: Wechat.Scene.TIMELINE // share to Timeline
- //}, function () {
- // alert("Success");
- //}, function (reason) {
- // alert("Failed: " + reason);
- //});
- //Wechat.share({
- // message: {
- // media: {
- // type: Wechat.Type.WEBPAGE,
- // webpageUrl: "http://tech.qq.com/zt2012/tmtdecode/252.htm"
- // }
- // },
- // scene: Wechat.Scene.TIMELINE // share to Timeline
- //}, function () {
- // alert("Success");
- //}, function (reason) {
- // alert("Failed: " + reason);
- //});
- }
- if (type == 2) {//微博 https://github.com/iVanPan/cordova_weibo/blob/master/README_ZH.md
- var args = {};
- args.text = '微博文字分享';
- WeiboSDK.shareTextToWeibo(function () {
- alert('share success');
- }, function (failReason) {
- alert(failReason);
- }, args);
- }
- // $state.go("app.shareDream",{item:$scope.dream});
- };
- //实时排行
- $scope.sort = {
- slide: ''
- };
- $scope.changeType = function (type) {
- $ionicScrollDelegate.scrollTop(true);
- $scope.type = type;
- };
- $scope.index = 0;
- $scope.vm = {
- coin:"",
- title:""
- };
- $scope.timer = '';
- var leftTimer = function (countDown) {
- if (isNaN(countDown)) {
- $scope.timer = '结束';
- return;
- }
- var day=parseInt(countDown/(24*60*60));
- var h=parseInt(countDown/(60*60)%24);
- var m=parseInt(countDown/60%60);
- var s=parseInt(countDown%60);
- //$scope.timer=(h<10?'0'+h:h)+'时'+(m<10?'0'+m:m)+'分'+(s<10?'0'+s:s)+'秒';
- if(day>0) $scope.timer = day+'天';
- if(day<0 && h>0) $scope.timer = h+'小时';
- if(day<0 && h<0 && m>0) $scope.timer = m+'分钟';
- if(day<0 && h<0 && m<0) $scope.timer = '结束';
-
- /* if($scope.leftTimer)$interval.cancel($scope.leftTimer);
- $scope.leftTimer = $interval(function () {
- if (countDown >= 1) leftTimer(countDown - 1);
- },1000);*/
- /* if(countDown<=0){
- $scope.timer='结束';
- }*/
- };
- $scope.changeIndex = function (index) {
- $scope.index = index;
- $scope.vm.coin = index*10;
- };
- $scope.vidEnded = function () {
- alert('播放完毕');
- };
- //实时计算支持乘数
- $scope.calcmultiplier = function () {
- $scope.multi.promise = $interval(function () {
-
- var date = new Date();
- var inter = date.getTime() - $scope.multi.b.getTime();
- var minutes = Math.floor(inter / (60 * 1000));
- var number = $scope.multi.a * minutes + $scope.multi.c;//js浮点运算会失真,根据muti.a的可能值范围,比如乘以100再除以100
- if (number<=1) {
- number = 1;
- }
- //$scope.multi.result = Math.round(number * 100) / 100;
- $scope.multi.result = Math.round(number * 100 / 100);
- },1000);
- // 点击支持取消 $interval.cancel($scope.multi.promise); 获取数据后重新开始执行
- };
- $scope.supportDream = function (data) {
- if(!$scope.vm.coin){
- msg.error("请选择梦想币数量!");
- return ;
- }
- var data = {
- id:id,
- coin:$scope.vm.coin
- };
- homeService.supportDream(data).then(function(result){
- $scope.tosupport = false;
- $scope.load(id);
- $interval.cancel($scope.multi.promise);
- })
- };
- $scope.collectionDream = function(is_collection){
- homeService.collectionDream(id,is_collection).then(function(result){
- $scope.dream.is_collection=result.data.data;
- })
- };
- $scope.add = function(is_collection){
- var data = {
- id:id,
- title:$scope.vm.title,
- pics:$scope.imgs
- };
- homeService.add_interaction(data).then(function(){
- $scope.load(id);
- $scope.closeModal();
- })
- };
- $scope.showAbout = true;
- $scope.hideAbout = false;
- $scope.showText = function(){
- $scope.aboutStyle = {
- "white-space" : "normal"
- };
- $scope.showAbout = false;
- $scope.hideAbout = true;
- };
- $scope.hideText = function(){
- $scope.aboutStyle = {
- "white-space" : "nowrap"
- };
- $scope.showAbout = true;
- $scope.hideAbout = false;
- };
- $scope.input = {
- placeholder: '评论',
- focus: false,
- show:false
- };
- $scope.replay = function ($event, name) {
-
- $event.stopPropagation();
- $scope.input.focus = true;
- $scope.input.show = true;
- $scope.input.placeholder = "回复" + name;
- $scope.vm.title='';
- };
- $scope.comment = function(){
- // $event.stopPropagation();
- //$scope.input.placeholder = "评论";
- $scope.input.focus = true;
- $scope.vm.title='';
- };
- $scope.submitComment = function(iid){
- if($scope.vm.comment&&$scope.vm.comment==''||!iid)return;
- var data = {
- id:iid,
- content:$scope.vm.comment
- };
- console.log($scope.vm.comment+" "+iid);
- homeService.add_comment(data).then(function(){
- $scope.vm.comment = '' ;
- $scope.load(id);
- $scope.closeModal();
- })
- };
- $scope.bigImage = false;
- $scope.showBigImage = function(imageName){
- $scope.url = imageName;
- $scope.bigImage = true;
- };
- $scope.hideBigImage = function(){
- $scope.bigImage = false;
- };
- $scope.addpict = function () {
- common.chooseImage().then(function (img) {
- common.uploadFiles(img,1).then(function (result) {
- var response = JSON.parse(result.response);
- var file = response.data.file;
- $scope.imgs.push(config.imgServer+file);
- console.log(JSON.stringify(config.imgServer+file));
- }, function (error) {
- msg.error('图片上传失败');
- });
- }, function (error) {
- console.log('图片选择失败');
- });
- };
- $ionicModal.fromTemplateUrl('recharge-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.rechagemodal = modal;
- });
- $scope.openRechargeModal = function() {
- $scope.rechagemodal.show();
- $scope.vm.money = '';
- };
- $scope.closeRechargeModal = function() {
- $scope.rechagemodal.hide();
- };
- $ionicModal.fromTemplateUrl('interaction-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.modal = modal;
- });
- $scope.openModal = function() {
- $scope.modal.show();
- $scope.vm.title = '';
- $scope.imgs = [];
- };
- $scope.closeModal = function() {
- $scope.modal.hide();
- };
- //当我们用到模型时,清除它!
- $scope.$on('$destroy', function() {
- $scope.modal.remove();
- });
- $scope.toMessage = function(){
- $state.go("app.message");
- }
- }]);
- app.controller('myDreamDetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
- , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $ionicModal, $timeout, $ionicScrollDelegate, $interval) {
- var id = $stateParams.id;
- var top3user = '';
- $scope.chosedIndex = 0;
- $scope.clickAvatar = function(index){
- $scope.chosedIndex = index;
- };
- // id=5;
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- $scope.load(id);
- $scope.thisUser = storage.getObject('user');
- homeService.myInfo().then(function(result){
- $scope.user = result.data.data;
- });
- console.log($scope.user);
- });
- $scope.$on('$ionicView.leave', function () {
- if($scope.multi.promise)$interval.cancel($scope.multi.promise);
- if($scope.leftTimer)$interval.cancel($scope.leftTimer);
- });
- $scope.load = function (id) {
- msg.loading();
- homeService.dreamDetail(id).then(function (result) {
- msg.hide();
- console.log(result);
- $scope.dream = result.data.data;
- $scope.dream.video = config.imgServer+$scope.dream.video;
- $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
- var reg = new RegExp("\n", "g");
- $scope.dream.about = $scope.dream.about.replace(reg, "<br/>");
- var end_time = new Date($scope.dream.end_time.replace(/-/g, "/"));
- var date = new Date();
- var inter = (end_time.getTime() - date.getTime()) / 1000;
- leftTimer(inter);
- $scope.multi.a = $scope.dream.a;
- $scope.multi.b = new Date($scope.dream.created_at.replace(/-/g, "/"));
- $scope.multi.c = $scope.dream.c;
- $scope.multi.promise = $scope.dream.a;
- var newtop3user = '' ;
- angular.forEach($scope.dream.top3user, function(user) {
- newtop3user= newtop3user +user.id+","
- });
- if(top3user!=''&&newtop3user!=top3user){
- //测试动画切换
- $timeout(function() {
- $scope.sort.slide1 = 'list-grow-animation';
- $scope.sort.slide2 = 'slide-in-both-ways';
- $scope.sort.slide3 = 'bounce-animation';
- }, 50);
- }
- top3user = newtop3user;
- if($scope.dream.top3user[0])$scope.sort.first = $scope.dream.top3user[0].avatar;
- if($scope.dream.top3user[1])$scope.sort.second = $scope.dream.top3user[1].avatar;
- if($scope.dream.top3user[2])$scope.sort.third = $scope.dream.top3user[2].avatar;
- $scope.calcmultiplier();
- }, function (error) {
- msg.hide();
- });
- };
- $scope.openSupport = function () {
- msg.alert("支持乘数说明","支持乘数支持乘数支持乘数支持乘数");
- };
- // $ionicModal.fromTemplateUrl('supportExplain.html', {
- // scope: $scope
- // }).then(function(modal) {
- // $scope.supportmodal = modal;
- // });
- // $scope.openSupportmodal = function() {
- // $scope.supportmodal.show();
- // };
- // $scope.closeSupportmodal = function() {
- // $scope.supportmodal.hide();
- // };
- $scope.multi = {
- a: '',
- b: '',
- c: '',
- result: 1,
- promise:null
- };
- $scope.type = 1;//tab切换
- $scope.tosupport = false;
- $scope.support = function ($event) {
- $event.stopPropagation();
- $scope.tosupport = true;
- $scope.vm.coin = 0;
- $scope.index = 0;
- };
- $scope.cancelSupport = function () {
- $scope.tosupport = false;
- $scope.toshare = false;
- $scope.input.show = false;
- };
- $scope.toshare = false;
- $scope.share = function ($event) {
- $event.stopPropagation();
- $scope.toshare = true;
- };
- $scope.toRecharge = function(){
- $state.go("app.recharge")
- };
- $scope.shareDream = function(){
- $state.go("app.shareDream",{item:$scope.dream});
- };
- //实时排行
- $scope.sort = {
- slide: ''
- };
- $scope.changeType = function (type) {
- $ionicScrollDelegate.scrollTop(true);
- $scope.type = type;
- };
- $scope.index = 0;
- $scope.vm = {
- coin:"",
- title:""
- };
- $scope.timer = '';
- var leftTimer = function (countDown) {
- if (isNaN(countDown)) {
- $scope.timer = '结束';
- return;
- }
- var day=parseInt(countDown/(24*60*60));
- var h=parseInt(countDown/(60*60)%24);
- var m=parseInt(countDown/60%60);
- var s=parseInt(countDown%60);
- //$scope.timer=(h<10?'0'+h:h)+'时'+(m<10?'0'+m:m)+'分'+(s<10?'0'+s:s)+'秒';
- if(day>0) $scope.timer = day+'天';
- if(day<0 && h>0) $scope.timer = h+'小时';
- if(day<0 && h<0 && m>0) $scope.timer = m+'分钟';
- if(day<0 && h<0 && m<0) $scope.timer = '结束';
- /* if($scope.leftTimer)$interval.cancel($scope.leftTimer);
- $scope.leftTimer = $interval(function () {
- if (countDown >= 1) leftTimer(countDown - 1);
- },1000);*/
- /* if(countDown<=0){
- $scope.timer='结束';
- }*/
- };
- $scope.changeIndex = function (index) {
- $scope.index = index;
- $scope.vm.coin = index*10;
- };
- $scope.vidEnded = function () {
- alert('播放完毕');
- };
- //实时计算支持乘数
- $scope.calcmultiplier = function () {
- $scope.multi.promise = $interval(function () {
- var date = new Date();
- var inter = date.getTime() - $scope.multi.b.getTime();
- var minutes = Math.floor(inter / (60 * 1000));
- var number = $scope.multi.a * minutes + $scope.multi.c;//js浮点运算会失真,根据muti.a的可能值范围,比如乘以100再除以100
- if (number<=1) {
- number = 1;
- }
- //$scope.multi.result = Math.round(number * 100) / 100;
- $scope.multi.result = Math.round(number * 100 / 100);
- },1000);
- // 点击支持取消 $interval.cancel($scope.multi.promise); 获取数据后重新开始执行
- };
- $scope.supportDream = function (data) {
- if(!$scope.vm.coin){
- msg.error("请选择梦想币数量!");
- return ;
- }
- var data = {
- id:id,
- coin:$scope.vm.coin
- };
- homeService.supportDream(data).then(function(result){
- $scope.tosupport = false;
- $scope.load(id);
- $interval.cancel($scope.multi.promise);
- })
- };
- $scope.collectionDream = function(is_collection){
- homeService.collectionDream(id,is_collection).then(function(result){
- $scope.dream.is_collection=result.data.data;
- })
- };
- $scope.add = function(is_collection){
- var data = {
- id:id,
- title:$scope.vm.title,
- pics:$scope.imgs
- };
- homeService.add_interaction(data).then(function(){
- $scope.load(id);
- $scope.closeModal();
- })
- };
- $scope.showAbout = true;
- $scope.hideAbout = false;
- $scope.showText = function(){
- $scope.aboutStyle = {
- "white-space" : "normal"
- };
- $scope.showAbout = false;
- $scope.hideAbout = true;
- };
- $scope.hideText = function(){
- $scope.aboutStyle = {
- "white-space" : "nowrap"
- };
- $scope.showAbout = true;
- $scope.hideAbout = false;
- };
- $scope.input = {
- placeholder: '评论',
- focus: false,
- show:false
- };
- $scope.replay = function ($event, name) {
- $event.stopPropagation();
- $scope.input.focus = true;
- $scope.input.show = true;
- $scope.input.placeholder = "回复" + name;
- $scope.vm.title='';
- };
- $scope.comment = function(){
- // $event.stopPropagation();
- //$scope.input.placeholder = "评论";
- $scope.input.focus = true;
- $scope.vm.title='';
- };
- $scope.submitComment = function(iid){
- if($scope.vm.comment&&$scope.vm.comment==''||!iid)return;
- var data = {
- id:iid,
- content:$scope.vm.comment
- };
- console.log($scope.vm.comment+" "+iid);
- homeService.add_comment(data).then(function(){
- $scope.vm.comment = '' ;
- $scope.load(id);
- $scope.closeModal();
- })
- };
- $scope.bigImage = false;
- $scope.showBigImage = function(imageName){
- $scope.url = imageName;
- $scope.bigImage = true;
- };
- $scope.hideBigImage = function(){
- $scope.bigImage = false;
- };
- $scope.addpict = function () {
- common.chooseImage().then(function (img) {
- common.uploadFiles(img,1).then(function (result) {
- var response = JSON.parse(result.response);
- var file = response.data.file;
- $scope.imgs.push(config.imgServer+file);
- console.log(JSON.stringify(config.imgServer+file));
- }, function (error) {
- msg.error('图片上传失败');
- });
- }, function (error) {
- console.log('图片选择失败');
- });
- };
- $ionicModal.fromTemplateUrl('recharge-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.rechagemodal = modal;
- });
- $scope.openRechargeModal = function() {
- $scope.rechagemodal.show();
- $scope.vm.money = '';
- };
- $scope.closeRechargeModal = function() {
- $scope.rechagemodal.hide();
- };
- $ionicModal.fromTemplateUrl('interaction-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.modal = modal;
- });
- $scope.openModal = function() {
- $scope.modal.show();
- $scope.vm.title = '';
- $scope.imgs = [];
- };
- $scope.closeModal = function() {
- $scope.modal.hide();
- };
- //当我们用到模型时,清除它!
- $scope.$on('$destroy', function() {
- $scope.modal.remove();
- });
- $scope.toMessage = function(){
- $state.go("app.my_message");
- }
- }]);
- app.controller('userDetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
- , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $ionicModal, $timeout, $ionicScrollDelegate, $interval) {
- var id = $stateParams.id;
- $scope.items = $stateParams.items;
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- });
- $scope.attentionUser = function(is_care){
- homeService.attentionUser(id,is_care).then(function(result){
- $scope.items.is_care=result.data.data;
- })
- };
- $scope.next = function (type) {
- //type:1 前一个,type:2 后一个
- if($scope.items.imgs.length>0){
- if(type==1)
- {
- var temp= $scope.items.imgs.splice(0,1);
- $scope.items.imgs.push(temp[0]);
- }
- if (type==2){
- var temp= $scope.items.imgs.splice($scope.items.imgs.length-1,1);
- $scope.items.imgs.unshift(temp[0]);
- }
- }
- };
- $scope.bigImage = false;
- $scope.showBigImage = function(imageName){
- $scope.url = imageName;
- $scope.bigImage = true;
- };
- $scope.hideBigImage = function(){
- $scope.bigImage = false;
- };
- $scope.cancelSupport = function () {
- $scope.tosupport = false;
- $scope.toshare = false;
- };
- $scope.toshare = false;
- $scope.share = function ($event) {
- $event.stopPropagation();
- $scope.toshare = true;
- };
- $scope.shareDream = function(){
- $state.go("app.shareDream",{item:$scope.user});
- };
- $scope.toDetail = function (dream_id) {
- if($scope.items.near_dream==null){
- msg.alert("当前梦想","该用户没有当前梦想");
- }
- if($scope.items.near_dream!=null){
- var dream_id = $scope.items.near_dream.id;
- $state.go('app.home_dreamdetail',{id:dream_id});
- }
- };
- $scope.toOldDream = function(){
- if($scope.items.dreams.length==0){
- msg.alert("曾经的梦想","该用户没有曾经的梦想");
- }
- if($scope.items.dreams.length!=0){
- $state.go("app.oldDream",{user_id:$scope.items.user.id});
- }
- };
- $scope.toSupportDream = function(){
- if($scope.items.sup_dreams.length==0){
- msg.alert("支持的梦想","该用户没有支持的梦想");
- }
- if($scope.items.sup_dreams.length!=0){
- $state.go("app.supportDream",{user_id:$scope.items.user.id});
- }
- };
- $scope.collectionDream = function(is_collection){
- homeService.collectionDream(id,is_collection).then(function(result){
- $scope.user.is_collection=result.data.data;
- })
- };
- }]);
- app.controller('shareDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
- , function ($scope,homeService,$stateParams, $state, msg) {
- $scope.dream = $stateParams.item;
- $scope.showAbout = true;
- $scope.hideAbout = false;
- $scope.showText = function(){
- $scope.aboutStyle = {
- "white-space" : "normal"
- };
- $scope.showAbout = false;
- $scope.hideAbout = true;
- };
- $scope.hideText = function(){
- $scope.aboutStyle = {
- "white-space" : "nowrap"
- };
- $scope.showAbout = true;
- $scope.hideAbout = false;
- };
- }]);
- app.controller('homeMessageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- myService.messageInfo().then(function(result){
- $scope.infos = result.data.data;
- },function(error){
- });
- });
- $scope.notRead = function(){
- $scope.readStyle = {
- "display" : "none"
- };
- };
- //系统消息
- $scope.systemInfo = function(){
- $state.go("app.message_sys");
- myService.systemInfo().then(function(result){
- },function(error){
- });
- };
- //回复我的
- $scope.replyMy = function(){
- $state.go("app.message_reply");
- myService.replyMy().then(function(result){
- },function(error){
- });
- };
- $scope.personalLetter = function(){
- $state.go("app.letter");
- }
- }]);
- app.controller('oldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
- , function ($scope,homeService,$stateParams, $state, msg) {
- var user_id = $stateParams.user_id;
- $scope.$on('$ionicView.beforeEnter',function(){
- $scope.toUserDetail(user_id);
- });
- $scope.toUserDetail = function(user_id){
- homeService.toUserDetail(user_id).then(function(result){
- $scope.items = result.data.data;
- $scope.user = result.data.data.user;
- $scope.dreams = $scope.user.sup_dream;
- },function(error){
- })
- };
- $scope.toDetail = function(){
- $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
- }
- }]);
- app.controller('supportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
- , function ($scope,homeService,$stateParams, $state, msg) {
- var user_id = $stateParams.user_id;
- $scope.$on('$ionicView.beforeEnter',function(){
- $scope.toUserDetail(user_id);
- });
- $scope.toUserDetail = function(user_id){
- homeService.toUserDetail(user_id).then(function(result){
- $scope.items = result.data.data;
- $scope.user = result.data.data.user;
- $scope.dreams = $scope.user.sup_dream;
- },function(error){
- })
- };
- $scope.toDetail = function(){
- $state.go("app.home_userDetail",{user_id:user_id,items:$scope.items})
- }
- }]);
- app.controller('searchCtrl', ["$scope","homeService", "$state", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate"
- , function ($scope,homeService, $state, msg, $ionicTabsDelegate, $ionicNavBarDelegate) {
- $scope.showMore = function (keyword,index) {
- if(!keyword)return;
- $scope.index = index;
- $scope.search(keyword);
- };
- $scope.search = function (keyword) {
- $scope.vm.keyword = keyword;
- homeService.search(keyword).then(function(result){
- $scope.isResult = true;
- $scope.dream_infos = result.data.data.dream_infos;
- $scope.user_infos = result.data.data.user_infos;
- });
- };
- $scope.toUserDetail = function (id) {
- homeService.toUserDetail(id).then(function(result){
- $scope.items = result.data.data;
- $state.go('app.home_userDetail',{id:id,items:$scope.items});
- },function(error){
- //msg.error(msg.data.error)
- })
- };
- $scope.toDetail = function (id) {
- $state.go('app.home_dreamdetail',{id:id});
- };
-
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.isResult = false;
- $scope.index = 0;
- $scope.vm = {
- keyword : ""
- };
- $ionicTabsDelegate.showBar(false);
- // $ionicNavBarDelegate.showBackButton(false);
- homeService.search('').then(function(result){
- $scope.hot_searches = result.data.data.hot_searches;
- $scope.history_searches = result.data.data.history_searches;
- });
- });
- }]);
- app.controller('interactionAddCtrl', ["$scope","homeService", "$state", "msg","config","common", "$ionicTabsDelegate", "$ionicNavBarDelegate"
- , function ($scope,homeService, $state, msg,config,common, $ionicTabsDelegate, $ionicNavBarDelegate) {
- }]);
- app.controller('homeDreamsCtrl', ["$scope", "$state", "myService", "msg"
- , function ($scope, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.myDream().then(function(result){
- console.log(result.data.data);
- $scope.dreams = result.data.data;
- });
- });
- $scope.toDetail = function (id) {
- $state.go('app.home_dreamdetail',{id:id});
- };
- }]);
-
- })(angular.module('app.controllers'));
|