Login.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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="text" class="data-input-box form-control lottery-msisdn-input" id="phonenumber"
  70. style="border-radius: 5px; padding-left: calc(4.75rem + 2px)"
  71. inputmode="numeric" pattern="\d{0,11}" maxlength="11"
  72. placeholder="@Lang.enter_phone_number" name="phonenumber" required>
  73. <div class="form-control-position lottery-msisdn-box">
  74. <a href="#" class="">+@Constants.COUNTRY_CODE</a>
  75. </div>
  76. </fieldset>
  77. }
  78. }
  79. @{
  80. if (Model.step == Constants.LOGIN_ENTER_OTP)
  81. {
  82. <div class="lottery-des-container">
  83. <h2>@Lang.verify_otp</h2>
  84. <h4>@Lang.enter_otp_to_login</h4>
  85. </div>
  86. <style>
  87. input[type="text"]:focus,
  88. input[type="number"]:focus,
  89. input[type="email"]:focus,
  90. input[type="tel"]:focus,
  91. input[type="password"]:focus {
  92. font-size: 25px;
  93. }
  94. [placeholder]:focus::-webkit-input-placeholder {
  95. transition: opacity 0.5s 0.0s ease;
  96. opacity: 0;
  97. }
  98. </style>
  99. <div class="lottery-otp-container" style=" margin: 30px; margin-right: 30px;">
  100. <form action="/verify-otp" method="POST">
  101. <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" />
  102. <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" />
  103. <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" />
  104. <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" />
  105. </form>
  106. </div>
  107. //<input type="text"
  108. // inputmode="numeric"
  109. // autocomplete="one-time-code"
  110. // pattern="\d{6}"
  111. // required>
  112. <script>
  113. var container = document.getElementsByClassName("lottery-otp-container")[0];
  114. container.onkeyup = function(e) {
  115. var target = e.srcElement;
  116. var maxLength = parseInt(target.attributes["maxlength"].value, 10);
  117. var myLength = target.value.length;
  118. if (myLength >= maxLength) {
  119. var next = target;
  120. while (next = next.nextElementSibling) {
  121. if (next == null)
  122. break;
  123. if (next.tagName.toLowerCase() == "input") {
  124. next.focus();
  125. break;
  126. }
  127. }
  128. }
  129. }
  130. $(document).ready(function(){
  131. $('body').on('keyup', 'input.lottery-otp-box', function(e){
  132. var inputs = $('input.lottery-otp-box');
  133. if(e.keyCode == 8){
  134. var index = inputs.index(this);
  135. if (index != 0)
  136. inputs.eq(index - 1).val('').focus();
  137. }
  138. else{
  139. if($(this).val().length === this.size){
  140. inputs.eq(inputs.index(this) + 1).focus();
  141. }
  142. }
  143. });
  144. });
  145. if ('OTPCredential' in window) {
  146. window.addEventListener('DOMContentLoaded', e => {
  147. //const input = document.querySelector('input[autocomplete="one-time-code"]');
  148. if (!input) return;
  149. // Cancel the Web OTP API if the form is submitted manually.
  150. const ac = new AbortController();
  151. const form = input.closest('form');
  152. if (form) {
  153. form.addEventListener('submit', e => {
  154. // Cancel the Web OTP API.
  155. ac.abort();
  156. });
  157. }
  158. // Invoke the Web OTP API
  159. navigator.credentials.get({
  160. otp: { transport:['sms'] },
  161. signal: ac.signal
  162. }).then(otp => {
  163. //input.value = otp.code;
  164. console.log("otp.code: " + otp.code);
  165. const myArray = text.split("");
  166. $(".otp-box-0").val(myArray[0]);
  167. $(".otp-box-1").val(myArray[1]);
  168. $(".otp-box-2").val(myArray[2]);
  169. $(".otp-box-3").val(myArray[3]);
  170. // Automatically submit the form when an OTP is obtained.
  171. if (form) form.submit();
  172. }).catch(err => {
  173. console.log(err);
  174. });
  175. });
  176. }
  177. </script>
  178. }
  179. }
  180. <span class="text-danger"></span>
  181. <div style="margin: 10px 30px;">
  182. <button type="submit" class="btn btn-outline-primary btn-block login-button login-button-action"
  183. onclick="@(Model.step == Constants.LOGIN_ENTER_MSISDN ? "loginRedirect_Click()" : "loginButtonAction_Click()")">
  184. <i class="ft-unlock"></i>@(Model.step == null ? Lang.get_otp1.ToUpper() : Lang.confirm.ToUpper())
  185. </button>
  186. </div>
  187. @{
  188. if (Model.step == Constants.LOGIN_ENTER_OTP)
  189. {
  190. <div style="text-align: center; margin-top: 30px;">
  191. <h4 style="color:black;">@Lang.not_get_otp <a style="font-weight:900;" onclick="resentOTP_Action()">@Lang.resend_otp</a></h4>
  192. </div>
  193. }
  194. else
  195. {
  196. <div>
  197. @await Component.InvokeAsync("FooterOutside", new { })
  198. </div>
  199. }
  200. }
  201. </div>
  202. </div>
  203. </div>
  204. </section>
  205. </div>
  206. </div>
  207. </div>
  208. @*<script type="text/javascript">
  209. function createAccountClick(message) {
  210. toastr.options.timeOut = 5000; // 1.5s
  211. toastr.error(message);
  212. }
  213. </script>*@