(function () { "use strict"; angular .module('codeAPLEBOX.client.user.customer.home') .controller('customerHomeController', customerHomeController); /* @ngInject */ function customerHomeController($state, appConfig, $log, Auth, $cookies, WEB_API_CUSTOMER, moment) { var vm = this; // ======================================================================= // 초기데이터 // ======================================================================= vm.customerInfo = $cookies.getObject("customerInfo"); iniData(); // ======================================================================= // Angularjs Function // ======================================================================= vm.goLogout = function(){ // 내정보수정 var value = confirm("로그아웃 하시겠습니까?") if (value) { Auth.logout_customer({ accountID: vm.customerInfo.accountID }).then(function (result) { $state.go("main.customerLogin"); $log.debug(result) }).catch(function (err) { $log.err(err) }); // $state.reload(); } } vm.goRentMonth = function(){ // 월별내역 $cookies.remove('rentPerMonthYearMonth'); $state.go('customer.rentpermonth'); } vm.goRents = function(index){ // 대여내역 $state.go('customer.rents',{ selectedCode: index.toString() }) } vm.goMyDeposit = function(){ // 내보증금 $state.go("customer.mydeposit", { previousState: 'customer.home' }); } vm.goReturns = function(){ // 반납내역 $cookies.remove('detailStatusYearMonth'); $state.go('customer.returnstatus'); //BS1110 } // ======================================================================= // Common API // ======================================================================= function iniData(){ var now = new Date(); vm.startDate = moment(new Date(now.getFullYear(), now.getMonth(), 1)).format("YYYY년 MM월 DD일"); vm.endDate = moment(new Date(now.getFullYear(), now.getMonth()+1, 0)).format("YYYY년 MM월 DD일"); getSummary(); } function getSummary(){ var currentMonth = moment(new Date()).format("YYYY-MM"); WEB_API_CUSTOMER.getSummary({ customerId: vm.customerInfo.id, currentMonth: currentMonth }).then(function (result) { vm.monthlyInfo = result.data.monthlyInfo; vm.otherInfo = result.data.otherInfo; }).catch(function (err) { $log.error(err); }); } } })();