var id_check = false; var frm_check = false; $(function() { $(document).on('keypress', '#frm_login input', function(e) { if (e.keyCode == 13) $(this).next().focus(); }); $(document).on('click', 'a.act_login', function() { login(); return false; }); $(document).on('submit', '#frm_login', function() { if (!form_val_chk($(this))) { return false; } $.ajax({ async: false, type: 'post', dataType: 'json', data: $('#frm_login').serialize(), url: '/common/member/login_proc.php', success: function(resp) { if (resp.result == 'success') { alert(resp.message); location.replace($('#frm_login input[name=red]').val()); } else alert(resp.message); }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); }); $(document).on('submit', '#frm_join1', function() { //$(this).find('#agree1, #agree2').prop('checked', true); return form_val_chk($(this)); }); $(document).on('click', 'a.act_join', function() { $('#frm_join2').trigger('submit'); return false; }); $(document).on('change', '#frm_join2 input[name=user_id]', function() { id_check = false; }); $(document).on('click', '.act_id_check', function() { if ($.trim($('#frm_join2 input[name=user_id]').val()) == '') { alert('아이디를 입력하세요.'); $('#frm_join2 input[name=user_id]').focus(); return false; } if ($('#frm_join2 input[name=user_id]').data('minlen') && $('#frm_join2 input[name=user_id]').val().replace(/ /g,'') != '') { if ($('#frm_join2 input[name=user_id]').val().length < $('#frm_join2 input[name=user_id]').data('minlen')) { alert($('#frm_join2 input[name=user_id]').data('minlen')+'자 이상 입력해주세요.'); $('#frm_join2 input[name=user_id]').focus(); return false; } } if (!pattern_check($('#frm_join2 input[name=user_id]').data('pattern'), $('#frm_join2 input[name=user_id]').val())) { $('#frm_join2 input[name=user_id]').focus(); return false; } $.ajax({ type: 'post', dataType: 'json', data: {act:'id', user_id:$.trim($('#frm_join2 input[name=user_id]').val())}, url: '/common/member/user_proc.php', success: function(resp) { alert(resp.message); if (resp.result == 'success') { id_check = true; } }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); return false; }); $(document).on('submit', '#frm_join2', function() { var chk = false; if (form_val_chk($(this))) { if (!id_check) { alert('아이디 중복 확인을 해주세요.'); return false; } if ($(this).find('input[name=passwd]').val() != $(this).find('input[name=passwd_conf]').val()) { alert('비밀번호가 일치하지 않습니다.'); return false; } $.ajax({ async: false, type: 'post', dataType: 'json', data: $('#frm_join2').serialize(), url: '/common/member/user_proc.php', success: function(resp){ alert(resp.message); if (resp.result == 'success') { chk = true; } }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } return chk; }); $(document).on('submit', '#frm_info', function() { if (form_val_chk($(this))) { if ($(this).find('input[name=passwd]').val() != $(this).find('input[name=passwd_conf]').val()) { alert('비밀번호가 일치하지 않습니다.'); return false; } $.ajax({ type: 'post', dataType: 'json', data: $('#frm_info').serialize(), url: '/common/member/user_proc.php', success: function(resp){ alert(resp.message); if (resp.result == 'success') { location.reload(); } }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } return chk; }); $(document).on('submit', '#frm_leave', function() { if (confirm('탈퇴하시겠습니까?')) { $.ajax({ type: 'post', dataType: 'json', data: $('#frm_leave').serialize(), url: '/common/member/user_proc.php', success: function(resp){ alert(resp.message); if (resp.result == 'success') { location.replace('/'); } }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } return false; }); $(document).on('submit', '#frm_find', function() { if (form_val_chk($(this))) { $.ajax({ type: 'post', dataType: 'json', data: $('#frm_find').serialize(), url: '/common/member/user_proc.php', success: function(resp){ alert(resp.message); }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } return false; }); $(document).on('submit', '#f_pwd_lost', function() { if (form_val_chk($(this))) { $.ajax({ type: 'post', dataType: 'json', data: $('#f_pwd_lost').serialize(), url: '/common/member/user_proc.php', success: function(resp){ alert(resp.message); if (resp.result == 'success') { location.replace('/'); } }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } return false; }); $(document).on('change', '#frm_search select', function() { $('#frm_search').trigger('submit'); return false; }); $(document).on('click', '.act_ord_cancel', function() { var idno = $(this).data('idno'); if (confirm('세무 상담 신청을 취소하시겠습니까?')) { $.ajax({ type: 'post', dataType: 'json', data: {'act':'cancel', 'idno':idno}, url: '/common/tax/proc.php', success: function(resp) { alert(resp.message); if (resp.result == 'success') { location.reload(); } }, error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); } return false; }); $(document).on('click', '.act_login_naver', function() { var url = 'https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=oeAl6almQpS3XhxeROWo&redirect_uri='+root_url_encoded+'common%2Fmember%2Flogin_naver.php&state=RAMDOM_STATE'; if ($(this).hasClass('mobile')) { location.href = url; } else { var win = window.open(url,'naver', 'width=10,height=10'); win.focus(); } return false; }); $(document).on('click', '.act_login_facebook', function() { FB.login(); return false; }); }); function login() { $('#frm_login').trigger('submit'); } //facebook function statusChangeCallback(response) { //console.log(response); if (response.status === 'connected') { FBlogin(); } } function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } window.fbAsyncInit = function() { FB.init({ appId : '430789080647419', cookie : true, // enable cookies to allow the server to access // the session xfbml : true, // parse social plugins on this page version : 'v2.8' // use graph api version 2.8 }); FB.getLoginStatus(function(response) { statusChangeCallback(response); }); }; // Load the SDK asynchronously (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/ko_KR/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function FBlogin() { FB.api('/me', function(response) { //$('#result').html('facebook: '+response.name+' '+response.id); $('#frm_login input[name=sns]').val('facebook'); $('#frm_login input[name=sns_id]').val(response.id); $('#frm_login input[name=sns_name]').val(response.name); login(); }); }