login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="login">
  3. <div class="box">
  4. <div class="title">{{lang.title}}</div>
  5. <div class="title">Welcome To Login</div>
  6. <div class="form">
  7. <el-input style="margin-top: 20px" v-model="account" :placeholder="lang.inputs[0]"></el-input>
  8. <el-input style="margin-top: 20px" type="password" v-model="password" :placeholder="lang.inputs[1]"></el-input>
  9. <div class="form_foot">
  10. <el-checkbox v-model="remenberPassword">{{lang.foot[0]}}</el-checkbox>
  11. <span>{{lang.foot[1]}}</span>
  12. </div>
  13. </div>
  14. <el-button type="primary" class="submit" :loading="submitting" @click="submit">{{lang.submit}}</el-button>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'login',
  21. data (){
  22. return {
  23. lang: {},
  24. account: '',
  25. password: '',
  26. remenberPassword: true,
  27. submitting: false
  28. }
  29. },
  30. created (){
  31. // 多语言支持
  32. this.lang = this.$lang('login');
  33. },
  34. methods: {
  35. // 提交登录
  36. submit (){
  37. // 表单验证
  38. if(this.account == ''){
  39. this.$message.warning(this.lang.tips.form.account);
  40. return;
  41. }
  42. if(this.password == ''){
  43. this.$message.warning(this.lang.tips.form.passwd);
  44. return;
  45. }
  46. // 登录请求
  47. this.submitting = true;
  48. this.$ajax.post('/user/login', {
  49. account: this.account,
  50. password: this.password
  51. }).then(r => {
  52. localStorage.setItem('designer_user', JSON.stringify(r));
  53. this.$router.push('/');
  54. }).catch(() => {
  55. this.submitting = false;
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="less" scoped>
  62. @import url('../tools/common.less');
  63. .login{
  64. width: 100%;
  65. height: 100%;
  66. position: absolute;
  67. background: url('@{imgurl}/img/login-bg.jpg') #ffffff;
  68. background-size: cover;
  69. background-position: center center;
  70. .box{
  71. width: 600px;
  72. height: calc(100% - 120px);
  73. padding-top: 120px;
  74. position: absolute;
  75. top: 0;
  76. right: 0;
  77. background: #ffffff;
  78. box-shadow: 0 0 30px 0 rgba(65, 95, 217, 0.3);
  79. .title{
  80. width: 400px;
  81. margin: 10px auto;
  82. font-size: 30px;
  83. color: #555555;
  84. }
  85. .form{
  86. width: 400px;
  87. margin: 100px auto;
  88. input{
  89. width: 100%;
  90. margin: 10px 0;
  91. }
  92. .form_foot{
  93. width: 100%;
  94. display: flex;
  95. margin-top: 10px;
  96. justify-content: space-between;
  97. color: #666666;
  98. span{
  99. cursor: pointer;
  100. }
  101. }
  102. }
  103. .submit{
  104. width: 400px;
  105. display: block;
  106. margin: 0 auto;
  107. }
  108. }
  109. }
  110. </style>