index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div id="login">
  3. <h1>程序员客栈 - BOSS</h1>
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="ruleForm">
  5. <el-form-item label="账号" prop="webmaster">
  6. <el-input v-model="ruleForm.webmaster" placeholder="请输入账号"></el-input>
  7. </el-form-item>
  8. <el-form-item label="密码" prop="password">
  9. <el-input v-model="ruleForm.password" type="password" placeholder="请输入密码"></el-input>
  10. </el-form-item>
  11. <el-form-item label="口令" prop="cypher">
  12. <el-input
  13. v-model="ruleForm.cypher"
  14. type="password"
  15. placeholder="请输入口令"
  16. @keyup.native.enter="submit"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button style="width: 100%;" type="primary" @click="submit">登录</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. layout: "empty",
  28. data() {
  29. return {
  30. ruleForm: {
  31. // 账号
  32. webmaster: "",
  33. // 密码
  34. password: "",
  35. // 口令,格式:inn月日,无 0
  36. cypher: ""
  37. },
  38. rules: {
  39. webmaster: [{ required: true, message: "请输入账号", trigger: "blur" }],
  40. password: [
  41. { required: true, message: "请输入密码", trigger: "change" },
  42. { min: 6, message: "长度在 6 个字符以上", trigger: "blur" }
  43. ],
  44. cypher: [{ required: true, message: "请输入账号", trigger: "blur" }]
  45. }
  46. };
  47. },
  48. methods: {
  49. async submit() {
  50. // this.$router.replace('/main')
  51. // return
  52. const { webmaster, password, cypher } = this.ruleForm;
  53. const res = await this.$post("/api/admin/index/login", {
  54. webmaster,
  55. password,
  56. cypher
  57. });
  58. console.log(res);
  59. if (res && res.status) this.$router.replace("/main");
  60. }
  61. }
  62. };
  63. </script>
  64. <style>
  65. #login {
  66. display: flex;
  67. flex-direction: column;
  68. align-items: center;
  69. margin-top: 200px;
  70. }
  71. .ruleForm {
  72. width: 550px;
  73. }
  74. </style>