Login.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div>
  3. <login-top Text="登录">
  4. <div slot="right" style="font-size:3.611vw" @click="$router.push('/register')">用户注册</div>
  5. </login-top>
  6. <div class="login_img" style="width: 100%;height: 100%;">
  7. <img src="../assets/img/pic_dlbg.png" alt="" style="width: 100%; height: 100%;">
  8. </div>
  9. <div class="login_dl">
  10. 登录
  11. </div>
  12. <div class="user_name">
  13. <p>用户名</p>
  14. <p><input type="text" placeholder="请输入用户名"></p>
  15. </div>
  16. <div class="user_name">
  17. <p>密码</p>
  18. <p><input type="text" placeholder="请输入密码"></p>
  19. </div>
  20. <!-- <login-text label="用户名"
  21. placeholder="请输入用户名"
  22. @contentWatch="res => model.username = res"
  23. style="margin:4.167vw 0"
  24. >
  25. </login-text>
  26. <login-text label="密码"
  27. placeholder="请输入密码"
  28. type="password"
  29. @contentWatch="res => model.password = res"
  30. >
  31. </login-text> -->
  32. <login-btn BtnText="登录" @TextClick="AjaxInsert"></login-btn>
  33. </div>
  34. </template>
  35. <script>
  36. import LoginTop from '@/components/common/LoginTop.vue'
  37. import LoginText from '@/components/common/LoginText.vue'
  38. import LoginBtn from '@/components/common/LoginBtn.vue'
  39. export default {
  40. data() {
  41. return {
  42. model:{}
  43. }
  44. },
  45. components:{
  46. LoginTop,
  47. LoginText,
  48. LoginBtn
  49. },
  50. methods:{
  51. async AjaxInsert() {
  52. let rulg = /^.{6,16}$/
  53. if(rulg.test(this.model.username)&&rulg.test(this.model.password)){
  54. const res = await this.$http.post('/login',this.model)
  55. this.$msg.fail(res.data.msg)
  56. if(res.data.code == 301 || res.data.code == 302){
  57. return
  58. }
  59. localStorage.setItem('token',res.data.token)
  60. localStorage.setItem('id',res.data.id)
  61. setTimeout(() => {
  62. this.$router.push('/userinfo')
  63. },1000)
  64. }else{
  65. this.$msg.fail('格式不正确,请重新输入!')
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="less">
  72. .login_img{
  73. // height: 100vh;
  74. // background: url('../assets/img/pic_dlbg.png');
  75. position: fixed;
  76. z-index: -1;
  77. }
  78. .login_dl{
  79. font-size: 25px;
  80. font-family: PingFang SC;
  81. font-weight: 800;
  82. color: #009FE8;
  83. line-height: 13px;
  84. margin-left: 50%;
  85. transform: translateX(-50%);
  86. text-align: center;
  87. margin-top: 232px;
  88. margin-bottom: 30px;
  89. }
  90. .user_name{
  91. padding: 34px;
  92. padding-top: 0;
  93. padding-bottom: 0;
  94. margin-bottom: 30px;
  95. p:nth-child(1){
  96. font-size: 14px;
  97. font-family: PingFang SC;
  98. font-weight: 400;
  99. color: #343434;
  100. margin-bottom: 10px;
  101. }
  102. p:nth-child(2){
  103. border-bottom: 1px solid #009FE8;
  104. input{
  105. font-size: 14px;
  106. margin-bottom: 4.999px;
  107. }
  108. }
  109. input{
  110. background:none;
  111. outline:none;
  112. border:none;
  113. }
  114. }
  115. </style>