You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.3 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <div class="site-wrapper site-page--login">
  3. <div class="site-content__wrapper">
  4. <div class="site-content">
  5. <div class="login-main">
  6. <h3 class="login-title">用户登陆</h3>
  7. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" status-icon>
  8. <el-form-item prop="userName">
  9. <el-input v-model="dataForm.userName" placeholder="帐号"></el-input>
  10. </el-form-item>
  11. <el-form-item prop="password">
  12. <el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button class="login-btn-submit" type="primary" @click="dataFormSubmit()">登录</el-button>
  16. </el-form-item>
  17. </el-form>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { getUUID } from '@/utils'
  25. export default {
  26. data () {
  27. return {
  28. dataForm: {
  29. userName: '',
  30. password: '',
  31. uuid: '',
  32. captcha: ''
  33. },
  34. dataRule: {
  35. userName: [
  36. { required: true, message: '帐号不能为空', trigger: 'blur' }
  37. ],
  38. password: [
  39. { required: true, message: '密码不能为空', trigger: 'blur' }
  40. ]
  41. },
  42. captchaPath: ''
  43. }
  44. },
  45. created () {
  46. this.userName();
  47. },
  48. methods: {
  49. // 获取上次登陆的用户名
  50. userName(){
  51. this.dataForm.userName = localStorage.getItem('userName')
  52. },
  53. // 提交表单
  54. dataFormSubmit () {
  55. this.$refs['dataForm'].validate((valid) => {
  56. if (valid) {
  57. this.$http({
  58. url: this.$http.adornUrl('/sys/login'),
  59. method: 'post',
  60. data: this.$http.adornData({
  61. 'username': this.dataForm.userName,
  62. 'password': this.dataForm.password,
  63. 'uuid': this.dataForm.uuid
  64. })
  65. }).then(({data}) => {
  66. if (data && data.code === 0) {
  67. this.$cookie.set('token', data.token)
  68. this.$router.replace({ name: 'home' })
  69. localStorage.setItem('locale', data.language)
  70. localStorage.setItem('refresh', "0")
  71. localStorage.setItem('userName', this.dataForm.userName)
  72. } else {
  73. this.$message.error(data.msg)
  74. }
  75. })
  76. }
  77. })
  78. },
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .site-wrapper.site-page--login {
  84. position: absolute;
  85. top: 0;
  86. right: 0;
  87. bottom: 0;
  88. left: 0;
  89. background-color: rgba(38, 50, 56, 0);
  90. overflow: hidden;
  91. &:before {
  92. position: fixed;
  93. top: 0;
  94. left: 0;
  95. z-index: -1;
  96. width: 80%;
  97. height: 100%;
  98. content: "";
  99. background-image: url(~@/assets/img/login_bg.jpg);
  100. background-size: cover;
  101. }
  102. .site-content__wrapper {
  103. position: absolute;
  104. top: 0;
  105. right: 0;
  106. bottom: 0;
  107. left: 0;
  108. padding: 0;
  109. margin: 0;
  110. overflow-x: hidden;
  111. overflow-y: auto;
  112. background-color: transparent;
  113. }
  114. .site-content {
  115. min-height: 100%;
  116. padding: 15% 500px 30px 30px;
  117. }
  118. .brand-info {
  119. margin: 220px 100px 0 90px;
  120. color: #fff;
  121. }
  122. .brand-info__text {
  123. margin: 0 0 22px 0;
  124. font-size: 48px;
  125. font-weight: 400;
  126. text-transform : uppercase;
  127. }
  128. .brand-info__intro {
  129. margin: 10px 0;
  130. font-size: 16px;
  131. line-height: 1.58;
  132. opacity: .6;
  133. }
  134. .login-main {
  135. position: absolute;
  136. top: 0;
  137. right: 0;
  138. padding: 15% 60px 180px;
  139. width: 350px;
  140. min-height: 100%;
  141. background-color: #fff;
  142. }
  143. .login-title {
  144. font-size: 30px;
  145. }
  146. .login-captcha {
  147. overflow: hidden;
  148. > img {
  149. width: 100%;
  150. cursor: pointer;
  151. }
  152. }
  153. .login-btn-submit {
  154. width: 100%;
  155. margin-top: 38px;
  156. }
  157. .el-input__inner {
  158. font-size: 30px;
  159. }
  160. .login-main .el-input__inner{
  161. margin-top: 10px;
  162. height: 45px;
  163. }
  164. .el-button--medium {
  165. margin-top: 18px;
  166. padding: 5px 11px;
  167. font-size: 25px;
  168. border-radius: 4px;
  169. }
  170. }
  171. </style>