123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 |
- (function (app) {
- app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common", "config", "msg","$timeout"
- , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common, config, msg, $timeout) {
- $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);
- $timeout(function () {
- $scope.user.avatar = config.imgServer + response.data.md5;
- });
- });
- };
- }]);
- app.controller('profileCtrl', ["$scope", "$timeout","$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "common"
- , function ($scope, $timeout, $ionicTabsDelegate, $state, $filter, storage, myService, msg, common) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- });
- $scope.setAvator = function () {
- common.setAvator().then(function (result) {
- var response = JSON.parse(result.response);
- $timeout(function () {
- $scope.vm.avatar = config.imgServer + response.data.md5;
- });
- });
- };
-
- //保存个人信息
- $scope.vm={
- pic:"",
- sex:"",
- signture:"",
- emotion:"",
- job:"",
- tall:""
- };
- $scope.$on('$ionicView.beforeEnter', function () {
- msg.loading();
- myService.myInfo().then(function(result){
- // alert(JSON.stringify(result.data.data));
- $scope.vm = result.data.data;
- $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.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
- };
- 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('提交中...');
-
- 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;
- debugger;
- },function(error){
- msg.error(error.data.message)
- })
- };
- }]);
- app.controller('withdrawCtrl', ["$scope","$ionicTabsDelegate","$timeout", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $timeout,$state,myService, msg, storage) {
- $scope.vm={
- pay:"",
- cash:""
- };
- $scope.$on("$ionicView.enter",function(){
- myService.showAccount().then(function(result){
- var items = result.data.data;
- $scope.pays=[];
- angular.forEach(items,function(item){
- 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+")";
- $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 () {
- $state.go("app.my");
- },1000);
- },function(error){
- })
- }
- }]);
- app.controller('payoutCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- }]);
- 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('explainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- }]);
- 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('attention_DetailCtrl', ["$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.dream_id = $scope.items.near_dream.id;
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- });
- $scope.attentionUser = function(id,is_care){
- homeService.attentionUser(id,is_care).then(function(result){
- $scope.items.is_care=result.data.data;
- })
- };
- $scope.cancelSupport = function () {
- $scope.tosupport = false;
- $scope.toshare = false;
- };
- $scope.toshare = false;
- $scope.share = function ($event) {
- $event.stopPropagation();
- $scope.toshare = true;
- };
- $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.my_dreamdetail',{id:dream_id});
- }
- };
- $scope.toOldDream = function(){
- if($scope.items.dreams.length==0){
- msg.alert("曾经的梦想","该用户没有曾经的梦想");
- }
- if($scope.items.dreams.length!=0){
- $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){
- $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('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(){
- $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.sup_dream;
- },function(error){
- })
- };
- $scope.toDetail = function(){
- $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
- };
- }]);
- app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- }]);
- app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
- , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.letter().then(function(result){
- $scope.comments = result.data.data;
- },function(error){
- });
- });
- }]);
- app.controller('rechargeCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
- , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- myService.myInfo().then(function(result){
- $scope.vm = result.data.data;
- $scope.vm.money = '';
- $scope.vm.payType = 1;
- })
- });
- $scope.payExplain = function(){
- $state.go("app.payExplain")
- };
- $scope.withdraw = function(){
- $state.go("app.withdraw")
- };
-
- //充值
- $scope.recharge = function(money){
- if (!$scope.vm.money) {
- msg.text('请输入充值金额');
- return;
- }
- myService.recharge(money).then(function (result) {
- //todo: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');
- });
- }
- }]);
- app.controller('payCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.myInfo().then(function(result){
- $scope.vm = result.data.data;
- $scope.vm.money = '';
- })
- });
- $scope.payExplain = function(){
- $state.go("app.explain")
- };
- $scope.withdraw = function(){
- $state.go("app.payout")
- };
- //充值
- $scope.recharge = function(money){
- myService.recharge(money).then(function(result){
- 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","common","$ionicTabsDelegate", "$state", "myService", "msg"
- , function ($scope,common,$ionicTabsDelegate, $state, myService, msg) {
- $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);
- }, function (error) {
- msg.error('图片上传失败');
- });
- }, function (error) {
- console.log('图片选择失败');
- });
- };
- $scope.imgs=[];
- $scope.deletefile = function (file) {
- var index = $scope.imgs.indexOf(file);
- $scope.imgs.splice(index, 1);
- common.deletefile(file).then(function () {
- })
- };
- $scope.vm={
- bank_name:'',
- bank_number:'',
- bank_phone:'',
- bank_user:''
- };
- $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('保存中...');
- 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:{
- bank_name:$scope.vm.bank_name,
- //bank_number:$scope.imgs
- bank_number:"https://www.baidu.com/img/bd_logo1.png"
- }
- };
- myService.addQrcode(data).then(function(result){
- msg.text("添加成功",true);
- $timeout(function () {
- $state.go("app.my_account");
- }, 1000);
- },function(error){
- msg.error(error.data.message);
- })
- }
- }]);
- app.controller('messageCtrl', ["$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.systemInfo = function(){
- $state.go("app.my_message_sys");
- };
- $scope.notRead = function(){
- myService.notRead().then(function(result){
- },function(error){
- })
- };
- //回复我的
- $scope.replyMy = function(){
- $state.go("app.my_message_reply");
- };
- $scope.personalLetter = function(){
- $state.go("app.personalLetter");
- }
- }]);
- app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- $ionicTabsDelegate.showBar(false);
- myService.myDream().then(function(result){
- $scope.dreams = result.data.data;
- });
- myService.myInfo().then(function(result){
- $scope.user = result.data.data
- });
- });
- $scope.toDetail = function (id) {
- $state.go('app.my_dreamdetail',{id:id});
- };
- }]);
- 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", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.systemInfo().then(function(result){
- $scope.sysInfos = result.data.data;
- },function(error){
- });
- });
- }]);
- /* app.controller('sysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.systemInfo().then(function(result){
- $scope.sysInfos = result.data.data;
- },function(error){
- });
- });
- }]);*/
- /* app.controller('letterCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
- }]);*/
- app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
- , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
- $scope.$on('$ionicView.beforeEnter', function () {
- myService.replyMy().then(function(result){
- $scope.comments = result.data.data;
- },function(error){
- });
- });
- $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.vm={
- content:"",
- comment_id:""
- };
- $scope.myReplay = function(){
- var data = {
- content:$scope.vm.content,
- comment_id:$scope.vm.id
- };
- myService.myReplay(data).then(function(result){
- },function(error){
- });
- $scope.modal.hide();
- }
- }]);
-
- })(angular.module('app.controllers'));
|