后端

index.vue 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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">renren-fast-vue</h2>
  7. <p class="brand-info__intro">renren-fast-vue基于vue、element-ui构建开发,实现renren-fast后台管理前端功能,提供一套更优的前端解决方案。</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>
  37. </template>
  38. <script>
  39. import API from '@/api'
  40. import { getUUID } from '@/utils'
  41. export default {
  42. data () {
  43. return {
  44. dataForm: {
  45. userName: '',
  46. password: '',
  47. uuid: '',
  48. captcha: ''
  49. },
  50. dataRule: {
  51. userName: [
  52. { required: true, message: '帐号不能为空', trigger: 'blur' }
  53. ],
  54. password: [
  55. { required: true, message: '密码不能为空', trigger: 'blur' }
  56. ],
  57. captcha: [
  58. { required: true, message: '验证码不能为空', trigger: 'blur' }
  59. ]
  60. },
  61. captchaPath: ''
  62. }
  63. },
  64. created () {
  65. this.getCaptcha()
  66. },
  67. methods: {
  68. // 提交表单
  69. dataFormSubmit () {
  70. this.$refs['dataForm'].validate((valid) => {
  71. if (valid) {
  72. var params = {
  73. 'username': this.dataForm.userName,
  74. 'password': this.dataForm.password,
  75. 'uuid': this.dataForm.uuid,
  76. 'captcha': this.dataForm.captcha
  77. }
  78. API.common.login(params).then(({data}) => {
  79. if (data && data.code === 0) {
  80. this.$cookie.set('token', data.token)
  81. this.$router.replace({ name: 'home' })
  82. } else {
  83. this.getCaptcha()
  84. this.$message.error(data.msg)
  85. }
  86. })
  87. }
  88. })
  89. },
  90. // 获取验证码
  91. getCaptcha () {
  92. this.dataForm.uuid = getUUID()
  93. this.captchaPath = API.common.captcha(this.dataForm.uuid)
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. .site-wrapper.site-page--login {
  100. position: absolute;
  101. top: 0;
  102. right: 0;
  103. bottom: 0;
  104. left: 0;
  105. background-color: rgba(38, 50, 56, .6);
  106. overflow: hidden;
  107. &:before {
  108. position: fixed;
  109. top: 0;
  110. left: 0;
  111. z-index: -1;
  112. width: 100%;
  113. height: 100%;
  114. content: "";
  115. background-image: url(~@/assets/img/login_bg.jpg);
  116. background-size: cover;
  117. }
  118. .site-content__wrapper {
  119. position: absolute;
  120. top: 0;
  121. right: 0;
  122. bottom: 0;
  123. left: 0;
  124. padding: 0;
  125. margin: 0;
  126. overflow-x: hidden;
  127. overflow-y: auto;
  128. }
  129. .site-content {
  130. min-height: 100%;
  131. padding: 30px 500px 30px 30px;
  132. }
  133. .brand-info {
  134. margin: 220px 100px 0 90px;
  135. color: #fff;
  136. }
  137. .brand-info__text {
  138. margin: 0 0 22px 0;
  139. font-size: 48px;
  140. font-weight: 400;
  141. text-transform : uppercase;
  142. }
  143. .brand-info__intro {
  144. margin: 10px 0;
  145. font-size: 16px;
  146. line-height: 1.58;
  147. opacity: .6;
  148. }
  149. .login-main {
  150. position: absolute;
  151. top: 0;
  152. right: 0;
  153. padding: 150px 60px 180px;
  154. width: 470px;
  155. min-height: 100%;
  156. background-color: #fff;
  157. }
  158. .login-title {
  159. font-size: 16px;
  160. }
  161. .login-captcha {
  162. overflow: hidden;
  163. > img {
  164. width: 100%;
  165. cursor: pointer;
  166. }
  167. }
  168. .login-btn-submit {
  169. width: 100%;
  170. margin-top: 38px;
  171. }
  172. }
  173. </style>