Login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <style lang="scss">
  2. @import '../style/_base.scss';
  3. .login{
  4. height: 100vh;
  5. min-height: 450px;
  6. background: url(../assets/bg.png) no-repeat;
  7. background-size: 100%;
  8. position: relative;
  9. .login-div{
  10. width:520px;
  11. height:448px;
  12. background:#FFFFFF;
  13. box-shadow:0px 12px 24px 0px rgba(0,0,0,0.24);
  14. border-radius:8px;
  15. position: absolute;
  16. top: 0;
  17. bottom: 0;
  18. left: 0;
  19. right: 0;
  20. margin: auto;
  21. padding:48px 75px;
  22. h1{
  23. text-align: center;
  24. margin-bottom: 40px;
  25. font-size: 28px;
  26. }
  27. .input_div{
  28. position: relative;
  29. margin-bottom: 12px;
  30. input{
  31. padding-left: 80px;
  32. outline: none;
  33. background:#F2F5F7;
  34. border-radius:8px;
  35. border:1px solid #EEEEEE;
  36. display: block;
  37. height: 54px;
  38. width: 100%;
  39. font-size: 16px;
  40. }
  41. label{
  42. color: #222;
  43. font-size: 16px;
  44. position: absolute;
  45. left: 16px;
  46. top:16px;
  47. z-index: 99;
  48. }
  49. }
  50. .code{
  51. input{
  52. width: 250px;
  53. border:1px solid #EEEEEE;
  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: #FF5151;
  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. .footer{
  75. position: fixed;
  76. width: 100%;
  77. bottom: 30px;
  78. left:0;
  79. z-index: 9;
  80. text-align: center;
  81. color:#000;
  82. font-size: 14px;
  83. font-weight: bold;
  84. }
  85. }
  86. </style>
  87. <template>
  88. <div class="login">
  89. <div class="login-div">
  90. <!-- <h1><img width="345" src="../assets/title.png" alt=""></h1> -->
  91. <h1>贝安欣PK检测管理后台</h1>
  92. <form>
  93. <div class="input_div">
  94. <label>用户名</label>
  95. <input type="text" v-model="logindata.username" placeholder="请输入用户名">
  96. </div>
  97. <div class="input_div">
  98. <label>密&nbsp;&nbsp;码</label>
  99. <input type="password" v-model="logindata.password" placeholder="请输入密码">
  100. </div>
  101. <div class="input_div code">
  102. <img @click="getCode" :src="code" alt="">
  103. <label>图形码</label>
  104. <input type="text" v-model="logindata.imgcode" placeholder="请输入验证码">
  105. </div>
  106. <el-button @click="login" @keyup.enter="login" class="login-btn" type="primary">登 录</el-button>
  107. </form>
  108. </div>
  109. <p class="footer">Copyright © {{copyrightdate}} 贝安欣 版权所有</p>
  110. </div>
  111. </template>
  112. <script>
  113. export default {
  114. name: 'login',
  115. data(){
  116. return{
  117. tp:'xt',
  118. code:'',
  119. logindata:{
  120. username:'',
  121. password:'',
  122. imgcode_id:'',
  123. imgcode:'',
  124. utype:2
  125. },
  126. copyrightdate:new Date().getFullYear()
  127. }
  128. },
  129. methods:{
  130. keyupEnter(){
  131. document.onkeydown = e =>{
  132. if (e.keyCode === 13) {
  133. console.log('enter')
  134. this.login()
  135. }
  136. }
  137. },
  138. login(){
  139. let parms=this.logindata;
  140. console.log(parms)
  141. this.$api.login(parms).then((res)=>{
  142. let data=res.data
  143. if(res.data.code == 0){
  144. window.location.hash='/doctor/list';
  145. }else{
  146. this.$message.error(res.data.message);
  147. }
  148. })
  149. },
  150. getCode(){
  151. this.$api.getCode().then(res=>{
  152. this.code=res.data.data.imgcode
  153. this.logindata.imgcode_id=res.data.data.imgcode_id
  154. })
  155. }
  156. },
  157. created(){
  158. this.getCode()
  159. }
  160. }
  161. </script>