Login.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <style lang="scss">
  2. @import '../style/_base.scss';
  3. .login{
  4. height: 100vh;
  5. min-height: 450px;
  6. background: url(../assets/bg.png) 100%;
  7. background-position: center bottom;
  8. // background: #1F315D;
  9. position: relative;
  10. .login-div{
  11. width:520px;
  12. height:448px;
  13. background:#FFFFFF;
  14. box-shadow:0px 12px 24px 0px rgba(0,0,0,0.24);
  15. border-radius:8px;
  16. position: absolute;
  17. top: 0;
  18. bottom: 0;
  19. left: 0;
  20. right: 0;
  21. margin: auto;
  22. padding:48px 75px;
  23. h1{
  24. text-align: center;
  25. margin-bottom: 40px;
  26. font-size: 28px;
  27. }
  28. .input_div{
  29. position: relative;
  30. margin-bottom: 12px;
  31. input{
  32. padding-left: 80px;
  33. outline: none;
  34. background:rgba(242,245,247,1);
  35. border-radius:8px;
  36. border:1px solid rgba(238,238,238,1);
  37. display: block;
  38. height: 54px;
  39. width: 100%;
  40. font-size: 16px;
  41. }
  42. label{
  43. color: #222;
  44. font-size: 16px;
  45. position: absolute;
  46. left: 16px;
  47. top:16px;
  48. z-index: 99;
  49. }
  50. }
  51. .code{
  52. input{
  53. width: 250px;
  54. }
  55. img{
  56. width: 108px;
  57. height: 54px;
  58. float: right;
  59. background-origin: 1px solid red;
  60. }
  61. }
  62. .login-btn{
  63. background: #066FE6;
  64. width: 100%;
  65. height: 54px;
  66. margin-top: 36px;
  67. font-size: 18px;
  68. color: #FFF;
  69. font-weight: 600;
  70. border:none;
  71. border-radius: 8px;
  72. }
  73. }
  74. }
  75. </style>
  76. <template>
  77. <div class="login">
  78. <div class="login-div">
  79. <h1>巴中逸沣安全培训</h1>
  80. <form>
  81. <div class="input_div">
  82. <label>用户名</label>
  83. <input type="text" v-model="logindata.username" placeholder="请输入用户名">
  84. </div>
  85. <div class="input_div">
  86. <label>密&nbsp;&nbsp;码</label>
  87. <input type="password" v-model="logindata.password" placeholder="请输入密码">
  88. </div>
  89. <div class="input_div code">
  90. <img @click="getCode" :src="code" alt="">
  91. <label>图形码</label>
  92. <input type="text" v-model="logindata.imgcode" placeholder="请输入验证码">
  93. </div>
  94. <el-button @click="login" class="login-btn" type="primary">登 录</el-button>
  95. </form>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. // import { Base64 } from 'js-base64';
  101. export default {
  102. name: 'login',
  103. data(){
  104. return{
  105. code:'',
  106. logindata:{
  107. username:'',
  108. password:'',
  109. imgcode_id:'',
  110. imgcode:''
  111. }
  112. }
  113. },
  114. methods:{
  115. login(){
  116. let parms=this.logindata;
  117. this.$api.login(parms).then((res)=>{
  118. let data=res.data
  119. if(res.data.code == 0){
  120. window.location.hash='/';
  121. }else{
  122. this.$message.error(res.data.message);
  123. }
  124. })
  125. .catch(err=>{
  126. this.$message.error(res.data.message);
  127. })
  128. },
  129. getCode(){
  130. this.$api.getCode().then(res=>{
  131. this.code=res.data.data.ubase64
  132. this.logindata.imgcode_id=res.data.data.captcha_id
  133. })
  134. }
  135. },
  136. created(){
  137. this.getCode();
  138. }
  139. }
  140. </script>