158 lines
7.5 KiB
Plaintext
158 lines
7.5 KiB
Plaintext
@{
|
|
ViewBag.Title = "ورود";
|
|
Layout = "~/Views/_LayoutAdmin.cshtml";
|
|
}
|
|
<div class="d-flex flex-center flex-row-fluid bgi-size-cover bgi-position-top bgi-no-repeat" style="background-image: url('../assets/media/bg/bg-3.jpg');">
|
|
<div class="login-form text-center p-7 position-relative overflow-hidden w-50">
|
|
<div class="d-flex flex-center mb-15">
|
|
<a href="#">
|
|
<img src="~/Media/logo.png" class="max-h-75px" alt="">
|
|
</a>
|
|
</div>
|
|
<div class="login-signin">
|
|
<div class="mb-20">
|
|
<h3>ورود به پنل مدیریت</h3>
|
|
<div class="text-muted font-weight-bold">شماره تلفن خود را وارد کنید</div>
|
|
</div>
|
|
<form class="form fv-plugins-bootstrap fv-plugins-framework" id="kt_sign_in_form">
|
|
@if (!Response.IsRequestBeingRedirected)
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
}
|
|
<div class="form-group mb-5 fv-plugins-icon-container">
|
|
<input class="form-control h-auto form-control-solid py-4 px-8" id="txtPhone" type="text" placeholder="شماره همراه ..." name="Username" maxlength="11">
|
|
<div class="fv-plugins-message-container"></div>
|
|
</div>
|
|
<div class="form-group mb-5 fv-plugins-icon-container">
|
|
<input class="form-control h-auto form-control-solid py-4 px-8" id="txtCode" type="password" placeholder="کد تایید" name="Password">
|
|
<div class="fv-plugins-message-container"></div>
|
|
</div>
|
|
<a id="SaveBtn" class="btn btn-primary font-weight-bold px-9 py-4 my-3 mx-4" onclick="Login()">ارسال کد تایید</a>
|
|
<a id="SaveBtn" class="btn btn-primary font-weight-bold px-9 py-4 my-3 mx-4" onclick="LoginPass()">ورود با پسورد</a>
|
|
<input type="hidden"><div></div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@section Script{
|
|
<script src="~/siteassets/js/bootstrap.js"></script>
|
|
<script src="~/siteassets/js/notyf.min.js"></script>
|
|
|
|
<script>
|
|
const Return = '@ViewBag.Return';
|
|
|
|
$("#txtPhone").keydown(function (e) {
|
|
if (e.keyCode == 13) {
|
|
$("#SaveBtn").click();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
function LoginPass() {
|
|
let Username = $("input[name=Username]").val();
|
|
let Password = $("input[name=Password]").val();
|
|
if (Username.length && Password.length) {
|
|
$("#kt_sign_in_submit").removeAttr("onclick");
|
|
$("#kt_sign_in_submit").css("opacity", 0.5);
|
|
$.post("../Panel/Login", $("#kt_sign_in_form").serialize(), function (data) {
|
|
if (data.Status == "Success") {
|
|
location.href = "../Panel/Index";
|
|
}
|
|
else {
|
|
$("#kt_sign_in_submit").attr("onclick", "Login()");
|
|
if (data.Status == "Error") {
|
|
toastr.warning("خطا هنگام برقراری ارتباط با سرور");
|
|
}
|
|
else if (data.Status == "Block") {
|
|
toastr.warning("شما دسترسی ورود به پنل را ندارید");
|
|
}
|
|
else {
|
|
toastr.warning("اطلاعات وارد شده صحیح نمی باشد");
|
|
}
|
|
}
|
|
}).fail(function () {
|
|
$("#kt_sign_in_submit").attr("onclick", "Login()");
|
|
toastr.error("خطا هنگام برقراری ارتباط با سرور");
|
|
}).always(function () {
|
|
$("#kt_sign_in_submit").css("opacity", 1);
|
|
});
|
|
}
|
|
else {
|
|
toastr.warning("نام کاربری و رمز عبور را وارد کنید");
|
|
}
|
|
}
|
|
|
|
function Login() {
|
|
var Phone = $("#txtPhone").val();
|
|
if (Phone.length != 11) {
|
|
toastr.error('شماره موبایل به درستی وارد نشده !!!');
|
|
} else {
|
|
$("#SaveBtn").css("opacity", 0.5);
|
|
$("#SaveBtn").attr("onclick", "");
|
|
$.post("../api/User/Login", { Phone: Phone }, function (data) {
|
|
if (data.Status == "OK") {
|
|
toastr.success('کد فعال سازی ارسال شد !!!');
|
|
$("#txtPhone").prop("disabled", true);
|
|
$(".lvl-2").fadeIn();
|
|
$("#SaveBtn").attr("onclick", "Submit()");
|
|
$("#SaveBtn").text("ورود به پنل");
|
|
//setTimeout(function () {
|
|
// let RedirectUrl = Return == '' ? '' : `&Return=${Return}`;
|
|
// location.href = "Verify?Phone=" + Phone + RedirectUrl;
|
|
//}, 2500);
|
|
}
|
|
else {
|
|
$("#SaveBtn").attr("onclick", "Login()");
|
|
toastr.error('خطا هنگام برقراری ارتباط با سرور !!!');
|
|
}
|
|
}).fail(function (xhr) {
|
|
console.error("Error:", xhr.responseText);
|
|
toastr.error('خطا هنگام برقراری ارتباط با سرور !!!');
|
|
$("#SaveBtn").attr("onclick", "Login()");
|
|
}).always(function () {
|
|
$("#SaveBtn").css("opacity", 1);
|
|
});
|
|
}
|
|
}
|
|
|
|
function Submit() {
|
|
var Phone = $("#txtPhone").val();
|
|
var Code = $("#txtCode").val();
|
|
if (Code.length == 5) {
|
|
$.post("../api/User/CheckCode", { Phone: Phone, Code: Code }, function (data) {
|
|
if (data.Status == "Success") {
|
|
//$("#SaveBtn").attr("onclick", "");
|
|
$.get("@Url.Action("Complete", "Panel")", { User: data.Id, Token: data.Token, Phone: Phone })
|
|
.done(function () {
|
|
toastr.success('ورود با موفقیت انجام شد !!!');
|
|
setTimeout(function () {
|
|
if (Return == '') {
|
|
location.href = "Index";
|
|
} else {
|
|
location.href = Return;
|
|
}
|
|
}, 2500);
|
|
})
|
|
.fail(function (xhr, status, error) {
|
|
// Handle error here
|
|
console.error("Request failed: ", status, error);
|
|
toastr.error('There was an error while processing your request.');
|
|
});
|
|
}
|
|
else {
|
|
|
|
toastr.error('کد وارد شده صحیح نمی باشد');
|
|
}
|
|
}).fail(function () {
|
|
|
|
toastr.error('خطا هنگام برقراری ارتباط با سرور !!!');
|
|
}).always(function () {
|
|
});
|
|
} else {
|
|
|
|
toastr.error('کد تایید را وارد کنید.');
|
|
}
|
|
}
|
|
</script>
|
|
} |