login.vue 5.1 KB

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