254 lines
7.0 KiB
JavaScript
254 lines
7.0 KiB
JavaScript
|
|
var dateTimeNow = '';
|
|
$(document).ready(function () {
|
|
$('#rule').click(function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#btnSmsReciver').prop("disabled", false);
|
|
$('#btnSmsReciver').removeClass("disable");
|
|
$(this).prop("disabled", true);
|
|
} 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');
|
|
});
|
|
|
|
$("#time-code").on('input', function () {
|
|
var value = $(this).val();
|
|
$(this).val(convertPersianNumbersToEnglish(value));
|
|
}).mask("000000");
|
|
|
|
$('#changeDuration').on('change', function () {
|
|
|
|
if (this.value == "1Mount") {
|
|
$('#Duration').val('یک ماهه');
|
|
} else if (this.value == "3Mount") {
|
|
$('#Duration').val('سه ماهه');
|
|
} else if (this.value == "6Mount") {
|
|
$('#Duration').val('شش ماهه');
|
|
} else if (this.value == "12Mount") {
|
|
$('#Duration').val('یک ساله');
|
|
}
|
|
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
url: computeMoneyByMountAjax,
|
|
type: 'GET',
|
|
data: {"mount": this.value, "money": $('#AmountFaReal').val() },
|
|
success: function (response) {
|
|
if (response.isSuccedded) {
|
|
$('#AmountFaWithout').text(response.cumputeWithout);
|
|
//$('#AmountFaDiscount').text(response.cumputeDiscount);
|
|
$('#AmountFaWith').text(response.cumputeWithout);
|
|
$('#AmountFaTotal').text(response.cumputeWithout);
|
|
$('#AmountFa').text(response.cumputeWithout);
|
|
// برای تخفیف محاسبه میشد
|
|
//$('#AmountFaWith').text(response.cumpute);
|
|
//$('#AmountFaTotal').text(response.cumpute);
|
|
//$('#AmountFa').text(response.cumpute);
|
|
} else {
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
}, 3500);
|
|
}
|
|
},
|
|
error: function (err) {
|
|
console.log(err);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#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();
|
|
dateTimeNow = new Date().toJSON();
|
|
startTimer(2);
|
|
} else {
|
|
$('.loading').hide();
|
|
$('#btnSmsReciver').show();
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
|
|
function startTimer(minutes) {
|
|
var timer = minutes * 60, display = $('#timer');
|
|
var interval = setInterval(function () {
|
|
var minutes = parseInt(timer / 60, 10);
|
|
var seconds = parseInt(timer % 60, 10);
|
|
|
|
minutes = minutes < 10 ? "0" + minutes : minutes;
|
|
seconds = seconds < 10 ? "0" + seconds : seconds;
|
|
|
|
display.text(minutes + ":" + seconds);
|
|
|
|
if (--timer < 0) {
|
|
clearInterval(interval);
|
|
$('#btnSmsReciver').prop("disabled", false);
|
|
$('#btnSmsReciver').removeClass("disable");
|
|
$('#btnSmsReciver').text('ارسال دوباره');
|
|
$('#CodeDiv').addClass("disable");
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
// var form = $("#steps");
|
|
// form.steps({
|
|
// headerTag: "h6",
|
|
// bodyTag: "section",
|
|
// transitionEffect: "fade",
|
|
// titleTemplate: '<div class="step-progress"><h5 class="d-flex justify-content-center align-items-center not-step"> #index# </h5><p>#title#</p></div>'
|
|
// });
|
|
});
|
|
|
|
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,
|
|
'codeSendTimeStr': dateTimeNow
|
|
},
|
|
success: function (response) {
|
|
if (response.exist === true) {
|
|
SaveServiceData();
|
|
} 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);
|
|
}
|
|
});
|
|
} 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: saveServiceAjax,
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
|
|
function OpenAccount() {
|
|
window.location.href = saveCameraAccountUrl;
|
|
}
|