<template>
<div :class="active">      
    <div class='loader'>
            <div class='spinner-grow text-primary' role='status'>
              <span class='sr-only'>Loading...</span>
            </div>
          </div>
        <div class="container">
            <div class="row justify-content-md-center">
                <div class="col-md-12 col-lg-4">
                    <div class="card login-box-container">
                        <div class="card-body">
                            <div class="authent-logo">
                                <img src="../../assets/images/logo@2x.png" alt="">
                            </div>
                            <div class="authent-text">
                                <p>Welcome to IO!</p>
                                <p>Please Sign-in to your account.</p>
                            </div>

                            <form>
                                <div class="mb-3">
                                    <div class="form-floating">
                                        <input type="text" class="form-control" id="floatingInput" placeholder="账号" v-model="username">
                                        <label for="floatingInput">账号</label>
                                      </div>
                                </div>
                                <div class="mb-3">
                                    <div class="form-floating">
                                        <input type="password" class="form-control" id="floatingPassword" placeholder="密码" v-model="password">
                                        <label for="floatingPassword">密码</label>
                                      </div>
                                </div>
                                <!-- <div class="mb-3 form-check">
                                  <input type="checkbox" class="form-check-input" id="exampleCheck1">
                                  <label class="form-check-label" for="exampleCheck1">Check me out</label>
                                </div> -->
                                <div class="d-grid">
                                <button type="submit" class="btn btn-info m-b-xs" @click="submit()">登录</button>
                            </div>
                              </form>
                              <div class="authent-reg">
                                  <p>没有账号？<RouterLink to="/registered">注册</RouterLink></p>
                              </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
</template>

<script>
import { login_api } from '@/request/api'
export default {
    name: 'Login',
    data() {
        return {
            active: 'login-page',
            username: '',
            password :''
        }
    },
    mounted() {
        this.active = 'login-page no-loader'
    },
    methods: {
         async submit(){
            let res=await login_api({username:this.username,password:this.password})
            if (res.code == 2000) {
                console.log('登录成功')
                this.$router.push('/home')
            }else{
                console.log(res.msg);
            }
        }
    },
}
</script>