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.

198 lines
4.8 KiB

3 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. src: 'http://192.168.1.83/upload/ifs.png',
  29. dataForm: {
  30. userName: '',
  31. password: '',
  32. uuid: '',
  33. captcha: ''
  34. },
  35. dataRule: {
  36. userName: [
  37. { required: true, message: '帐号不能为空', trigger: 'blur' }
  38. ],
  39. password: [
  40. { required: true, message: '密码不能为空', trigger: 'blur' }
  41. ]
  42. },
  43. captchaPath: ''
  44. }
  45. },
  46. computed: {
  47. multiLanguage: {
  48. get() {
  49. return this.$store.state.user.multiLanguage
  50. },
  51. set(val) {
  52. this.$store.commit('user/updateMultiLanguage', val)
  53. }
  54. },
  55. authControl: {
  56. get() {
  57. return this.$store.state.user.authControl
  58. },
  59. set(val) {
  60. this.$store.commit('user/updateAuthControl', val)
  61. }
  62. }
  63. },
  64. created () {
  65. this.userName();
  66. },
  67. methods: {
  68. // 获取上次登陆的用户名
  69. userName(){
  70. this.dataForm.userName = localStorage.getItem('userName')
  71. },
  72. // 提交表单
  73. dataFormSubmit () {
  74. this.$refs['dataForm'].validate((valid) => {
  75. if (valid) {
  76. this.$http({
  77. url: this.$http.adornUrl('/api/sys/login'),
  78. method: 'post',
  79. data: this.$http.adornData({
  80. 'username': this.dataForm.userName,
  81. 'password': this.dataForm.password,
  82. 'uuid': this.dataForm.uuid
  83. })
  84. }).then(({data}) => {
  85. if (data && data.code === 0) {
  86. this.$cookie.set('token', data.token)
  87. this.$router.replace({ name: 'home' })
  88. this.$i18n.locale=data.language
  89. localStorage.setItem('locale', data.language)
  90. localStorage.setItem('refresh', "0")
  91. localStorage.setItem('userName', this.dataForm.userName)
  92. this.getConfigParams()
  93. } else {
  94. this.$message.error(data.msg)
  95. }
  96. })
  97. }
  98. })
  99. },
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .site-wrapper.site-page--login {
  105. position: absolute;
  106. top: 0;
  107. right: 0;
  108. bottom: 0;
  109. left: 0;
  110. background-color: rgba(38, 50, 56, 0);
  111. overflow: hidden;
  112. &:before {
  113. position: fixed;
  114. top: 0;
  115. left: 0;
  116. z-index: -1;
  117. width: 80%;
  118. height: 100%;
  119. content: "";
  120. background-image: url(~@/assets/img/login_bg.jpg);
  121. background-size: cover;
  122. }
  123. .site-content__wrapper {
  124. position: absolute;
  125. top: 0;
  126. right: 0;
  127. bottom: 0;
  128. left: 0;
  129. padding: 0;
  130. margin: 0;
  131. overflow-x: hidden;
  132. overflow-y: auto;
  133. background-color: transparent;
  134. }
  135. .site-content {
  136. min-height: 100%;
  137. padding: 15% 500px 30px 30px;
  138. }
  139. .brand-info {
  140. margin: 220px 100px 0 90px;
  141. color: #fff;
  142. }
  143. .brand-info__text {
  144. margin: 0 0 22px 0;
  145. font-size: 48px;
  146. font-weight: 400;
  147. text-transform : uppercase;
  148. }
  149. .brand-info__intro {
  150. margin: 10px 0;
  151. font-size: 16px;
  152. line-height: 1.58;
  153. opacity: .6;
  154. }
  155. .login-main {
  156. position: absolute;
  157. top: 0;
  158. right: 0;
  159. padding: 15% 60px 180px;
  160. width: 350px;
  161. min-height: 100%;
  162. background-color: #fff;
  163. }
  164. .login-title {
  165. font-size: 30px;
  166. }
  167. .login-captcha {
  168. overflow: hidden;
  169. > img {
  170. width: 100%;
  171. cursor: pointer;
  172. }
  173. }
  174. .login-btn-submit {
  175. width: 100%;
  176. }
  177. .login-main .el-input__inner{
  178. margin-top: 10px;
  179. height: 45px;
  180. }
  181. .el-button--medium {
  182. margin-top: 0px;
  183. padding: 5px 11px;
  184. font-size: 16px;
  185. border-radius: 4px;
  186. }
  187. .el-form-item {
  188. margin-bottom: 5px;
  189. }
  190. }
  191. </style>