require("../css/login.less")
require("./../css/common.less");
const Vue = require('vue/dist/vue.esm.js').default
const ElementUI = require("../public/elementUI/2.7.2/index")
Vue.use(ElementUI)
const vm = new Vue({
  el: '#app',
  name: "login",
  data: function () {
    return {
      captchaUrl: "./images/CAPTCHA.png",
      rules: {
        username: [{ required: true, message: "账号是必填", trigger: 'blur' }],
        password: [{ required: true, message: "密码是必填", trigger: 'blur' }]
      },
      ruleForm: { username: "", password: "", captcha: "" },
    }
  },
  methods: {
    handleSubmitForm() {
      const ruleFormRef = this.$refs.ruleFormRef
      ruleFormRef.validate((valid) => {
        if (valid) {
          if (this.ruleForm.username == "admin" && this.ruleForm.password == "admin") {

            if (this.ruleForm.captcha.toLowerCase() == "xvxr") {
              this.$message({
                showClose: true,
                message: '登录成功',
                type: 'success'
              });
              ruleFormRef.resetFields()
              window.location.href = "./home.html"
            } else {
              this.$message({
                showClose: true,
                message: '验证码错误',
                type: 'error'
              });
              ruleFormRef.resetFields()
            }
          } else {
            this.$message({
              showClose: true,
              message: '密码或者账号错误!',
              type: 'error'
            });
            ruleFormRef.resetFields()
          }
        }
      })
    },

  },
  watch: {},
  computed: {

  },
  created: function () { },
  mounted: function () { },
  beforeDestroy: function () { },
})