login.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div id="login">
  3. <el-row>
  4. <el-col :span="24">
  5. <div class="bg">
  6. <div class="main">
  7. <div class="left">
  8. <span>直播管理平台</span>
  9. </div>
  10. <div class="right">
  11. <el-col :span="24" class="title">
  12. <span>用户登录</span>
  13. </el-col>
  14. <el-col :span="24" class="form">
  15. <el-form :model="form" :rules="rules" ref="form" class="demo-ruleForm">
  16. <el-form-item prop="roomid" class="roomid">
  17. <span slot="label"><el-image :src="image.roomid"></el-image></span>
  18. <el-input v-model="form.roomid" placeholder="请输入房间号"></el-input>
  19. </el-form-item>
  20. <el-form-item prop="phone">
  21. <span slot="label"><el-image :src="image.phone"></el-image></span>
  22. <el-input v-model="form.phone" placeholder="请输入手机号" maxlength="11"></el-input>
  23. </el-form-item>
  24. <el-form-item prop="passwd">
  25. <span slot="label"><el-image :src="image.password"></el-image></span>
  26. <el-input v-model="form.passwd" placeholder="请输入密码" show-password></el-input>
  27. </el-form-item>
  28. <el-col :span="24" style="text-align:center;">
  29. <el-button type="primary" @click="resetForm('form')">重置</el-button>
  30. <el-button type="success" @click="submitForm('form')">登录</el-button>
  31. </el-col>
  32. </el-form>
  33. </el-col>
  34. </div>
  35. </div>
  36. </div>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. </template>
  41. <script>
  42. import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
  43. const { mapActions: login } = createNamespacedHelpers('login');
  44. export default {
  45. name: 'login',
  46. props: {},
  47. components: {},
  48. data: function() {
  49. return {
  50. form: {},
  51. rules: {
  52. roomid: [{ required: false, message: '请输入房间号', trigger: 'blur' }],
  53. phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
  54. passwd: [{ required: true, message: '请输入密码', trigger: 'blur' }],
  55. },
  56. image: {
  57. roomid: require('@/assets/roomid.png'),
  58. phone: require('@/assets/user.png'),
  59. password: require('@/assets/password.png'),
  60. },
  61. };
  62. },
  63. created() {},
  64. methods: {
  65. ...login({ toLogin: 'login' }),
  66. submitForm(formName) {
  67. this.$refs[formName].validate(async valid => {
  68. if (valid) {
  69. let res = await this.toLogin({ user: this.form });
  70. if (res.id) {
  71. this.$router.push('/');
  72. }
  73. } else {
  74. console.log('error submit!!');
  75. return false;
  76. }
  77. });
  78. },
  79. resetForm(formName) {
  80. this.$refs[formName].resetFields();
  81. },
  82. },
  83. computed: {
  84. ...mapState(['user']),
  85. pageTitle() {
  86. return `${this.$route.meta.title}`;
  87. },
  88. },
  89. metaInfo() {
  90. return { title: this.$route.meta.title };
  91. },
  92. };
  93. </script>
  94. <style lang="less" scoped>
  95. .bg {
  96. width: 100%;
  97. height: 100vh;
  98. background-image: url('../assets/bg3.jpg');
  99. background-size: 100% 100%;
  100. background-position: center center;
  101. }
  102. .main {
  103. position: absolute;
  104. top: 30%;
  105. left: 30%;
  106. width: 660px;
  107. height: 370px;
  108. }
  109. .main .left {
  110. float: left;
  111. width: 330px;
  112. height: 370px;
  113. text-align: center;
  114. background: #0000004f;
  115. }
  116. .main .left span {
  117. font-size: 25px;
  118. color: #fff;
  119. font-weight: bold;
  120. font-family: cursive;
  121. padding: 36% 0;
  122. display: inline-block;
  123. line-height: 40px;
  124. }
  125. .main .right {
  126. float: left;
  127. width: 330px;
  128. height: 370px;
  129. background: #ffffff5f;
  130. .title {
  131. text-align: center;
  132. padding: 20px 0;
  133. margin: 0 0 20px 0;
  134. border-bottom: 1px solid #ccc;
  135. span {
  136. font-size: 20px;
  137. color: #0635ab;
  138. font-weight: bold;
  139. }
  140. }
  141. .form {
  142. padding: 0 10px;
  143. }
  144. }
  145. /deep/.el-input {
  146. width: 80%;
  147. }
  148. /deep/.el-image {
  149. top: 5px;
  150. }
  151. /deep/.roomid .el-form-item__label {
  152. padding: 0 13px 0 10px;
  153. }
  154. </style>