Login.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. @{
  2. ViewData["Title"] = "Login";
  3. Layout = "~/Views/Shared/_NothingLayout.cshtml";
  4. }
  5. @using LotteryWebApp.Languages;
  6. @using LotteryWebApp.Controllers;
  7. @using LotteryWebApp.Common;
  8. @model AccountLogin_ViewModel
  9. <style>
  10. input {
  11. font-size: 2em;
  12. }
  13. input:placeholder-shown {
  14. font-size: 1em !important;
  15. }
  16. </style>
  17. @{
  18. if(Model.message != null)
  19. {
  20. <script>
  21. toastr.error('@Model.message');
  22. </script>
  23. }
  24. }
  25. <div class="app-content content">
  26. @{
  27. //if (Model.step == Constants.LOGIN_ENTER_OTP)
  28. //{
  29. // <div class="card-title text-center ">
  30. // <div class="news-button-header-container" style="text-align: start; margin: 0 10px;">
  31. // @await Component.InvokeAsync("SmallHeader", new { title = @Lang.confirm_otp})
  32. // </div>
  33. // </div>
  34. //}
  35. }
  36. <div class="content-wrapper">
  37. <div class="content-header row">
  38. </div>
  39. <div class="content-body">
  40. <section class="flexbox-container">
  41. <div class="col-12 align-items-center justify-content-center">
  42. <div class="">
  43. <div class="lottery-msisdn-box-container">
  44. @{
  45. if (Model.step == Constants.LOGIN_ENTER_MSISDN)
  46. {
  47. <style>
  48. input {
  49. font-size: 16px;
  50. }
  51. input[type="text"]:focus,
  52. input[type="number"]:focus,
  53. input[type="email"]:focus,
  54. input[type="tel"]:focus,
  55. input[type="password"]:focus {
  56. font-size: 16px;
  57. }
  58. </style>
  59. <div class="card-header border-0 card-box">
  60. <div class="card-title text-center ">
  61. <div>
  62. <div style=" margin-top: 50px;">
  63. <img class="logo-app logo-start" src="~/img/Group 83968 (1).png" />
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <fieldset class="form-group position-relative has-icon-left lottery-msisdn-container" style=" margin: 100px 30px 20px 30px;">
  69. <input type="number" class="data-input-box form-control lottery-msisdn-input" id="phonenumber" style="border-radius: 5px; padding-left: calc(4.75rem + 2px)"
  70. placeholder="@Lang.enter_phone_number" name="phonenumber" required>
  71. <div class="form-control-position lottery-msisdn-box">
  72. <a href="#" class="">+509</a>
  73. </div>
  74. </fieldset>
  75. }
  76. }
  77. @{
  78. if (Model.step == Constants.LOGIN_ENTER_OTP)
  79. {
  80. <div class="lottery-des-container">
  81. <h2>@Lang.verify_otp</h2>
  82. <h4>@Lang.enter_otp_to_login</h4>
  83. </div>
  84. <style>
  85. input[type="text"]:focus,
  86. input[type="number"]:focus,
  87. input[type="email"]:focus,
  88. input[type="tel"]:focus,
  89. input[type="password"]:focus {
  90. font-size: 25px;
  91. }
  92. [placeholder]:focus::-webkit-input-placeholder {
  93. transition: opacity 0.5s 0.0s ease;
  94. opacity: 0;
  95. }
  96. </style>
  97. <div class="lottery-otp-container" style=" margin: 30px; margin-right: 30px;">
  98. <form action="/verify-otp" method="POST">
  99. <input class="lottery-otp-box otp-box-0" pattern="\d{1}" inputmode="numeric" name="lottery-otp-box" size="1" autofocus="autofocus" type="text" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" maxlength="1" />
  100. <input class="lottery-otp-box otp-box-1" pattern="\d{1}" inputmode="numeric" name="lottery-otp-box" size="1" autofocus="autofocus" type="text" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" maxlength="1" />
  101. <input class="lottery-otp-box otp-box-2" pattern="\d{1}" inputmode="numeric" name="lottery-otp-box" size="1" autofocus="autofocus" type="text" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" maxlength="1" />
  102. <input class="lottery-otp-box otp-box-3" pattern="\d{1}" inputmode="numeric" name="lottery-otp-box" size="1" autofocus="autofocus" type="text" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" maxlength="1" />
  103. </form>
  104. </div>
  105. //<input type="text"
  106. // inputmode="numeric"
  107. // autocomplete="one-time-code"
  108. // pattern="\d{6}"
  109. // required>
  110. <script>
  111. var container = document.getElementsByClassName("lottery-otp-container")[0];
  112. container.onkeyup = function(e) {
  113. var target = e.srcElement;
  114. var maxLength = parseInt(target.attributes["maxlength"].value, 10);
  115. var myLength = target.value.length;
  116. if (myLength >= maxLength) {
  117. var next = target;
  118. while (next = next.nextElementSibling) {
  119. if (next == null)
  120. break;
  121. if (next.tagName.toLowerCase() == "input") {
  122. next.focus();
  123. break;
  124. }
  125. }
  126. }
  127. }
  128. $(document).ready(function(){
  129. $('body').on('keyup', 'input.lottery-otp-box', function(e){
  130. var inputs = $('input.lottery-otp-box');
  131. if(e.keyCode == 8){
  132. var index = inputs.index(this);
  133. if (index != 0)
  134. inputs.eq(index - 1).val('').focus();
  135. }
  136. else{
  137. if($(this).val().length === this.size){
  138. inputs.eq(inputs.index(this) + 1).focus();
  139. }
  140. }
  141. });
  142. });
  143. if ('OTPCredential' in window) {
  144. window.addEventListener('DOMContentLoaded', e => {
  145. //const input = document.querySelector('input[autocomplete="one-time-code"]');
  146. if (!input) return;
  147. // Cancel the Web OTP API if the form is submitted manually.
  148. const ac = new AbortController();
  149. const form = input.closest('form');
  150. if (form) {
  151. form.addEventListener('submit', e => {
  152. // Cancel the Web OTP API.
  153. ac.abort();
  154. });
  155. }
  156. // Invoke the Web OTP API
  157. navigator.credentials.get({
  158. otp: { transport:['sms'] },
  159. signal: ac.signal
  160. }).then(otp => {
  161. //input.value = otp.code;
  162. console.log("otp.code: " + otp.code);
  163. const myArray = text.split("");
  164. $(".otp-box-0").val(myArray[0]);
  165. $(".otp-box-1").val(myArray[1]);
  166. $(".otp-box-2").val(myArray[2]);
  167. $(".otp-box-3").val(myArray[3]);
  168. // Automatically submit the form when an OTP is obtained.
  169. if (form) form.submit();
  170. }).catch(err => {
  171. console.log(err);
  172. });
  173. });
  174. }
  175. </script>
  176. }
  177. }
  178. <span class="text-danger"></span>
  179. <div style="margin: 10px 30px;">
  180. <button type="submit" class="btn btn-outline-primary btn-block login-button login-button-action"
  181. onclick="@(Model.step == Constants.LOGIN_ENTER_MSISDN ? "loginRedirect_Click()" : "loginButtonAction_Click()")">
  182. <i class="ft-unlock"></i>@(Model.step == null ? Lang.get_otp1.ToUpper() : Lang.confirm.ToUpper())
  183. </button>
  184. </div>
  185. @{
  186. if (Model.step == Constants.LOGIN_ENTER_OTP)
  187. {
  188. <div style="text-align: center; margin-top: 30px;">
  189. <h4 style="color:black;">@Lang.not_get_otp <a style="font-weight:900;" onclick="resentOTP_Action()">@Lang.resend_otp</a></h4>
  190. </div>
  191. }
  192. else
  193. {
  194. <div>
  195. @await Component.InvokeAsync("FooterOutside", new { })
  196. </div>
  197. }
  198. }
  199. </div>
  200. </div>
  201. </div>
  202. </section>
  203. </div>
  204. </div>
  205. </div>
  206. @*<script type="text/javascript">
  207. function createAccountClick(message) {
  208. toastr.options.timeOut = 5000; // 1.5s
  209. toastr.error(message);
  210. }
  211. </script>*@