colmo设计师沙龙pc端后台管理系统

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div class="login-container">
  3. <el-form
  4. ref="loginForm"
  5. :model="loginForm"
  6. :rules="loginRules"
  7. class="login-form"
  8. auto-complete="on"
  9. label-position="left"
  10. >
  11. <div class="title-container">
  12. <h3 class="title">COLMO后台管理系统</h3>
  13. </div>
  14. <el-form-item prop="userName">
  15. <span class="svg-container">
  16. <svg-icon icon-class="user" />
  17. </span>
  18. <el-input
  19. ref="userName"
  20. v-model="loginForm.userName"
  21. placeholder="用户名"
  22. name="userName"
  23. type="text"
  24. tabindex="1"
  25. auto-complete="on"
  26. />
  27. </el-form-item>
  28. <el-form-item prop="password">
  29. <span class="svg-container">
  30. <svg-icon icon-class="password" />
  31. </span>
  32. <el-input
  33. :key="passwordType"
  34. ref="password"
  35. v-model="loginForm.password"
  36. :type="passwordType"
  37. placeholder="密码"
  38. name="password"
  39. tabindex="2"
  40. auto-complete="on"
  41. @keyup.enter.native="handleLogin"
  42. />
  43. <span class="show-pwd" @click="showPwd">
  44. <svg-icon
  45. :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
  46. />
  47. </span>
  48. </el-form-item>
  49. <el-button
  50. :loading="loading"
  51. type="primary"
  52. style="width: 100%; margin-bottom: 30px"
  53. @click.native.prevent="handleLogin"
  54. >登录</el-button>
  55. </el-form>
  56. </div>
  57. </template>
  58. <script>
  59. export default {
  60. name: 'Login',
  61. data() {
  62. return {
  63. loginForm: {
  64. userName: '',
  65. password: ''
  66. },
  67. loginRules: {
  68. userName: [
  69. { required: true, message: '请输入用户名', trigger: 'change' }
  70. ],
  71. password: [
  72. { required: true, trigger: 'change', message: '请输入密码' }
  73. ]
  74. },
  75. loading: false,
  76. passwordType: 'password',
  77. redirect: undefined
  78. }
  79. },
  80. watch: {
  81. $route: {
  82. handler: function(route) {
  83. this.redirect = route.query && route.query.redirect
  84. },
  85. immediate: true
  86. }
  87. },
  88. methods: {
  89. showPwd() {
  90. if (this.passwordType === 'password') {
  91. this.passwordType = ''
  92. } else {
  93. this.passwordType = 'password'
  94. }
  95. this.$nextTick(() => {
  96. this.$refs.password.focus()
  97. })
  98. },
  99. handleLogin() {
  100. this.$refs.loginForm.validate((valid) => {
  101. if (valid) {
  102. this.loading = true
  103. this.$store
  104. .dispatch('user/login', this.loginForm)
  105. .then(() => {
  106. this.$router.push({ path: '/Person/Person' })
  107. this.loading = false
  108. })
  109. .catch(() => {
  110. this.loading = false
  111. })
  112. } else {
  113. console.log('error submit!!')
  114. return false
  115. }
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. /* 修复input 背景不协调 和光标变色 */
  123. /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
  124. $bg: #283443;
  125. $light_gray: #fff;
  126. $cursor: #fff;
  127. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  128. .login-container .el-input input {
  129. color: $cursor;
  130. }
  131. }
  132. /* reset element-ui css */
  133. .login-container {
  134. .el-input {
  135. display: inline-block;
  136. height: 47px;
  137. width: 85%;
  138. input {
  139. background: transparent;
  140. border: 0px;
  141. -webkit-appearance: none;
  142. border-radius: 0px;
  143. padding: 12px 5px 12px 15px;
  144. color: $light_gray;
  145. height: 47px;
  146. caret-color: $cursor;
  147. &:-webkit-autofill {
  148. box-shadow: 0 0 0px 1000px $bg inset !important;
  149. -webkit-text-fill-color: $cursor !important;
  150. }
  151. }
  152. }
  153. .el-form-item {
  154. border: 1px solid rgba(255, 255, 255, 0.1);
  155. background: rgba(0, 0, 0, 0.1);
  156. border-radius: 5px;
  157. color: #454545;
  158. }
  159. }
  160. </style>
  161. <style lang="scss" scoped>
  162. $bg: #2d3a4b;
  163. $dark_gray: #889aa4;
  164. $light_gray: #eee;
  165. .login-container {
  166. min-height: 100%;
  167. width: 100%;
  168. background-color: $bg;
  169. overflow: hidden;
  170. .login-form {
  171. position: relative;
  172. width: 520px;
  173. max-width: 100%;
  174. padding: 160px 35px 0;
  175. margin: 0 auto;
  176. overflow: hidden;
  177. }
  178. .tips {
  179. font-size: 14px;
  180. color: #fff;
  181. margin-bottom: 10px;
  182. span {
  183. &:first-of-type {
  184. margin-right: 16px;
  185. }
  186. }
  187. }
  188. .svg-container {
  189. padding: 6px 5px 6px 15px;
  190. color: $dark_gray;
  191. vertical-align: middle;
  192. width: 30px;
  193. display: inline-block;
  194. }
  195. .title-container {
  196. position: relative;
  197. .title {
  198. font-size: 26px;
  199. color: $light_gray;
  200. margin: 0px auto 40px auto;
  201. text-align: center;
  202. font-weight: bold;
  203. }
  204. }
  205. .show-pwd {
  206. position: absolute;
  207. right: 10px;
  208. top: 7px;
  209. font-size: 16px;
  210. color: $dark_gray;
  211. cursor: pointer;
  212. user-select: none;
  213. }
  214. }
  215. </style>