<style>
    @import url('../assets/views/login.css');
</style>
<template>
    <div class="login_page">  
        <print></print>     
        <div v-if='isshow' class="login-box" >
            <div class="login-log">
                <img src="../assets/img/system/logo2.png" />
            </div>
            <div class="title">『 MAGE 』Data Services</div>
            <div class="line">
                <i class="iconfont icon-bl27account"></i>
                <input type="text" @keyup.enter='login' v-model="loginInfo.account" autocomplete="new-password" placeholder="请输入你的身份ID" class="ipt" />
            </div>
            <div class="line">
                <i class="iconfont icon-password"></i>
                <input type="password"  @keyup.enter='login' v-model="loginInfo.password" autocomplete="new-password" placeholder="请输入你的ID凭证" class="ipt" />
            </div>
            <div class="btn-box">
                <button class="btn-default" @click="login">立即登录</button>
            </div>
        </div>
    </div>
</template>
<script>
import Particle from 'particleground-light'
import print from '../components/print/index'
export default {
    components: {
        print
    },
    data(){
        return{
            loginInfo:{
                account:'',
                password:''
            },
            isshow:false
        }
    },
    created() {
        if(localStorage.isFirst &&localStorage.isFirst=='y'){
            this.isshow=true
        }else{
            setTimeout(() => {
                this.isshow=true
                localStorage.isFirst='y'
            }, 83*200);
        }
    },
    mounted () {
        new Particle(document.querySelector('.login_page'),{
            dotColor: '#031940',
            lineColor: '#031940'
        })
        if(localStorage.user){
            localStorage.removeItem('user')
        }
    },
    methods: {
        login(){
            console.log('in..........')
            if(this.loginInfo.account==''){
                this.alert('登录提醒','请输入你的身份ID')
            } else if(this.loginInfo.password==''){
                this.alert('登录提醒','请输入你的ID凭证')
            } else {
                var msg = {
                    EmAccount: this.loginInfo.account,
                    EmPassword: this.loginInfo.password,
                    Domain: 'yx.oytour.com'
                }
                this.apipost("admin_get_EmployeeLogin", msg, response => {
                    var jsonData = response.data;
                    if (jsonData.resultCode == 1) {
                        //登录成功
                        var userData = jsonData.data
                        localStorage.user=JSON.stringify(userData)
                        this.$router.push('/index')
                    } else {
                        this.loginInfo.password=''
                        this.alert('登录失败提醒',response.data.message)
                    }
                },err => {});
            }
        }
    }
}
</script>


