165 lines
5.1 KiB
JavaScript
165 lines
5.1 KiB
JavaScript
$(document).ready(function () {
|
|
$('#rule').click(function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#btnSmsReciver').prop("disabled", false);
|
|
$('#btnSmsReciver').removeClass("disable");
|
|
} else {
|
|
$('#btnSmsReciver').prop("disabled", true);
|
|
$('#btnSmsReciver').addClass("disable");
|
|
}
|
|
});
|
|
|
|
$("#next-step").on("click", function () {
|
|
$('#step-form1').hide();
|
|
$('#step-form2').show();
|
|
$('#prev-step').text('مرحله قبل');
|
|
$('#next-step').text('ثبت');
|
|
// $('#next-step').addClass('disable')
|
|
$('#step-2').removeClass('not-step');
|
|
});
|
|
|
|
$("#prev-step").on("click", function () {
|
|
$('#step-form1').show();
|
|
|
|
if ($('#step-form2').is(":hidden")) {
|
|
$("#MainModal").modal("hide");
|
|
}
|
|
|
|
$('#step-form2').hide();
|
|
$('#prev-step').text('انصراف');
|
|
$('#next-step').text('مرحله بعد');
|
|
$('#step-2').addClass('not-step');
|
|
});
|
|
|
|
$('#btnSmsReciver').on("click", function () {
|
|
$('#btnSmsReciver').prop("disabled", true);
|
|
$('#btnSmsReciver').addClass("disable");
|
|
sendVerifyCode();
|
|
});
|
|
|
|
function sendVerifyCode() {
|
|
$.ajax({
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: sendSmsAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
success: function (response) {
|
|
if (response.isSuccess) {
|
|
$('#CodeDiv').removeClass("disable");
|
|
$('#next-step').removeClass('disable');
|
|
$('#next-step').attr('onclick', 'confirmCodeToLogin()');
|
|
codeTimer();
|
|
} else {
|
|
$('.loading').hide();
|
|
$('#btnSmsReciver').show();
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
|
|
function codeTimer() {
|
|
$('#timer').text('');
|
|
var timer2 = "2:00";
|
|
var interval = setInterval(function () {
|
|
var timer = timer2.split(':');
|
|
//by parsing integer, I avoid all extra string processing
|
|
var minutes = parseInt(timer[0], 10);
|
|
var seconds = parseInt(timer[1], 10);
|
|
--seconds;
|
|
minutes = (seconds < 0) ? --minutes : minutes;
|
|
if (minutes < 0) clearInterval(interval);
|
|
seconds = (seconds < 0) ? 59 : seconds;
|
|
seconds = (seconds < 10) ? '0' + seconds : seconds;
|
|
//minutes = (minutes < 10) ? minutes : minutes;
|
|
$('.countdown').html(minutes + ':' + seconds);
|
|
timer2 = minutes + ':' + seconds;
|
|
|
|
if (timer2 === "0:00" && !$('#passDiv').hasClass("showPassDiv")) {
|
|
|
|
$('#next-step').attr('onclick', '');
|
|
$('#next-step').addClass('disable');
|
|
$('#CodeDiv').addClass("disable");
|
|
|
|
|
|
//اینپوت برای وارد کردن کدها خالی میشود
|
|
$('.time-code').val('');
|
|
$('#timer').text('00:00');
|
|
}
|
|
|
|
}, 1000);
|
|
}
|
|
});
|
|
|
|
function confirmCodeToLogin() {
|
|
var code = $('#time-code').val();
|
|
if (code.length == 6) {
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: checkCodeAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: {
|
|
'code': code
|
|
},
|
|
success: function (response) {
|
|
if (response.exist === true) {
|
|
SaveServiceData();
|
|
} else {
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text('کد وارد شده صحیح نیست.');
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
}, 3500);
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
} else {
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text('کد وارد شده کمتر از 6 رقم است.');
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
}, 3500);
|
|
}
|
|
}
|
|
|
|
function SaveServiceData()
|
|
{
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: saveServiceFreeAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: $('#create-form').serialize(),
|
|
success: function (response) {
|
|
if (response.isSuccedded === true) {
|
|
$('.alert-success-msg').show();
|
|
$('.alert-success-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-success-msg').hide();
|
|
$('.alert-success-msg p').text('');
|
|
}, 3500);
|
|
} else {
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
}, 3500);
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|