var is_fs = false; var requestFullScreen = function(elem) { var element = document.body; // Supports most browsers and their versions. var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; if (requestMethod) { // Native full screen. requestMethod.call(element); } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. var wscript = new ActiveXObject("WScript.Shell"); if (wscript !== null) { wscript.SendKeys("{F11}"); } } is_fs = true; $(elem).html(''); } var cancel_fs = function(elem) { var element = document; //and NOT document.body!! var requestMethod = element.exitFullScreen || element.mozCancelFullScreen || element.webkitExitFullScreen || element.mozExitFullScreen || element.msExitFullScreen || element.webkitCancelFullScreen; if (requestMethod) { // Native full screen. requestMethod.call(element); } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. var wscript = new ActiveXObject("WScript.Shell"); if (wscript !== null) { wscript.SendKeys("{F11}"); } } $(elem).html(''); is_fs = false; } var toggleFS = function(elem) { is_fs == true ? cancel_fs(elem) : requestFullScreen(elem); } $(function(){ $('.logo_icon').click(function(){ $('.header').toggleClass("active"); }) }) // datepicker /* $(function(){ $('.dateArea .date').datepicker({ format: "yyyy-mm-dd", setDates :"2018-10-22", language: "kr", todayHighlight: true, }); }); */ /* 출금 관련 코드 */ function customWidthPrompt(_option){ var id = new Date().getTime() + "_" + Math.ceil(Math.random() * 100000); var padding = "45px"; if(_option.padding != undefined) padding = _option.padding; var inputType = (_option.inputType != undefined) ? _option.inputType : 'text'; $("body").append( '' ) $("#alert_prompt_"+id).on('hidden.bs.modal' ,function(){ $("#alert_prompt_"+id).remove(); }) $("#confirm_title_"+id).html(_option.title); $("#confirm_msg_"+id).html(_option.msg); $("#btn_confirm_submit_"+id).unbind("click").click(function(){ _option.submit($('#confirm_value_'+id).val()) }); $("#alert_prompt_"+id).modal('show'); } function customWithdrawalConfirm(_option){ var id = new Date().getTime() + "_" + Math.ceil(Math.random() * 100000); var padding = "45px"; if(_option.padding != undefined) padding = _option.padding; $("body").append( '' ) $("#confirm_message_"+id).on('hidden.bs.modal' ,function(){ $("#confirm_message_"+id).remove(); }) $("#confirm_title_"+id).html(_option.title); $("#confirm_msg_"+id).html(_option.msg); $("#btn_confirm_submit_"+id).unbind("click").click(_option.submit); $("#confirm_message_"+id).modal('show'); } function customWithdrawalAlert(_option){ var margin_top = (_option.margin_top != undefined ? _option.margin_top : "20px"); var id = new Date().getTime() + "_" + Math.ceil(Math.random() * 100000); $("body").append( '' ) $("#alert_message_"+id).on('hidden.bs.modal' ,function(){ $("#alert_message_"+id).remove(); }) if(_option.title == undefined) $("#alert_title_"+id).remove(); else $("#alert_title_"+id).html(_option.title); $("#alert_msg_"+id).html(_option.msg); $("#btn_alert_submit_"+id).unbind("click"); if(_option.submit != undefined) $("#btn_alert_submit_"+id).click(_option.submit); $("#alert_message_"+id).modal('show'); } function withdrawalKeyEvent(shop_point) { var withdrawal_commission = 300; $("#withdrawal_price").val($("#withdrawal_price").val().replace(/[^0-9]/gi , '')); if($("#withdrawal_price").val() == '' || $("#withdrawal_price").val() == 0){ $("#after_point").html("출금후 예치금 : "+Comma(shop_point)+"원"); }else if(shop_point < Number($("#withdrawal_price").val())){ $("#withdrawal_price").val(shop_point - withdrawal_commission); $("#after_point").html("출금후 예치금 : "+Comma(shop_point - Number($("#withdrawal_price").val()) - withdrawal_commission)+'원'); }else{ $("#after_point").html("출금후 예치금 : "+Comma(shop_point - Number($("#withdrawal_price").val()) - withdrawal_commission)+'원'); } } var cardWidth = 370; $(function(){ $('select').click(function(){ $('.selectBox').remove(); var selectBox = $(this); var offset = selectBox.offset(); var left = offset.left; var top = offset.top + $(this).height();; var width = $(this).width(); var li = ''; for(var i = 0 ; i < $(this).children('option').length ; i++){ var value = $(this).children('option').eq(i); li += '
  • '+value.html()+'
  • '; } $('body').append( '' ); $('.selectBox li').unbind('click').click(function(){ selectBox.val($(this).data('value')).change(); }); $(window).unbind('click').click(function(e){ if(e.target.tagName != 'SELECT') $('.selectBox').remove();}); return false; }); var setScrollTimer; $("#account_scroll_view").scroll(function(e){ if(setScrollTimer != undefined){ clearTimeout(setScrollTimer); } var left = document.getElementById("account_scroll_view").scrollLeft; if(left % cardWidth != 0){ setScrollTimer = setTimeout(function(){ let resize = 0; if((left%cardWidth) > (cardWidth / 2)){ resize = cardWidth - (left%cardWidth); } else { resize = (left%cardWidth) * -1; } $("#account_scroll_view").animate({ scrollLeft: left + resize }, 300); // document.getElementById("account_scroll_view").scrollTo({ // top: 0, // left: left + resize, // behavior: 'smooth' // }) } , 300) } }) $("#btn_account_prev").click(function(){ let left = document.getElementById("account_scroll_view").scrollLeft; if((left%cardWidth) == 0){ $("#account_scroll_view").animate({ scrollLeft: left - cardWidth - (left%cardWidth) }, 300); // document.getElementById("account_scroll_view").scrollTo({ // top: 0, // left: left - cardWidth - (left%cardWidth), // behavior: 'smooth' // }) } }) $("#btn_account_next").click(function(){ let left = document.getElementById("account_scroll_view").scrollLeft; if((left%cardWidth) == 0){ $("#account_scroll_view").animate({ scrollLeft: left + cardWidth - (left%cardWidth) }, 300); // document.getElementById("account_scroll_view").scrollTo({ // top: 0, // left: left + cardWidth - (left%cardWidth), // behavior: 'smooth' // }) } }) $("#account_scroll_view").on("mousewheel DOMMouseScroll", function (e) { if( e != undefined && e.originalEvent != undefined){ if (e.originalEvent.deltaY > 0) { $("#btn_account_next").click(); } else { $("#btn_account_prev").click(); } } }) $(".card_view").click(function(){ if($(this).index(".card_view") == $(".card_view").length - 1){ $("#addWithdrawalAccountPopup").modal('show'); let res = HttpPostJson( "/order_bg_test/getRefundBankCode", {}); if(res.result == 1 && Object.keys(res.refund_bank_code).length > 0){ $("#selectBankCode").html(""); for(key in res.refund_bank_code){ let value = res.refund_bank_code[key.toString()]; $("#selectBankCode").prepend(''); } $("#selectBankCode").prepend(""); $("#selectBankCode").val(""); } } }); $("#btnAddAccount").click(function(){ let selectBankCode = $("#selectBankCode").val() let bank_name = $("#bank_name").val() let owner_name = $("#owner_name").val() let res = HttpPostJson( "/order_bg_test/setRefundAccount", {bank_cd : selectBankCode , account_no : bank_name , account_nm : owner_name }); if(res.result == 1){ $("#addWithdrawalAccountPopup").modal('hide'); accountListRefresh(); customWithdrawalAlert({ title: "계좌등록" , msg : "계좌등록이 완료되었습니다" }); }else if(res.msg != ''){ customWithdrawalAlert({ title: "계좌등록" , msg : res.msg }); } }) $("#addWithdrawalAccountPopup").on('hide.bs.modal', function (e) { $("#selectBankCode").val(""); $("#bank_name").val(""); $("#owner_name").val(""); }); $("#btn_withdrawal").click(function(){ $("#withdrawalPopup").modal('show'); accountListRefresh(); let res = HttpPostJson( "/order/get_point", {}); $("#now_point").html("현재 예치금 : "+Comma(res.shop_point)+'원'); $("#after_point").html("출금후 예치금 : "+Comma(res.shop_point)+'원'); let shop_point = res.shop_point $("#withdrawal_price").unbind('keydown').keydown(function(){ withdrawalKeyEvent(shop_point); if (((event.keyCode<48) || (event.keyCode>57)) && ((event.keyCode<96) || (event.keyCode>105)) && event.keyCode != 8 && event.keyCode != 9 && event.keyCode != 46 && event.keyCode != 37 && event.keyCode != 39) return false; }); $("#withdrawal_price").unbind('keypress').keypress(function(){ withdrawalKeyEvent(shop_point); if (((event.keyCode<48) || (event.keyCode>57)) && ((event.keyCode<96) || (event.keyCode>105)) && event.keyCode != 8 && event.keyCode != 9 && event.keyCode != 46 && event.keyCode != 37 && event.keyCode != 39) return false; }); $("#withdrawal_price").unbind('keyup').keyup(function(){ withdrawalKeyEvent(shop_point); if (((event.keyCode<48) || (event.keyCode>57)) && ((event.keyCode<96) || (event.keyCode>105)) && event.keyCode != 8 && event.keyCode != 9 && event.keyCode != 46 && event.keyCode != 37 && event.keyCode != 39) return false; }); }) $("#btnWithdrawal").click(function(){ var left = document.getElementById("account_scroll_view").scrollLeft; var selectAccount = Math.round(left / cardWidth); if(selectAccount == $(".card_view").length -1 ){ customWithdrawalAlert({ title: "출금요청" , msg : "출금요청 계좌를 선택해주세요" }); return false; } var account_idx = $(".card_view").eq(selectAccount).data("account_idx"); let res = HttpPostJson( "/order_bg_test/hasSecondaryPassword", {}); if(res.result == 1){ // 비밀번호 있음 if($("#withdrawal_price").val().trim() == ''){ customWithdrawalAlert({ title: "출금요청" , msg : "출금요청금액을 입력해주세요" }); }else{ easypayWithdrawal(); } }else if(res.result == 2){ // 비밀번호 오류 customWithdrawalAlert({ title: "2차 비밀번호" , msg : res.msg }); }else if(res.result == 0){ // 비밀번호가 없어서 설정해야됨 setSecondaryFirst() } }) }) function easypayWithdrawal(){ customWidthPrompt({ title : "2차 비밀번호" , msg : "2차 비밀번호를 입력해주세요" , inputType : "password" , submit : function(pw_second){ var left = document.getElementById("account_scroll_view").scrollLeft; var selectAccount = Math.round(left % cardWidth); var account_idx = $(".card_view").eq(selectAccount).data("account_idx"); let res = HttpPostJson( "/order_bg_test/easypayWithdrawal", { account_idx : account_idx , amount : $("#withdrawal_price").val().replace(/[^0-9]/gi , '') , message : '' , secondary_password : pw_second }); if(res.result == 1){ customWithdrawalAlert({ title: "출금요청" , msg : "출금요청이 완료되었습니다" }); $("#withdrawalPopup").modal('hide'); }else if(res.msg != ''){ customWithdrawalAlert({ title: "출금요청" , msg : res.msg }); } } }) } function setSecondarySecond(pw_first){ customWidthPrompt({ title : "2차 비밀번호 확인" , msg : "2차 비밀번호를 다시 입력해주세요" , inputType : "password" , submit : function(pw_second){ if(pw_first == pw_second){ let res = HttpPostJson( "/order_bg_test/setSecondaryPassword", {secret_value : pw_second}); if(res.result == 1){ customWithdrawalAlert({ title: "2차 비밀번호" , msg : "2차 비밀번호 설정이 완료되었습니다" }); }else if(res.msg != ''){ customWithdrawalAlert({ title: "2차 비밀번호" , msg : res.msg }); } }else{ customWithdrawalAlert({ title: "2차 비밀번호" , msg : "입력하신 비밀번호가 일치하지 않습니다
    다시 시도해주세요." , submit : function(){setSecondaryFirst();}}); } } }) } function setSecondaryFirst(){ customWidthPrompt({ title : "2차 비밀번호 설정" , msg : "2차 비밀번호를 설정해주세요
    6글자 이상 입력해주세요" , inputType : "password" , submit : function(pw_first){ if(pw_first.length < 6){ customWithdrawalAlert({ title: "2차 비밀번호" , msg : "6글자 이상 입력해 주세요" , submit : function(){setSecondaryFirst();}}); }else{ setSecondarySecond(pw_first); } } }) } function accountListRefresh(){ let res = HttpPostJson( "/order_bg_test/getRefundAccounts", {}); let cardView = $(".card_view") for(let key in cardView){ if(key < cardView.length -1){ cardView.eq(key).remove(); } } if(res.result == 1 && res.list.length > 0){ for(let key in res.list){ let value = res.list[key]; $("#account_item_list").prepend( '
  • '+ '

    '+value.bank_code_name+'

    '+ '

    '+value.bank_account+'

    '+ '

    예금주 : '+value.bank_name+'

    '+ '' + '
  • ' ); } $(".icon_trash").unbind("click").click(function(){ let index = $(this).index(".icon_trash"); let account_item = $('.account_item').eq(index); let account_idx = $('.account_item').eq(index).data("account_idx"); let p_value = account_item.children("p"); let msg = p_value.eq(0).html() + '
    ' + p_value.eq(1).html() + '
    ' + p_value.eq(2).html() + '
    선택하신 계좌를 삭제하시겠습니까?'; customWithdrawalConfirm({ title: "계좌삭제" , msg : msg , submit : function(){ let res = HttpPostJson( "/order_bg_test/removeRefundAccounts", { account_idx : account_idx}); if(res.result == 1){ accountListRefresh(); customWithdrawalAlert({ title: "계좌삭제" , msg : "삭제 완료" }); } } }); }); } }