Login.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <style lang="scss">
  2. @import '../style/_base.scss';
  3. .xt_login{
  4. background: url(../images/bg.png) no-repeat;
  5. }
  6. .zf_login{
  7. background: url(../images/bg.png) no-repeat;
  8. }
  9. .login{
  10. height: 100vh;
  11. min-height: 450px;
  12. background: url(../images/bg.png) no-repeat;
  13. background-size: 100%;
  14. background-position: center top;
  15. // background: #1F315D;
  16. position: relative;
  17. .login-div{
  18. width:520px;
  19. height:448px;
  20. background:#FFFFFF;
  21. box-shadow:0px 12px 24px 0px rgba(0,0,0,0.24);
  22. border-radius:8px;
  23. position: absolute;
  24. top: 0;
  25. bottom: 0;
  26. left: 0;
  27. right: 0;
  28. margin: auto;
  29. padding:48px 75px;
  30. h1{
  31. text-align: center;
  32. margin-bottom: 40px;
  33. font-size: 28px;
  34. }
  35. .input_div{
  36. position: relative;
  37. margin-bottom: 12px;
  38. input{
  39. padding-left: 80px;
  40. outline: none;
  41. background:rgba(242,245,247,1);
  42. border-radius:8px;
  43. border:1px solid rgba(238,238,238,1);
  44. display: block;
  45. height: 54px;
  46. width: 100%;
  47. font-size: 16px;
  48. }
  49. label{
  50. color: #222;
  51. font-size: 16px;
  52. position: absolute;
  53. left: 16px;
  54. top:16px;
  55. z-index: 99;
  56. }
  57. }
  58. .code{
  59. input{
  60. width: 250px;
  61. }
  62. img{
  63. width: 108px;
  64. height: 54px;
  65. float: right;
  66. background-origin: 1px solid red;
  67. }
  68. }
  69. .login-btn{
  70. background: #FF694B;
  71. width: 100%;
  72. height: 54px;
  73. margin-top: 36px;
  74. font-size: 18px;
  75. color: #FFF;
  76. font-weight: 600;
  77. border:none;
  78. border-radius: 8px;
  79. }
  80. }
  81. .footer{
  82. position: fixed;
  83. width: 100%;
  84. bottom: 10px;
  85. left:0;
  86. z-index: 9;
  87. text-align: center;
  88. color:#333;
  89. font-size: 12px;
  90. }
  91. }
  92. </style>
  93. <template>
  94. <div class="login">
  95. <div class="login-div">
  96. <h1>综合风险防控平台</h1>
  97. <form>
  98. <div class="input_div">
  99. <label>用户名</label>
  100. <input type="text" v-model="logindata.username" placeholder="请输入用户名">
  101. </div>
  102. <div class="input_div">
  103. <label>密&nbsp;&nbsp;码</label>
  104. <input type="password" v-model="logindata.password" placeholder="请输入密码">
  105. </div>
  106. <div class="input_div code">
  107. <img @click="getCode" :src="code" alt="">
  108. <label>图形码</label>
  109. <input type="text" v-model="logindata.imgcode" placeholder="请输入验证码">
  110. </div>
  111. <el-button @click="login" @keyup.enter="login" class="login-btn" type="primary">登 录</el-button>
  112. </form>
  113. </div>
  114. <p class="footer">四川百安兮注册安全工程师事务有限公司提供技术支持</p>
  115. </div>
  116. </template>
  117. <script>
  118. export default {
  119. name: 'login',
  120. data(){
  121. return{
  122. tp:'xt',
  123. code:'',
  124. logindata:{
  125. username:'root',
  126. password:'root',
  127. imgcode_id:'',
  128. imgcode:'',
  129. utype:2
  130. }
  131. }
  132. },
  133. methods:{
  134. keyupEnter(){
  135. document.onkeydown = e =>{
  136. if (e.keyCode === 13) {
  137. console.log('enter')
  138. this.login()
  139. }
  140. }
  141. },
  142. login(){
  143. let parms=this.logindata;
  144. this.$api.login(parms).then((res)=>{
  145. let data=res.data
  146. if(res.data.code == 0){
  147. if(data.data.utype == 0){
  148. window.location.hash='/';
  149. }
  150. if(data.data.utype == 1){
  151. window.location.hash='/govermentData';
  152. }
  153. if(data.data.utype == 2){
  154. window.location.hash='/companyData';
  155. }
  156. localStorage.setItem('utype',res.data.data.utype);
  157. localStorage.setItem('token',res.data.data.token);
  158. }else{
  159. this.$message.error("账号或者密码有误");
  160. }
  161. })
  162. .catch(err=>{
  163. this.$message.error("账号或者密码有误");
  164. })
  165. },
  166. getCode(){
  167. this.$api.getCode().then(res=>{
  168. this.code=res.data.data.imgcode
  169. this.logindata.imgcode_id=res.data.data.imgcode_id
  170. })
  171. }
  172. },
  173. created(){
  174. this.tp = this.$route.query.tp;
  175. console.log(this.tp,this.$route.query.tp)
  176. this.getCode();
  177. this.keyupEnter();
  178. }
  179. }
  180. </script>