<template>
  <div class="login">
    <div class="container-login100">
      <div class="wrap-login100">
        <div class="login100-pic js-tilt" data-tilt>
          <img src="@/styles/login/img/img-01.png" alt="IMG">

          <div style="text-align: center;font-weight: bold;margin-top: 30px;font-family: Poppins-Bold;font-size: 20px;">DD 会员管理系统</div>
        </div>

        <form class="login100-form validate-form">
				<span class="login100-form-title" style="margin-top: 30px;">
					用户登陆
				</span>

          <div class="wrap-input100 validate-input">
            <input class="input100" type="text" name="username" v-model="loginForm.username" placeholder="用户名">
            <span class="focus-input100"></span>
            <span class="symbol-input100">
						<i class="fa fa-user" aria-hidden="true"></i>
					</span>
          </div>

          <div class="wrap-input100 validate-input">
            <input class="input100" type="password" name="password" v-model="loginForm.password" placeholder="密码">
            <span class="focus-input100"></span>
            <span class="symbol-input100">
						<i class="fa fa-lock" aria-hidden="true"></i>
					</span>
          </div>

          测试账号 ： demo 111111<br/>
          qq: 727869402<br/>
          vx: MAMBA_4EVER24
          <div class="container-login100-form-btn">
            <button type="button" class="login100-form-btn" @click="handleLogin">
              登陆
            </button>
          </div>

          <div class="text-center p-t-12">
<!--            <a class="txt2" href="javascript:">-->
<!--              忘记密码？-->
<!--            </a>-->
          </div>

          <div class="text-center p-t-136">
<!--            <a class="txt2" href="#">-->
<!--              还没有账号？立即注册-->
<!--              <i class="fa fa-long-arrow-right m-l-5" aria-hidden="true"></i>-->
<!--            </a>-->
          </div>
        </form>


        <div style="margin: 0 auto;"> <a href="https://beian.miit.gov.cn" style="color: #57b846;">豫ICP备2023016213号</a></div>

      </div>
    </div>
  </div>
</template>

<script>
    import {validUsername} from "@/utils/validate";
    import {error, isEmpty, isNotEmpty} from "@/utils/index"
    export default {
        name: "login",
        data() {
          return {
            loginForm: {
              username: 'demo',
              password: '111111'
            },
            redirect: undefined
          }
        },
        watch: {
          $route: {
            handler: function(route) {
              this.redirect = route.query && route.query.redirect
            },
            immediate: true
          }
        },
        methods: {
          handleLogin() {
            if(isNotEmpty(this.loginForm.username)&&isNotEmpty(this.loginForm.password)){
              this.loading = true
              this.$store.dispatch('user/login', this.loginForm).then(() => {
                this.$router.push({ path: this.redirect || '/' })
                this.loading = false
              }).catch(() => {
                this.loading = false
              })
            }else{
              error('请完善登陆信息！')
            }
          }
        }
      }
</script>


<style scoped src="@/styles/login/css/font-awesome.min.css"/>
<style scoped src="@/styles/login/css/main.css"/>
<style scoped src="@/styles/login/css/util.css"/>
<style scoped>

</style>
