InputLicense.cshtml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. @model string;
  2. <html>
  3. @{
  4. Layout = null;
  5. }
  6. <head>
  7. <link rel="stylesheet" href="~/WebConsole/css/licensing.css" />
  8. <link rel="stylesheet" href="~/WebConsole/css/modalBox.css">
  9. </head>
  10. <body class="container-main">
  11. <div class="container-item">
  12. <h1 class="h1">
  13. 请输入验证码
  14. </h1>
  15. <div>
  16. <form class="login">
  17. <div class="container-form">
  18. <input id="input_box" type="text" name="authCode" value="" placeholder="验证码" />
  19. <input id="ok_button" class="submit"
  20. type="button"
  21. onclick="check(this.form)"
  22. value="确 定" />
  23. </div>
  24. </form>
  25. <div class="serial-number">SN: @Model</div>
  26. </div>
  27. </div>
  28. <div id="code_error" class="modal">
  29. <p>验证码错误,请联系厂家获取!</p>
  30. <a href="#" rel="modal:close">关闭</a>
  31. </div>
  32. <div id="reboot_msg" class="modal">
  33. <p>验证通过,请重启设备!</p>
  34. <a href="#" rel="modal:close">关闭</a>
  35. </div>
  36. <script src="~/js/jquery-3.4.1.min.js"></script>
  37. <script>
  38. //will set ApiName as key,ProviderConfigName as value
  39. var currenthref = window.location.href;
  40. var currentPath = window.location.pathname;
  41. var currentHP = currenthref.slice(0, currenthref.indexOf(currentPath) + 1);
  42. var apis = new Map();
  43. $(document).ready(function () {
  44. var requestData = ["webapi", ["LicensingApp"]];
  45. var serviceUrl = currentHP+"u/?apitype=service&an=ShowMeApi&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  46. $.ajax({
  47. url: serviceUrl,
  48. datatype: "application/json",
  49. type: 'post',
  50. contentType: "application/json;charset=utf-8;",
  51. data: JSON.stringify(requestData),
  52. beforeSend: function () {
  53. },
  54. success: function (data) {
  55. console.log(data);
  56. data.forEach(function (d) {
  57. if (apis.has(d.ApiName)) {
  58. apis.delete(d.ApiName);
  59. }
  60. apis.set(d.ApiName, d.Path);
  61. });
  62. },
  63. error: function (err) {
  64. console.log(err);
  65. }
  66. });
  67. });
  68. function saveLicense(license) {
  69. var path = apis.has("VerifyLicense") ? apis.get("VerifyLicense") : "";
  70. if (path === "") return;
  71. //var requestUrl = "http://localhost:8384/u/?apitype=service&an=VerifyLicense&pn=" + processorName
  72. // + "&en=Application.LicensingApp.App";
  73. var requestUrl = currentHP.slice(0, currentHP.length-1) + path;
  74. $.ajax({
  75. url: requestUrl,
  76. datatype: "application/json",
  77. type: 'post',
  78. contentType: "application/json;charset=utf-8;",
  79. data: JSON.stringify(license),
  80. beforeSend: function () {
  81. },
  82. success: function (data) {
  83. if (data == true) {
  84. //window.location.href = '@Url.Action("SaveLicense", "Home")?license=' + license;
  85. $("#reboot_msg").modal({
  86. fadeDuration: 100
  87. });
  88. disableInputForm();
  89. }
  90. else {
  91. $("#code_error").modal({
  92. fadeDuration: 100
  93. });
  94. }
  95. },
  96. error: function (err) {
  97. console.log(err);
  98. }
  99. });
  100. }
  101. function check(form) {
  102. if (form.authCode.value != "") {
  103. saveLicense(form.authCode.value);
  104. } else {
  105. $("#code_error").modal({
  106. fadeDuration: 100
  107. });
  108. }
  109. }
  110. function disableInputForm() {
  111. document.getElementById("input_box").disabled = true;
  112. document.getElementById("ok_button").disabled = true;
  113. }
  114. </script>
  115. <script src="~/WebConsole/js/jQuery3.js"></script>
  116. <script src="~/WebConsole/js/modalBox.js"></script>
  117. </body>
  118. </html>