login-4.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div id="login-2">
  3. <el-row>
  4. <el-col :span="24" class="main" :style="{ 'background-image': `url('${backimage}')` }">
  5. <div class="w_1200">
  6. <el-col :span="24" class="info">
  7. <el-col :span="24" class="info_1">
  8. <h2>{{ siteInfo.zhTitle }}</h2>
  9. </el-col>
  10. <el-col :span="24" class="info_2">
  11. <el-form :model="form" :rules="rules" ref="form">
  12. <el-form-item prop="account">
  13. <el-input placeholder="请输入账号" v-model="form.account"> </el-input>
  14. </el-form-item>
  15. <el-form-item prop="password">
  16. <el-input placeholder="密码" v-model="form.password" type="password" show-password> </el-input>
  17. </el-form-item>
  18. <el-col :span="24">
  19. <el-switch v-model="value" active-text="记住密码" active-color="#555" inactive-color="#ccc"> </el-switch>
  20. </el-col>
  21. <el-col :span="24" class="btn">
  22. <el-form-item class="btn">
  23. <el-button type="primary" @click="toLogin('form')">登录</el-button>
  24. </el-form-item>
  25. </el-col>
  26. </el-form>
  27. </el-col>
  28. <el-col :span="24" class="info_3" @click.native="toRegister()">立即注册 </el-col>
  29. </el-col>
  30. </div>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. </template>
  35. <script>
  36. import { siteInfo } from '@common/src/layout/site';
  37. import { mapState, createNamespacedHelpers } from 'vuex';
  38. export default {
  39. name: 'login-2',
  40. props: {},
  41. components: {},
  42. data: function () {
  43. return {
  44. siteInfo: siteInfo,
  45. // 背景图片
  46. backimage: require('@/assets/login/login_4_1.png'),
  47. form: {},
  48. rules: {
  49. account: [{ required: true, message: '账号不能为空', trigger: 'blur' }],
  50. password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
  51. code: [{ required: true, message: '验证码不能为空', trigger: 'blur' }],
  52. },
  53. value: true,
  54. };
  55. },
  56. created() {},
  57. methods: {
  58. toLogin(formName) {
  59. this.$refs[formName].validate(async (valid) => {
  60. if (valid) {
  61. this.$emit('toLogin', { data: this.form, formName: formName });
  62. } else {
  63. console.log('error submit!!');
  64. return false;
  65. }
  66. });
  67. },
  68. toRegister() {
  69. this.$emit('toRegister');
  70. },
  71. toCode() {
  72. this.$emit('toCode');
  73. },
  74. },
  75. computed: {
  76. ...mapState(['user']),
  77. },
  78. metaInfo() {
  79. return { title: this.$route.meta.title };
  80. },
  81. watch: {
  82. test: {
  83. deep: true,
  84. immediate: true,
  85. handler(val) {},
  86. },
  87. },
  88. };
  89. </script>
  90. <style lang="less" scoped>
  91. .main {
  92. background-size: 100% 100%;
  93. height: 100vh;
  94. background-repeat: no-repeat;
  95. overflow: hidden;
  96. .info {
  97. flex: 0 0 auto;
  98. width: 33.333333%;
  99. border-radius: 5px;
  100. font-size: 14px;
  101. margin: 15% 30%;
  102. background: #fff;
  103. padding: 16px;
  104. .info_1 {
  105. border-radius: 5px;
  106. background: #e32f6e;
  107. margin: -20% 0 8% 0;
  108. padding: 16px;
  109. color: #fff;
  110. text-align: center;
  111. }
  112. .info_2 {
  113. .btn {
  114. margin: 5% 0 0 0;
  115. text-align: center;
  116. button {
  117. width: 100%;
  118. background: #e32f6e;
  119. border: #e32f6e;
  120. }
  121. }
  122. }
  123. .info_3 {
  124. margin: 20px 0 10px 0;
  125. color: #e32f6e;
  126. font-size: 14px;
  127. text-align: center;
  128. }
  129. .info_3:hover {
  130. cursor: pointer;
  131. }
  132. }
  133. }
  134. /deep/.el-switch__label {
  135. color: #7b809a;
  136. }
  137. /deep/.el-switch__label.is-active {
  138. color: #7b809a;
  139. }
  140. </style>