login.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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">木之云数字化平台</h2>
  7. <p class="brand-info__intro">即时生产数字化平台,服务于各类生产型企业</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. <!-- 发布客户环境时注释这段代码 -- Start -->
  35. <div style="bottom: 20px;position: fixed;color:white">
  36. ©2023 muzhikeji.cn 版权所有ICP证:<a href="https://beian.miit.gov.cn/" target="_blank">赣ICP备2021005225号-2</a>
  37. </div>
  38. <!-- 发布客户环境时注释这段代码 -- End -->
  39. </div>
  40. </div>
  41. <!-- <div class="site-wrapper site-sidebar&#45;&#45;fold"-->
  42. <!-- v-loading.fullscreen.lock="loading"-->
  43. <!-- element-loading-text="加载中">-->
  44. <!-- </div>-->
  45. </div>
  46. </template>
  47. <script>
  48. import { getUUID } from '@/utils'
  49. export default {
  50. data () {
  51. return {
  52. dataForm: {
  53. userName: '',
  54. password: '',
  55. uuid: '',
  56. captcha: ''
  57. },
  58. dataRule: {
  59. userName: [
  60. { required: true, message: '帐号不能为空', trigger: 'blur' }
  61. ],
  62. password: [
  63. { required: true, message: '密码不能为空', trigger: 'blur' }
  64. ],
  65. captcha: [
  66. { required: true, message: '验证码不能为空', trigger: 'blur' }
  67. ]
  68. },
  69. captchaPath: ''
  70. }
  71. },
  72. created () {
  73. // console.log('login')
  74. // this.getCaptcha()
  75. },
  76. methods: {
  77. // 提交表单
  78. dataFormSubmit () {
  79. this.$refs['dataForm'].validate((valid) => {
  80. if (valid) {
  81. this.$http({
  82. url: this.$http.adornUrl('/user-service/user/login'),
  83. method: 'post',
  84. data: this.$http.adornData({
  85. 'username': this.dataForm.userName,
  86. 'password': this.dataForm.password,
  87. 'appCode': 'ERP-SYSTEM'
  88. })
  89. }).then(({data}) => {
  90. if (data && data.code === '200') {
  91. this.$cookie.set('token', data.data.access_token)
  92. this.$router.replace({ name: this.dataForm.userName === 'admin' ? 'home-admin' : 'home-customer' })
  93. } else {
  94. // this.getCaptcha()
  95. this.$message.error(data.msg)
  96. }
  97. })
  98. }
  99. })
  100. },
  101. // 获取验证码
  102. getCaptcha () {
  103. this.dataForm.uuid = getUUID()
  104. this.captchaPath = this.$http.adornUrl(`/captcha.jpg?uuid=${this.dataForm.uuid}`)
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. .site-wrapper.site-page--login {
  111. position: absolute;
  112. top: 0;
  113. right: 0;
  114. bottom: 0;
  115. left: 0;
  116. background-color: rgba(38, 50, 56, .6);
  117. overflow: hidden;
  118. &:before {
  119. position: fixed;
  120. top: 0;
  121. left: 0;
  122. z-index: -1;
  123. width: 100%;
  124. height: 100%;
  125. content: "";
  126. /*background-image: url(~@/assets/img/login_bg.png);*/
  127. background-image: url(~@/assets/img/login_bg2.jpg);
  128. background-size: cover;
  129. }
  130. .site-content__wrapper {
  131. position: absolute;
  132. top: 0;
  133. right: 0;
  134. bottom: 0;
  135. left: 0;
  136. padding: 0;
  137. margin: 0;
  138. overflow-x: hidden;
  139. overflow-y: auto;
  140. background-color: transparent;
  141. }
  142. .site-content {
  143. min-height: 100%;
  144. padding: 30px 500px 30px 30px;
  145. }
  146. .brand-info {
  147. margin: 220px 100px 0 90px;
  148. color: #fff;
  149. }
  150. .brand-info__text {
  151. margin: 0 0 22px 0;
  152. font-size: 48px;
  153. font-weight: 400;
  154. text-transform : uppercase;
  155. }
  156. .brand-info__intro {
  157. margin: 10px 0;
  158. font-size: 16px;
  159. line-height: 1.58;
  160. opacity: .6;
  161. }
  162. .login-main {
  163. position: absolute;
  164. top: 0;
  165. right: 0;
  166. padding: 150px 60px 180px;
  167. width: 470px;
  168. min-height: 100%;
  169. background-color: #fff;
  170. }
  171. .login-title {
  172. font-size: 16px;
  173. }
  174. .login-captcha {
  175. overflow: hidden;
  176. > img {
  177. width: 100%;
  178. cursor: pointer;
  179. }
  180. }
  181. .login-btn-submit {
  182. width: 100%;
  183. margin-top: 38px;
  184. }
  185. }
  186. </style>