InputLicense.cshtml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. @model string;
  2. <html>
  3. @{
  4. Layout = null;
  5. }
  6. <head>
  7. <link rel="stylesheet" href="~/css/licensing.css" />
  8. <link rel="stylesheet" href="~/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 apis = new Map();
  40. $(document).ready(function () {
  41. var requestData = ["webapi", ["LicensingApp"]];
  42. var serviceUrl = "http://localhost:8384/u/?apitype=service&an=ShowMeApi&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  43. $.ajax({
  44. url: serviceUrl,
  45. datatype: "application/json",
  46. type: 'post',
  47. contentType: "application/json;charset=utf-8;",
  48. data: JSON.stringify(requestData),
  49. beforeSend: function () {
  50. },
  51. success: function (data) {
  52. console.log(data);
  53. data.forEach(function (d) {
  54. if (apis.has(d.ApiName)) {
  55. apis.delete(d.ApiName);
  56. }
  57. apis.set(d.ApiName, d.Path);
  58. });
  59. },
  60. error: function (err) {
  61. console.log(err);
  62. }
  63. });
  64. });
  65. function saveLicense(license) {
  66. var path = apis.has("VerifyLicense") ? apis.get("VerifyLicense") : "";
  67. if (path === "") return;
  68. //var requestUrl = "http://localhost:8384/u/?apitype=service&an=VerifyLicense&pn=" + processorName
  69. // + "&en=Application.LicensingApp.App";
  70. var requestUrl = "http://localhost:8384" + path;
  71. $.ajax({
  72. url: requestUrl,
  73. datatype: "application/json",
  74. type: 'post',
  75. contentType: "application/json;charset=utf-8;",
  76. data: JSON.stringify(license),
  77. beforeSend: function () {
  78. },
  79. success: function (data) {
  80. if (data == true) {
  81. //window.location.href = '@Url.Action("SaveLicense", "Home")?license=' + license;
  82. $("#reboot_msg").modal({
  83. fadeDuration: 100
  84. });
  85. disableInputForm();
  86. }
  87. else {
  88. $("#code_error").modal({
  89. fadeDuration: 100
  90. });
  91. }
  92. },
  93. error: function (err) {
  94. console.log(err);
  95. }
  96. });
  97. }
  98. function check(form) {
  99. if (form.authCode.value != "") {
  100. saveLicense(form.authCode.value);
  101. } else {
  102. $("#code_error").modal({
  103. fadeDuration: 100
  104. });
  105. }
  106. }
  107. function disableInputForm() {
  108. document.getElementById("input_box").disabled = true;
  109. document.getElementById("ok_button").disabled = true;
  110. }
  111. </script>
  112. <script src="~/js/jQuery3.js"></script>
  113. <script src="~/js/modalBox.js"></script>
  114. </body>
  115. </html>