|
|
@@ -16,29 +16,52 @@ async function beforeAuth(tag) {
|
|
|
}
|
|
|
})
|
|
|
setCookie('authNum', randomCode, 3);
|
|
|
- const timer = document.getElementById('timer');
|
|
|
- timer.style.display = 'block';
|
|
|
- countDown();
|
|
|
+ if (tag === 'auth_check_phone') {
|
|
|
+ const timer = document.getElementById('auth_timer');
|
|
|
+ timer.style.display = 'block';
|
|
|
+ countDown('auth_timer');
|
|
|
+ } else {
|
|
|
+ const timer = document.getElementById('timer');
|
|
|
+ timer.style.display = 'block';
|
|
|
+ countDown('timer');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 인증버튼 클릭
|
|
|
-function afterAuth(tag) {
|
|
|
- const phoneNumInput = document.getElementById('check_phone');
|
|
|
- const authNumInput = document.getElementById('check_apply_num');
|
|
|
- const phoneBtn = document.getElementById('button_phone');
|
|
|
- const authBtn = document.getElementById('button_auth');
|
|
|
- const timer = document.getElementById('timer');
|
|
|
- const authVal = document.getElementById('check_apply_num').value;
|
|
|
+async function afterAuth(type) {
|
|
|
+ let phoneNumInput;
|
|
|
+ let authNumInput;
|
|
|
+ let phoneBtn;
|
|
|
+ let authBtn;
|
|
|
+ let timer;
|
|
|
+ let authVal;
|
|
|
+ if (type === 'APPLY') {
|
|
|
+ phoneNumInput = document.getElementById('check_phone');
|
|
|
+ authNumInput = document.getElementById('check_apply_num');
|
|
|
+ phoneBtn = document.getElementById('button_phone');
|
|
|
+ authBtn = document.getElementById('button_auth');
|
|
|
+ timer = document.getElementById('timer');
|
|
|
+ authVal = document.getElementById('check_apply_num').value;
|
|
|
+ } else if (type === 'READ') {
|
|
|
+ phoneNumInput = document.getElementById('auth_check_phone');
|
|
|
+ authNumInput = document.getElementById('auth_apply_num');
|
|
|
+ phoneBtn = document.getElementById('auth_button_phone');
|
|
|
+ authBtn = document.getElementById('auth_button_auth');
|
|
|
+ timer = document.getElementById('auth_timer');
|
|
|
+ authVal = document.getElementById('auth_apply_num').value;
|
|
|
+ }
|
|
|
if (authVal.length === 7) {
|
|
|
const authNum = getCookie('authNum');
|
|
|
if (authVal === authNum) {
|
|
|
- alert('인증이 완료되었습니다.');
|
|
|
+
|
|
|
phoneNumInput.disabled = true;
|
|
|
authNumInput.disabled = true;
|
|
|
phoneBtn.disabled = true;
|
|
|
authBtn.disabled = true;
|
|
|
timer.style.display = 'none';
|
|
|
clearInterval(intervalCount);
|
|
|
+ type === 'APPLY' ? alert('인증이 완료되었습니다.') :
|
|
|
+ await getPassword();
|
|
|
} else {
|
|
|
alert('인증번호가 일치하지 않습니다.');
|
|
|
}
|
|
|
@@ -74,14 +97,52 @@ function saveAuth() {
|
|
|
document.getElementById('lg_email').value = email;
|
|
|
document.getElementById('lg_phone').value = phone;
|
|
|
document.getElementById('button-phone').disabled = true;
|
|
|
- closeModal();
|
|
|
+ closeModal('advice_modal');
|
|
|
+}
|
|
|
+
|
|
|
+async function getPassword() {
|
|
|
+ const id = document.getElementById('board_id').value;
|
|
|
+ axios.get('/api/v1/board/password', {params: {id}})
|
|
|
+ .then(res => {
|
|
|
+ alert(`비밀번호는 ${res.data} 입니다.`)
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function checkPassword() {
|
|
|
+ const id = document.getElementById('board_id').value;
|
|
|
+ const password = document.getElementById('auth_password').value;
|
|
|
+ const dataMap = {id, password}
|
|
|
+ axios.post('/api/v1/board/password', dataMap)
|
|
|
+ .then(res => {
|
|
|
+ if (!res.data) {
|
|
|
+ alert('비밀번호가 틀렸습니다.');
|
|
|
+ } else {
|
|
|
+ closeModal('auth_modal');
|
|
|
+ document.getElementById('advice_manual_header').style.display = 'none';
|
|
|
+ document.getElementById('advice_apply').style.display = 'none';
|
|
|
+ document.getElementById('advice_manual').style.display = 'none';
|
|
|
+ document.getElementById('advice_detail').style.display = 'flex';
|
|
|
+ bindDetail(id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 타이머 함수
|
|
|
-function countDown() {
|
|
|
+function countDown(target) {
|
|
|
let time = 180;
|
|
|
- const timer = document.getElementById('timer');
|
|
|
- const buttonAuth = document.getElementById('button_auth');
|
|
|
+ const timer = document.getElementById(target);
|
|
|
+ let buttonAuth;
|
|
|
+ if (target === 'timer') {
|
|
|
+ buttonAuth = document.getElementById('button_auth');
|
|
|
+ } else {
|
|
|
+ buttonAuth = document.getElementById('auth_button_auth');
|
|
|
+ }
|
|
|
intervalCount = setInterval(function () {
|
|
|
if (time > 0) {
|
|
|
--time;
|