login.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5. <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
  6. <link rel="stylesheet" type="text/css" href="/static/css/login.css">
  7. <script src="/static/js/jquery.min.js"></script>
  8. <script src="/static/js/bootstrap.min.js"></script>
  9. <script src="/static/js/vue-2.4.0.js"></script>
  10. <script src="/static/js/axios.min.js"></script>
  11. <script type="text/javascript" src="/static/js/jquery.select.js"></script>
  12. <title>Document</title>
  13. </head>
  14. <body>
  15. <div class="container container-small" id="app">
  16. <h1>登录
  17. <small>忘记密码?<a href="" onclick="return false;" data-toggle="modal" data-target="#myModal">修改密码</a></small>
  18. </h1>
  19. <div class="form-group">
  20. <label for="user1">用户名</label>
  21. <input type="text" class="form-control" id="user1" >
  22. </div>
  23. <div class="form-group">
  24. <label>密码</label>
  25. <input type="password" class="form-control" v-model="pswd">
  26. </div>
  27. <div class="form-group">
  28. <button type="submit" class="btn btn-primary submit" @click="login">登录</button>
  29. </div>
  30. </div>
  31. <div class="modal fade" id="myModal">
  32. <div class="modal-dialog">
  33. <div class="modal-content" style="width: 65%;">
  34. <div class="modal-header">
  35. <div class="modal-title">修改密码</div>
  36. </div>
  37. <div class="modal-body">
  38. <div class="form-group">
  39. <label for="user2">用户名</label>
  40. <input type="text" class="form-control upinput" id="user2" autocomplete="off">
  41. </div>
  42. <div class="form-group">
  43. <label for="pswd">旧密码</label>
  44. <input type="password" class="form-control upinput" name="aa" id="oldpswd">
  45. </div>
  46. <div class="form-group">
  47. <label for="pswd">新密码</label>
  48. <input type="password" class="form-control upinput" name="aa" id="oldpswd">
  49. </div>
  50. </div>
  51. <div class="modal-footer">
  52. <button class="btn btn-primary" data-dismiss="modal">确定</button>
  53. <button class="btn btn-primary" data-dismiss="modal">取消</button>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <script>
  59. var vm = new Vue({
  60. el: '#app',
  61. data: {
  62. up_time: '',
  63. user_1:'',
  64. user_2:'',
  65. pswd:'',
  66. pswd_old:'',
  67. pswd_new:'',
  68. },
  69. methods: {
  70. login() {
  71. console.log($("#user1").val())
  72. this.user_1 = $("#user1").val()
  73. axios.post('/login/', {
  74. params: {
  75. user_1: this.user_1,
  76. pswd: this.pswd,
  77. }
  78. })
  79. .then(res => {
  80. // alert(res.data)
  81. var data1 = res.data
  82. console.log(data1)
  83. })
  84. .catch(err => {
  85. console.log(err.response["data"] + err.response["status"])
  86. })
  87. },
  88. },
  89. created() {
  90. }
  91. });
  92. $(function () {
  93. // 开始写 jQuery 代码...
  94. var timer = null;
  95. // 定义一个公用的搜索接口
  96. function getStr(n, url, field, clickif) {
  97. //n为搜索的参数 url为请求的路由,filed是定位表单的id,
  98. //clickif用于判断是否是第一次加载,如果不是第一次加载则需要模拟点击
  99. var search = n
  100. // 配置路由
  101. if (typeof search === 'undefined') {
  102. search = ''
  103. };
  104. console.log(search)
  105. axios.get(url, {
  106. params: {
  107. search_no: search
  108. }
  109. })
  110. .then(res => {
  111. // alert(res.data)
  112. var data1 = res.data.data
  113. datas = data1
  114. console.log(datas)
  115. if (datas.length == 0) {
  116. alert("没有搜索到数据")
  117. return
  118. }
  119. $.selectSuggest(field, datas);
  120. // 是否第一次进入
  121. if (clickif !== 1) {
  122. $("#" + field).trigger("click");
  123. }
  124. })
  125. .catch(err => {
  126. console.log('error:' + err)
  127. })
  128. };
  129. //登录时获取用户信息
  130. $("#user1").bind("input propertychange", function (event) {
  131. var search = $("#user1").val()
  132. console.log($("#user1").val())
  133. timer && clearTimeout(timer);
  134. timer = setTimeout(function () {
  135. getStr(search, '/logininformation/', 'user1');
  136. }, 2000);
  137. });
  138. getStr('', '/logininformation/', 'user1', 1);
  139. //修改密码时获取用户信息
  140. $("#user2").bind("input propertychange", function (event) {
  141. var search = $("#user2").val()
  142. console.log($("#user2").val())
  143. timer && clearTimeout(timer);
  144. timer = setTimeout(function () {
  145. getStr(search, '/logininformation/', 'user2');
  146. }, 2000);
  147. });
  148. });
  149. </script>
  150. </body>
  151. </html>