test.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Layui</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <link rel="stylesheet" href="layui/css/layui.css" media="all">
  10. <link rel="stylesheet" href="css/index.css" media="all">
  11. </head>
  12. <body>
  13. <div class="layui-fluid container">
  14. <div class="layui-row top">
  15. <div class="layui-col-lg12">
  16. </div>
  17. </div>
  18. <div class="layui-row layui-col-space10 content">
  19. <div class="layui-col-lg3 item">
  20. <div class="task">
  21. </div>
  22. </div>
  23. <div class="layui-col-lg6 item">
  24. <div class="task" id="XScannerContainer">
  25. </div>
  26. </div>
  27. <div class="layui-col-lg3 item">
  28. <div class="task">
  29. <button type="button" class="layui-btn layui-btn-normal" onclick="OpenDwSource()">开始扫描</button>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="layui-row">
  34. <div class="layui-col-lg12 bottom"></div>
  35. </div>
  36. </div>
  37. <script src="js/xscan.js" charset="utf-8"></script>
  38. <!-- 注意:如果你直接复制所有代码到本地,上述 JS 路径需要改成你本地的 -->
  39. <script>
  40. layui.use(['form'], function () {
  41. var form = layui.form
  42. layer = layui.layer
  43. //自定义验证规则
  44. form.verify({
  45. username: function (value) {
  46. console.log(value)
  47. if (value.length < 1) {
  48. return '请输入用户名!';
  49. }
  50. }
  51. , password: [
  52. /^[\S]{6,12}$/
  53. , '密码必须6到12位,且不能出现空格!'
  54. ]
  55. });
  56. //监听提交
  57. form.on('submit(login)', function (data) {
  58. var data = form.val("login")
  59. LayuiPostJson({
  60. url: LOGINAPI,
  61. data: data
  62. }).then(res => {
  63. localStorage.setItem("token",res.access_token)
  64. }).catch(err => {
  65. layer.msg("账号或密码错误!")
  66. })
  67. return false;
  68. });
  69. });
  70. </script>
  71. </body>
  72. </html>