123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- (function (app) {
- app.controller('homeCtrl', ["$scope", "$ionicTabsDelegate", "$http", 'config', "$state", "msg", "$ionicPopover", "homeService", "$ionicPopup", "$timeout", "$ionicSideMenuDelegate", "$rootScope"
- , function ($scope, $ionicTabsDelegate, $http, config, $state, msg, $ionicPopover, homeService, $ionicPopup, $timeout, $ionicSideMenuDelegate, $rootScope) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(true);
- $scope.load(true);
- homeService.messageInfo().then(function(result){
- $scope.infos = result.data.data;
- if($scope.infos.letter.is_read==0 && $scope.infos.reply.is_read==0 && $scope.infos.systemInfo.is_read==0){
- $scope.showMessage=0;
- }
- else {
- $scope.showMessage=1;
- }
- },function(error){
- });
- });
- $rootScope.$on('msg-new', function (event, msg) {
- //收到新消息
- alert('收到新消息,改变样式');
- $scope.showMessage = 1;
- })
- $scope.type = 'hot';//tab切换
- //$scope.chosedIndex = 0;
- $scope.clickAvatar = 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)
- });
- };
- $ionicPopover.fromTemplateUrl('my-popover.html', {
- scope: $scope
- }).then(function (popover) {
- $scope.popover = popover;
- });
- $scope.toggleLeftSideMenu = function () {
- $ionicSideMenuDelegate.toggleLeft();
- };
- $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;
- 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.doFilter = function () {
- homeService.doFilter($scope.filter.sex,$scope.filter.age,$scope.filter.city).then(function(result){
- $scope.index.dreams = result.data.data.dreams.data;
- },function(error){
- msg.error(data.error.message);
- });
- //$ionicSideMenuDelegate.toggleRight();
- };
- $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","$location","$ionicHistory","$timeout", "$state", "WechatService","$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams","$ionicBackdrop", "$timeout", "$ionicScrollDelegate", "$interval"
- , function ($scope,$location, $ionicHistory,$timeout,$state,WechatService,$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;
- homeService.myInfo().then(function (result) {
- $scope.user = result.data.data;
- });
- };
- // id=5;
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- $scope.load(id);
- $scope.thisUser = storage.getObject('user');
- $scope.vm.payType = 2;
- homeService.myInfo().then(function(result){
- $scope.user = result.data.data;
- });
- homeService.messageInfo().then(function(result){
- $scope.infos = result.data.data;
- if($scope.infos.letter.is_read==0 && $scope.infos.reply.is_read==0 && $scope.infos.systemInfo.is_read==0){
- $scope.showMessage=0;
- }
- else {
- $scope.showMessage=1;
- }
- },function(error){
- });
- });
- $scope.$on('$ionicView.leave', function () {
- if($scope.multi.promise)$interval.cancel($scope.multi.promise);
- if($scope.leftTimer)$interval.cancel($scope.leftTimer);
- });
- $scope.toSort = function(){
- //$scope.type = 3;
- $scope.changeType(3)
- };
- $scope.load = function (id) {
- msg.loading();
- homeService.dreamDetail(id).then(function (result) {
- msg.hide();
- console.log(result);
- $scope.showCode = function(codeName){
- $scope.url = codeName;
- $scope.code = true;
- };
- $scope.hideCode = function(){
- $scope.code = false;
- };
- $scope.dream = result.data.data;
- if($scope.timer=='已结束'|| 100*$scope.dream.get_coin/$scope.dream.coin>=100){
- $scope.codeBtn = true;
- }
- if($scope.dream.video){
- $scope.dream.vpic = config.server+'upload/vpic/'+$scope.dream.video+'.jpg';
- $scope.dream.video = config.imgServer+$scope.dream.video;
- }
- 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("支持乘数说明","支持乘数支持乘数支持乘数支持乘数");
- };
- $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.toRecharge = function(){
- $state.go("app.recharge")
- };
- $scope.share = function (type,$event) {
- $scope.toshare = true;
- if (type==0) {//分享给朋友
- /* Wechat.share({
- text: "分享的文字",
- scene: Wechat.Scene.SESSION // share to 好友
- }, function () {
- alert("Success");
- }, function (reason) {
- alert("Failed: " + reason);
- });*/
- Wechat.share({
- message: {
- /*title:"瞄瞄",
- description:"HELLO,这是我的梦想,快来围观吧!",
- thumb:"img/icon_cat_h.png",*/
- title: $scope.dream.name,
- description: $scope.dream.about,
- thumb: "http://q8.9026.com/attachment//base/img/share/icon_cat_h.png",
- media: {
- type: Wechat.Type.WEBPAGE,
- webpageUrl: "q8.9026.com//admin/share/view?id=" + id
- }
- },
- scene: Wechat.Scene.SESSION
- }, function () {
- alert("Success");
- }, function (reason) {
- alert("Failed: " + reason);
- });
- }
- if(type==1){
- Wechat.share({
- message: {
- /*title:"瞄瞄",
- description:"HELLO,这是我的梦想,快来围观吧!",
- thumb:"img/icon_cat_h.png",*/
- title: $scope.dream.name,
- description: $scope.dream.about,
- thumb: "http://q8.9026.com/attachment//base/img/share/icon_cat_h.png",
- media: {
- type: Wechat.Type.WEBPAGE,
- webpageUrl: "q8.9026.com//admin/share/view?id=" + id
- }
- },
- scene: Wechat.Scene.TIMELINE
- }, function () {
- alert("Success");
- }, function (reason) {
- alert("Failed: " + reason);
- });
- }
- // $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);
- homeService.myInfo().then(function(result){
- $scope.user = result.data.data;
- });
- $interval.cancel($scope.multi.promise);
- msg.text("发送成功");
- })
- };
- $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,
- video:$scope.video.server
- };
- 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.showmore = function (index) {
- if ($scope.dream.interactions[index].showmore) {
- $scope.dream.interactions[index].showmore = false;
- } else {
- $scope.dream.interactions[index].showmore = true;
- }
- }
- $scope.replay = function ($event, name, index) {
- $event.stopPropagation();
- $scope.input.focus = true;
- $scope.input.show = true;
- angular.forEach($scope.dream.interactions, function (item) {
- item.show = false;
- })
- $scope.dream.interactions[index].show = true;
- $scope.input.placeholder = "评论" + name+":";
- $scope.vm.title='';
- }
- $scope.replayOther = function ($event, name, index,currentindex) {
- $event.stopPropagation();
- if($scope.dream.interactions[index].comments[currentindex].user_id!=$scope.user.id){
- $scope.input.focus = true;
- $scope.input.show = true;
- angular.forEach($scope.dream.interactions, function (item) {
- item.show = false;
- })
- $scope.dream.interactions[index].show = true;
- $scope.input.placeholder = "评论" + name+":";
- $scope.vm.title='';
- }
- else {
- msg.confirm("评论","是否删除评论").then(function(result){
- if(result==true)
- {
- homeService.deleteComment($scope.dream.interactions[index].comments[currentindex].id).then(function(result){
- msg.text("删除成功");
- $scope.load(id);
- },function(error){
- msg.error(error.data.message);
- })
- }
- });
- }
- };
- $scope.testcharge = function(number){
- if (!number) {
- msg.text('请输入充值金额');
- return;
- }
- homeService.testcharge(number,2).then(function (result) {
- msg.text("充值成功");
- $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
- $timeout(function () {
- $scope.closeRechargeModal();
- }, 500);
- homeService.myInfo().then(function (result) {
- $scope.user = result.data.data;
- });
- })
- }
- //充值
- $scope.charge = function(number){
- if (!number) {
- msg.text('请输入充值金额');
- return;
- }
- homeService.charge(number,2).then(function (result) {
- //todo:result需要返回支付宝或者微信的签名信息
- console.log("result: " + JSON.stringify(result));
- var payInfo = result.data;
- if ($scope.vm.payType == 1) { //支付宝
- cordova.plugins.AliPay.pay(payInfo, function success(e) {
- //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
- //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
- //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
- //当e.resultStatus为9000时,请去服务端验证支付结果
- $scope.clicksub = false;
- if (e.resultStatus == '9000') {
- alert(orderID);
- //支付成功
- // $state.go('app.my');
- } else {
- msg.error("支付失败");
- // msg.error("支付失败:" + JSON.stringify(e));
- }
- }, function error(e) {
- $scope.clicksub = false;
- // msg.error("支付失败:" + JSON.stringify(e));
- msg.error("支付失败");
- });
- }
- if ($scope.vm.payType == 2) { //微信
- var obj = JSON.parse(payInfo);
- var params = {
- partnerid: obj.partnerid, // merchant id
- prepayid: obj.prepayid, // prepay id
- noncestr: obj.noncestr, // nonce
- timestamp: obj.timestamp, // timestamp
- sign: obj.sign, // signed string
- };
- Wechat.sendPaymentRequest(params, function (r) {
- $scope.clicksub = false;
- courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
- // alert(result);
- //支付成功
- // $state.go('app.my');
- }, function (erro) {
- msg.alert("支付反馈失败:" + JSON.stringify(erro));
- });
- }, function (reason) {
- $scope.clicksub = false;
- msg.alert("支付失败:" + JSON.stringify(reason));
- });
- }
- // msg.text("充值成功");
- // $state.go('app.my');
- });
- }
- $scope.submitComment = function (index) {
- var interaction = $scope.dream.interactions[index];
- var iid = interaction.id;
- // $scope.dream.interactions[index].comments.push($scope.vm.comment);
- $scope.input.focus = true;
- 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 ($event, imageName) {
- $event.stopPropagation();
- $scope.url = imageName;
- $scope.bigImage = true;
- };
- $scope.hideBigImage = function(){
- $scope.bigImage = false;
- };
- $ionicModal.fromTemplateUrl('qrCode.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.qrCodemodal = modal;
- });
- $scope.openCode = function() {
- $scope.qrCodemodal.show();
- $scope.vm.money = '';
- };
- $scope.closeCode = function() {
- $scope.qrCodemodal.hide();
- };
- $ionicModal.fromTemplateUrl('commentPic.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.CommentPicmodal = modal;
- });
- $scope.openCommentPic = function(pic) {
- $scope.CommentPicmodal.show();
- $scope.commentPicUrl = pic;
- };
- $scope.closeCommentPic = function() {
- $scope.CommentPicmodal.hide();
- };
- $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('图片选择失败');
- });
- };
- $scope.deletefile = function (file) {
- var index = $scope.imgs.indexOf(file);
- $scope.imgs.splice(index, 1);
- common.deletefile(file).then(function () {
- })
- };
- $scope.addvideo = function () {
- common.chooseVideo().then(function (file) {
- common.uploadFiles(file, 2).then(function (result) {
- var response = JSON.parse(result.response);
- $scope.video.server = response.data.file;
- var file = config.imgServer+response.data.file;
- console.log("file:"+file);
- $scope.video.isOK = true;
- $scope.video.file = file;
- $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
- console.log("vpic:"+$scope.video.vpic);
- }, function (error) {
- msg.error('视频上传失败');
- });
- }, function (erro) {
- 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.video = {};
- };
- $scope.closeModal = function() {
- $scope.modal.hide();
- };
- //当我们用到模型时,清除它!
- $scope.$on('$destroy', function() {
- $scope.modal.remove();
- });
- $scope.toMessage = function(){
- //var dreamdetailUrl = $location.path();
- if($location.path()=="/app/home/dreamdetail"){
- $state.go("app.message");
- }
- else {
- $state.go("app.my_message");
- }
- }
- }]);
- app.controller('userDetailCtrl', ["$scope","$location", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
- , function ($scope,$location, $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.toshare = false;
- $scope.toRecharge = function(){
- $state.go("app.recharge")
- };
- $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;
- if($location.path()=="/app/home/userDetail"){
- $state.go('app.home_dreamdetail',{id:dream_id});
- }
- else {
- $state.go('app.my_dreamdetail',{id:dream_id});
- }
- }
- };
- $scope.toOldDream = function(){
- if($scope.items.dreams.length<2){
- msg.alert("曾经的梦想","该用户没有曾经的梦想");
- }
- if($scope.items.dreams.length>1){
- if($location.path()=="/app/home/userDetail"){
- $state.go('app.oldDream',{user_id:$scope.items.user.id});
- }
- else {
- $state.go('app.myOldDream',{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){
- if($scope.items.dreams.length>1){
- if($location.path()=="/app/home/userDetail"){
- $state.go('app.supportDream',{user_id:$scope.items.user.id});
- }
- else {
- $state.go('app.mySupportDream',{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('homeCollectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
- , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- myService.collect().then(function(result){
- $scope.dreams = result.data.data.dreams;
- });
- });
- $scope.toDetail = function (id) {
- $state.go('app.home_dreamdetail',{id:id});
- };
- }]);
- 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(){
- myService.notRead().then(function(result){
- myService.messageInfo().then(function(result){
- $scope.infos = result.data.data;
- },function(error){
- });
- },function(error){
- })
- };
- //系统消息
- $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.dreams;
- },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'));
|