1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 |
- (function (app) {
- app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common", "config", "msg"
- , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common, config, msg) {
- $scope.$on('$ionicView.beforeEnter', function (viewResult) {
- $ionicTabsDelegate.showBar(true);
- myService.myInfo().then(function(result){
- $scope.user = result.data.data
- });
- });
- $scope.setAvator = function () {
- common.setAvator().then(function (result) {
- var response = JSON.parse(result.response);
- console.log(response.data.file);
- $scope.user.avatar = config.imgServer + response.data.file;
- });
- };
- }]);
- app.controller('profileCtrl', ["$scope","$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "config", "common"
- , function ($scope, $ionicTabsDelegate, $state, $filter, storage, myService, msg, config, common) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- msg.loading();
- myService.myInfo().then(function(result){
- $scope.vm = result.data.data;
- console.log($scope.vm.avatar);
- $scope.vm.sex = $scope.vm.sex+'';
- $scope.vm.emotion = $scope.vm.emotion+'';
- if($scope.vm.birthday){
- var arr1 = $scope.vm.birthday.split("-");
- $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]);
- }
- msg.hide();
- },function(error){
- msg.hide();
- // msg.error(error.data.message);
- })
- });
- $scope.setAvator = function () {
- common.setAvator().then(function (result) {
- var response = JSON.parse(result.response);
- $scope.vm.avatar = config.imgServer + response.data.file;
- });
- };
-
- //保存个人信息
- $scope.vm={
- pic:"",
- sex:"",
- signture:"",
- emotion:"",
- job:"",
- tall:"",
- nickname:"",
- birthday1:""
- };
-
- $scope.saveMaterial = function(){
- var data = {
- sex:$scope.vm.sex,
- signture:$scope.vm.signture,
- emotion:$scope.vm.emotion,
- work:$scope.vm.work,
- height:$scope.vm.height,
- city:$scope.vm.city,
- nickname:$scope.vm.nickname,
- birthday:$scope.vm.birthday1
- };
- if($scope.vm.birthday1){
- data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
- }
- if($scope.vm.avatar){
- data.pic = $scope.vm.avatar;
- }
- //msg.loading('提交中...');
- msg.loading();
-
- myService.saveMaterial(data).then(function(result){
- msg.hide();
- msg.success("保存成功!");
- $state.go('app.my');
- myService.myInfo();
- },function(error){
- msg.hide();
- msg.error(error.data.message);
- })
- }
- }]);
- app.controller('settingCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- });
- //退出登陆
- $scope.logout = function(){
- storage.remove("token");
- storage.remove("user");
- $state.go("login");
- }
- }]);
- app.controller('aboutMiaoCtrl', ["$scope","$ionicTabsDelegate","$timeout", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate,$timeout, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.aboutMiao();
- });
- $scope.aboutMiao = function(){
- myService.aboutMiao().then(function(result){
- $scope.items = result.data.data;
- },function(error){
- msg.error(error.data.message)
- })
- };
- }]);
- app.controller('withdrawCtrl', ["$scope","$ionicTabsDelegate","$ionicHistory","$timeout", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $ionicHistory,$timeout,$state,myService, msg, storage) {
- $scope.vm={
- pay:"",
- cash:""
- };
- $scope.$on("$ionicView.enter",function(){
- myService.showAccount().then(function(result){
- $scope.accountId = result.data.data;
- var items = result.data.data;
- //if(items.length==0){
- // msg.text("请先添加账户");
- // $state.go("app.my_account_add");
- // return
- //}
- $scope.pays=[];
- angular.forEach(items,function(item){
- if(item.bank_name!=null) {
- var value=item.bank_name+"(";
- var len=item.bank_number.length;
- var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
- var txt2=item.bank_number.substr(len-4,4);
- value=value+txt1+txt2+")";
- }
- else {
- value=item.type;
- }
- $scope.pays.push({id:item.id,value:value});
- });
- $scope.vm.pay = $scope.pays[0]
- },function(error){
- msg.error(error.data.message)
- })
- });
- $scope.withdraw = function(){
- var data = {
- data:{
- bank_id:$scope.vm.pay.id,
- cash:$scope.vm.cash
- }
- };
- myService.withdraw(data).then(function(result){
- msg.text("提现申请已提交");
- $timeout(function () {
- $ionicHistory.goBack();
- },1000);
- },function(error){
- })
- }
- }]);
- app.controller('payoutCtrl', ["$scope","$ionicTabsDelegate","$timeout","$ionicHistory", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $timeout, $ionicHistory,$state,myService, msg, storage) {
- $scope.vm={
- pay:"",
- cash:""
- };
- $scope.$on("$ionicView.enter",function(){
- myService.showAccount().then(function(result){
- $scope.accountId = result.data.data;
- var items = result.data.data;
- $scope.pays=[];
- angular.forEach(items,function(item){
- if(item.bank_name!=null) {
- var value=item.bank_name+"(";
- var len=item.bank_number.length;
- var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
- var txt2=item.bank_number.substr(len-4,4);
- value=value+txt1+txt2+")";
- }
- else {
- value=item.type;
- }
- $scope.pays.push({id:item.id,value:value});
- })
- },function(error){
- msg.error(error.data.message)
- })
- });
- $scope.withdraw = function(){
- var data = {
- data:{
- bank_id:$scope.vm.pay.id,
- cash:$scope.vm.cash
- }
- };
- myService.withdraw(data).then(function(result){
- msg.text("提现申请已提交");
- $timeout(function () {
- $ionicHistory.goBack();
- },1000);
- },function(error){
- })
- }
- }]);
- app.controller('payExplainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.payExplain();
- });
- $scope.payExplain = function(){
- myService.payExplain().then(function(result){
- $scope.items = result.data.data;
- },function(error){
- msg.error(error.data.message)
- })
- };
- }]);
- app.controller('paySuccessCtrl', ["$scope","$stateParams","$ionicTabsDelegate","$ionicHistory", "$state", "myService", "msg","storage"
- , function ($scope,$stateParams,$ionicTabsDelegate,$ionicHistory, $state,myService, msg, storage) {
- var item = $stateParams.item;
- alert(item.out_trade_no);
- $scope.goBack = function(){
- $ionicHistory.goBack();
- }
- }]);
- app.controller('contactCtrl', ["$scope","$ionicTabsDelegate", "$timeout","$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $timeout,$state,myService, msg, storage) {
- $scope.vm={
- content:"",
- email:""
- };
- $scope.contact = function(){
- var data={
- data:{
- content:$scope.vm.content,
- email:$scope.vm.email
- }
- };
- myService.contact(data).then(function(result){
- msg.text("发送成功");
- $timeout(function(){
- $state.go("app.my");
- },1000);
- },function(error){
- msg.error(error.data.message);
- })
- }
- }]);
- app.controller('attentionCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.attention().then(function(result){
- $scope.users = result.data.data;
- },function(error){
- })
- });
- $scope.toMyUserDetail = function (id) {
- myService.toMyUserDetail(id).then(function(result){
- $scope.items = result.data.data;
- $state.go('app.attention_Detail',{id:id,items:$scope.items});
- },function(error){
- //msg.error(msg.data.error)
- })
- };
- }]);
- app.controller('careCtrl', ["$scope","$ionicTabsDelegate",'$ionicModal',"$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate,$ionicModal, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.careMe().then(function(result){
- $scope.users = result.data.data;
- },function(error){
- })
- });
- $scope.toMyUserDetail = function (id) {
- myService.toMyUserDetail(id).then(function(result){
- $scope.items = result.data.data;
- $state.go('app.attention_Detail',{id:id,items:$scope.items});
- },function(error){
- //msg.error(msg.data.error)
- })
- };
- $ionicModal.fromTemplateUrl('my-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function (modal) {
- $scope.modal = modal;
- });
- //发私信
- $scope.vm={
- content:"",
- comment_id:""
- };
- $scope.closeModal = function () {
- var data = {
- content: $scope.vm.content,
- to_user_id: $scope.item.id
- };
- myService.sendLetter(data).then(function (result) {
- msg.success('回复成功');
- $scope.vm.content = '';
- $scope.item = null;
- $scope.modal.hide();
- }, function (error) {
- msg.error('回复失败');
- });
- };
- $scope.hideModal = function(){
- $scope.modal.hide();
- };
- $scope.reply = function (user) {
- event.stopPropagation();
- $scope.item = user;
- $scope.modal.show();
- }
- }]);
- app.controller('mySupportDreamCtrl', ["$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(id){
- $state.go('app.my_dreamdetail',{id:id});
- // $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
- }
- }]);
- app.controller('myOldDreamCtrl', ["$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(id){
- $state.go('app.my_dreamdetail',{id:id});
- // $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
- };
- }]);
- app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", '$location',"$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate,$location, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.loaddata(true);
- });
- $scope.loaddata = function(init){
- myService.letter().then(function(result){
- $scope.items = result.data.data;
- if (init) {
- $scope.$broadcast('scroll.refreshComplete');
- } else {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- },function(error){
- });
- }
- $scope.toLetter = function(id){
- if($location.path()=="/app/home/message/letter"){
- console.log($location.path());
- $state.go('app.letterDetail')
- }
- else {
- $state.go('app.myLetterDetail')
- }
- }
- }]);
- app.controller('letterDetailCtrl', ["$scope","$ionicTabsDelegate",'$stateParams',"$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate,$stateParams, $state,myService, msg, storage) {
- var id = $stateParams.id;
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.letter().then(function(result){
- $scope.items = result.data.data;
- },function(error){
- });
- });
- }]);
- app.controller('rechargeCtrl', ["$scope","$ionicModal","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService","userService", "msg"
- , function ($scope,$ionicModal,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService,userService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.showWithdraw = true;
- $ionicTabsDelegate.showBar(false);
- $scope.vm = {
-
- }
- myService.myInfo().then(function(result){
- $scope.vm = result.data.data;
- $scope.vm.number = '';
- $scope.vm.payType = 2;
- });
- userService.isTest().then(function(res){
- if(res.data.data){
- $scope.showWithdraw = true;
- }
- else{
- $scope.showWithdraw = false;
- }
- })
- if($scope.ios.isIOS){
- var productIds = ['apple100000','apple100001','apple100002','apple100003','apple100004']; // <- Add your product Ids here
- msg.loading();
- inAppPurchase
- .getProducts(productIds)
- .then(function (products) {
- msg.hide();
- $scope.products = products;
- console.log('products:'+JSON.stringify(products));
- })
- .catch(function (err) {
- msg.hide();
- console.log(err);
- });
- }
- });
- $scope.payExplain = function(){
- $state.go("app.payExplain")
- };
- $scope.withdraw = function(){
- $state.go("app.withdraw")
- };
- $scope.testcharge = function(number){
- if (!number) {
- msg.text('请输入充值金额');
- return;
- }
- myService.testcharge(number,2).then(function (result) {
- msg.text("充值成功");
- $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
- // $timeout(function(){
- // $ionicHistory.goBack();
- // },500)
- });
- };
- $ionicModal.fromTemplateUrl('paysuccess-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function(modal) {
- $scope.modal = modal;
- });
- $scope.openModal = function() {
- $scope.modal.show();
- };
- $scope.closeModal = function() {
- $scope.modal.hide();
- };
- //当我们用到模型时,清除它!
- $scope.$on('$destroy', function() {
- $scope.modal.remove();
- });
-
- $scope.ios={
- isIOS:ionic.Platform.isIOS(),
- productid:''
- }
-
- //充值
- $scope.charge = function(number){
- if($scope.ios.isIOS){
- if (number<2){
- msg.text('请选择充值金额');
- return;
- }
- console.log('购买productid:'+number);
- msg.loading();
- inAppPurchase
- .buy(number)
- .then(function (data) {
- msg.hide();
- console.log('购买then:'+JSON.stringify(data));
- return inAppPurchase.consume(data.productType, data.receipt, data.signature);
- })
- .then(function (data) {
- msg.hide();
- myService.orderIos(number).then(function (result) {
- console.log('服务器端购买成功:'+number);
- }, function (erro) {
- });
- console.log('购买成功:'+number);
- msg.success('购买成功');
- $ionicHistory.goBack();
- })
- .catch(function (err) {
- msg.hide();
- console.log('购买失败:'+JSON.stringify(err));
- // alert('购买失败:'+JSON.stringify(err));
- });
- }else{
- if (!number) {
- msg.text('请输入充值金额');
- return;
- }
- myService.charge(number,2).then(function (result) {
- //todo:result需要返回支付宝或者微信的签名信息
- console.log("result: " + JSON.stringify(result));
- var payInfo = result.data.data;
- var orderID = payInfo.transaction_id
- $scope.vm.transaction_id = payInfo.transaction_id;
- $scope.vm.price = payInfo.price;
- 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 obj = payInfo.orderString;
- // console.log("obj: " + JSON.stringify(obj));
- 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
- };
- // console.log("result: " + JSON.stringify(params));
- Wechat.sendPaymentRequest(params, function (r) {
- $scope.clicksub = false;
- // $state.go("app.paySuccess")
- // $state.go('app.paySuccess',{item:payInfo})
- $scope.openModal();
- // alert(orderID);
- myService.orderStatus(orderID).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');
- });
- }
- }
- }]);
-
- app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- $scope.showAccount();
- });
- $scope.showAccount = function(){
- myService.showAccount().then(function(result){
- $scope.items = result.data.data;
- },function(error){
- msg.error(error.data.message);
- })
- };
- $scope.destroyAccount = function(id){
- myService.destroyAccount(id).then(function(result){
- msg.text("删除成功");
- $scope.showAccount();
- },function(error){
- msg.error(error.data.message);
- })
- }
- }]);
- app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
- , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
- $scope.addpict = function () {
- common.chooseImage().then(function (qrcode) {
- common.uploadFiles(qrcode,1).then(function (result) {
- var response = JSON.parse(result.response);
- var file = config.imgServer+response.data.file;
- $scope.vm.file = file;
- $scope.qrcode.push(file);
- }, function (error) {
- msg.error('图片上传失败');
- });
- }, function (error) {
- console.log('图片选择失败');
- });
- };
- $scope.qrcode=[];
- $scope.deletefile = function (file) {
- var index = $scope.qrcode.indexOf(file);
- $scope.qrcode.splice(index, 1);
- common.deletefile(file).then(function () {
- })
- };
- $scope.vm={
- bank_name:'',
- bank_number:'',
- bank_phone:'',
- bank_user:'',
- type:""
- };
- $scope.addAccount = function () {
- var data = {
- data:{
- bank_name:$scope.vm.bank_name,
- bank_number:$scope.vm.bank_number,
- bank_phone:$scope.vm.bank_phone,
- bank_user:$scope.vm.bank_user
- }
- };
- //msg.loading('保存中...');
- msg.loading();
- myService.addAccount(data).then(function (result) {
- msg.hide();
- $state.go('app.my_account');
- }, function (error) {
- msg.hide();
- msg.error(error.data.message);
- });
- };
- $scope.addQrcode = function(){
- var data = {
- data:{
- type:$scope.vm.type,
- qrcode:$scope.vm.file
- //qrcode:"https://www.baidu.com/img/bd_logo1.png"
- }
- };
- myService.addQrcode(data).then(function(result){
- msg.text("添加成功",true);
- $state.go("app.my_account");
- },function(error){
- msg.error(error.data.message);
- })
- }
- }]);
- app.controller('messageCtrl', ["$scope", "$location","$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope,$location,$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(){
- if($location.path()=='/app/my/message'){
- $state.go("app.my_message_sys");
- }
- else {
- $state.go("app.message_sys");
- }
- };
- //支持消息
- $scope.replyMy = function(){
- if($location.path()=='/app/my/message'){
- $state.go("app.my_message_reply");
- }
- else {
- $state.go("app.message_reply");
- }
- };
- //通知
- $scope.personalLetter = function(){
- if($location.path()=='/app/my/message'){
- $state.go("app.personalLetter");
- }
- else {
- $state.go("app.letter");
- }
- };
- }]);
- app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- $scope.load(true);
- myService.myInfo().then(function(result){
- $scope.user = result.data.data
- });
- });
- $scope.filter = {
- hasMore: false,
- pageIndex: 1,
- pageSize: 25
- };
- $scope.load = function (init) {
- if (init) {
- $scope.filter.pageIndex = 1;
- $scope.dreams = [];
- }
- msg.loading();
- myService.myDream($scope.filter.pageIndex).then(function(result){
- msg.hide();
- $scope.filter.pageIndex++;
- var more = (result.data.data.data.length >= $scope.filter.pageSize);
- $scope.filter.hasMore = more;
- $scope.dreams = $scope.dreams.concat(result.data.data.data);
- if (init) {
- $scope.$broadcast('scroll.refreshComplete');
- } else {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- },function(error){
- msg.hide();
- });
- };
- $scope.toDetail = function (id) {
- $state.go('app.my_dreamdetail',{id:id});
- };
- $scope.time = function(){
- }
- }]);
- app.controller('collectCtrl', ["$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.my_dreamdetail',{id:id});
- };
- }]);
- app.controller('messageSysCtrl', ["$scope","common","config","$ionicPopup","$location", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope,common,config,$ionicPopup,$location,$ionicTabsDelegate, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.loaddata(true);
- });
- $scope.vm = {
- content:""
- };
- $scope.imgs = [];
- $scope.video = {};
- $scope.loaddata = function(init){
- myService.systemInfo().then(function(result){
- $scope.sysInfos = result.data.data;
- if (init) {
- $scope.$broadcast('scroll.refreshComplete');
- } else {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- },function(error){
- });
- }
- $scope.addpict = function () {
- common.chooseImage().then(function (img) {
- common.uploadFiles(img,1).then(function (result) {
- var response = JSON.parse(result.response);
- var file = config.imgServer + response.data.file;
- $scope.imgs.push(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) {
- msg.loading();
- common.uploadFiles(file, 2).then(function (result) {
- msg.hide();
- var response = JSON.parse(result.response);
- //var file = config.imgServer+response.data.file;
- //$scope.video.file = response.data.file;
- $scope.video.isOK = true;
- $scope.video.file = file;
- $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
- }, function (error) {
- //msg.error('视频上传失败');
- msg.hide();
- msg.error(JSON.stringify(error));
- });
- }, function (erro) {
- console.log('选择视频失败');
- });
- };
- $scope.deletevideo = function (file) {
- $scope.video = {};
- common.deletefile(file).then(function (res) {
- },function(erro){
- //alert(JSON.stringify(erro));
- })
- };
- $scope.goMes = function(is_reply,is_url,dream_id,is_end,message,user_id,info,attr_id){
- //发送私信
- if(is_reply==1){
- $scope.vm.content='';
- $scope.imgs=[];
- $scope.video = {};
- var myPopup = $ionicPopup.show({
- template : '<div>' +
- '<textarea autofocus style="border: 1px solid #D0D0D0" name="" id="" cols="30" rows="8" ng-model="vm.content" placeholder="对他的好意给予感谢的回复"></textarea onf>' +
- '<a ng-if="!video.isOK&&imgs.length==0" class="btn-file-up" ng-click="addpict()">' +
- '<img src="img/icon_photo.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
- '<em style="font-size: 16px">添加图片</em>' +
- '</a>' +
- '<a ng-if="imgs.length==0&&!video.isOK" class="btn-file-up" ng-click="addvideo()">' +
- '<img src="img/icon_video.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
- '<em style="font-size: 16px">添加视频</em>' +
- '</a>' +
- '<a ng-repeat="item in imgs" ng-click="showImages(item)" class="img-file-up">' +
- '<b style="background-image:url({{item}});"><em ng-click="deletefile(item)" class="ion-ios-close-outline"></em></b>' +
- '</a>' +
- '<div class="img-file-up" ng-if="video.isOK">' +
- '<div style="position:relative;">' +
- '<em ng-click="deletevideo(video.file)" class="ion-ios-close-outline"></em>' +
- '<video ng-src="{{video.file | trustUrl}}" style="width: 100px; height: 100px; border: 1px solid #D0D0D0" poster="{{video.vpic}}" controls="controls"></video>' +
- '</div>' +
- '</div>' +
- '</div>',
- title: message,
- scope: $scope,
- buttons: [
- { text: '取消' },
- {
- text: '<b>确定</b>',
- type: 'button-positive',
- onTap: function(e) {
- var data = {
- to_user_id:user_id,
- content:$scope.vm.content,
- video:$scope.video.file,
- image:$scope.imgs,
- //image:['http://img0.imgtn.bdimg.com/it/u=2398075737,160631337&fm=214&gp=0.jpg'],
- };
- myService.sendLetter(data).then(function(result){
- if(result.data.status_code==0){
- msg.success('发送成功');
- }
- })
- }
- }
- ]
- });
- }
- //跳转
- else if(is_url==1){
- if($location.path()=="/app/home/message/sys"){
- $state.go('app.home_dreamdetail',{id:dream_id,type:2});
- }
- else {
- $state.go('app.my_dreamdetail',{id:dream_id,type:2});
- }
- }
- //梦想结束
- else if(is_end==1&&attr_id==6){
- var endTemplate = '<div style="text-align: center"><p>恭喜你成功地你的梦想迈出最大的一步,</p>' +
- '<p>要取出全部梦想资金,</p>' +
- '<p>你需要亲自问候你的梦主</p>' +
- '<p>致出最诚挚的感谢</p>' +
- '<p>点击《确定》我们会提供</p>' +
- '<p>《梦主》的资料</p>' +
- '<p>如果你觉得不合适,你可以点击《取消》,但是《梦主》的资金会被退还给他</p>' +
- '<p>你以后创建梦想也会比较难</p>' +
- '</div>';
- msg.confirm('恭喜你!',endTemplate,'拒绝').then(function(result){
- if(result==true){
- myService.sure_meet(dream_id,1).then(function(res){
- if(res.data.status_code==0){
- if(res.data.data==0){
- msg.success('该梦想暂无梦主!');
- }
- else {
- msg.success('确定见面,期待相见吧!');
- }
- }
- })
- }
- else {
- myService.sure_meet(dream_id,0).then(function(res){
- if(res.data.status_code==0){
- msg.success('已拒绝见面!');
- }
- })
- }
- })
- }
- }
- }]);
- app.controller('messageReplyCtrl', ["$scope","$location","$ionicPopup","$ionicTabsDelegate", "$state","config", "myService", "msg", "$ionicModal"
- , function ($scope,$location,$ionicPopup,$ionicTabsDelegate, $state,config, myService, msg, $ionicModal) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.load(true);
- });
- $scope.load = function (init) {
- myService.replyMy().then(function (result) {
- $scope.comments = result.data.data;
- if (init) {
- $scope.$broadcast('scroll.refreshComplete');
- } else {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- }
- }, function (error) {
- });
- };
- $scope.goMes = function(info,img,is_max,mes,video,attr_id,dream_id,to_user_id,is_end,is_url){
- //收到私信
- if(attr_id==7){
- if(video!=null){
- var letterTemplate = '<div style="text-align: center">' +
- '<video ng-src=" ' +config.imgServer+video+' " width="100%" style="height: 350px;" class="centerme" controls="controls" ></video>' +
- '<p>'+info+'</p>' +
- '</div>';
- }
- else if(img!='') {
- var letterTemplate = '<div style="text-align: center;">' +
- '<img src="'+img+'" style="border-radius: 100%; width:100%; height: 100%;">' +
- '<p>'+info+'</p>' +
- '</div>';
- }
- else {
- var letterTemplate = '<div style="text-align: center">' +
- '<p>'+info+'</p>' +
- '</div>';
- }
- msg.confirm('私信',letterTemplate,'','梦想页').then(function(result){
- if(result==true){
- if($location.path()=="/app/home/message/reply"){
- $state.go('app.home_dreamdetail',{id:dream_id,type:2});
- }
- else {
- $state.go('app.my_dreamdetail',{id:dream_id,type:2});
- }
- }
- })
- }
- //成为梦主
- else if(is_max==1&&is_end==1){
- var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
- '<p>'+ info +'</p>' +
- '</div>';
- msg.confirm('恭喜你!',maxTemplate).then(function(result){
- if(result==true){
- myService.sure_meet2(to_user_id,1).then(function(res){
- if(res.data.status_code==0) {
- msg.success('确定见面,期待相见吧!');
- }
- })
- }
- else {
- myService.sure_meet2(to_user_id,0).then(function(res){
- if(res.data.status_code==0){
- msg.success('已取消见面!');
- }
- })
- }
- })
- }//确认见面/扫一扫
- else if(is_max==0&&is_url==0){
- var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
- '</div>';
- msg.alert('恭喜你!',maxTemplate).then(function(result){
- })
- }
- else if(is_end==0&&is_url==0){
- }
- else {
- if($location.path()=="/app/home/message/reply"){
- $state.go('app.home_dreamdetail',{id:dream_id,type:2});
- }
- else {
- $state.go('app.my_dreamdetail',{id:dream_id,type:2});
- }
- }
- };
- //我的回复
- $scope.vm = {
- content: ""
- };
- $ionicModal.fromTemplateUrl('my-modal.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function (modal) {
- $scope.modal = modal;
- });
- //$ionicModal.fromTemplateUrl('my-modal.html', {
- // scope: $scope,
- // animation: 'slide-in-up'
- //}).then(function (modal) {
- // $scope.modal = modal;
- //});
- //$scope.openModal = function () {
- // $scope.modal.show();
- //};
- //$scope.closeModal = function () {
- // $scope.modal.hide();
- //
- //};
- $scope.goDetail = function (id,interaction_id){
- $state.go('app.home_dreamdetail',{id:id,interaction_id:interaction_id,type:2});
- };
- //我的回复
- //$scope.vm={
- // content:"",
- // comment_id:""
- //};
- //$scope.closeModal = function () {
- // var data = {
- // content: $scope.vm.content,
- // comment_id: $scope.item.id,
- // interaction_id: $scope.item.interaction_id
- // };
- // myService.myReplay(data).then(function (result) {
- // msg.success('回复成功');
- // $scope.load();
- // }, function (error) {
- // msg.error('回复失败');
- // });
- // $scope.vm.content = '';
- // $scope.item = null;
- // $scope.modal.hide();
- //};
- //
- //$scope.reply = function (item) {
- // $scope.item = item;
- // $scope.modal.show();
- //}
-
- }]);
-
- })(angular.module('app.controllers'));
|