<template>
  <div v-wechat-title="$route.meta.title" style="background-color:#FAFAFA;height:100%;">
    <div style="text-align:center;padding-top:100px;">
      <div>
        帐号:
        <Input v-model="admin.Account" clearable prefix="ios-contact" placeholder="输入帐号" style="width: auto" />
      </div>
      <div style="margin:20px 0px 20px 0px;">
        密码:
        <Input v-model="admin.Password" clearable prefix="ios-eye-off" type="password" placeholder="输入密码" style="width: auto" />
      </div>
      <Button @click="isLogin" style="color:blue;width:220px;"  long type="dashed">登录</Button>
    </div>
  </div>
</template>

<script>
import CryptoJS from "crypto-js";
import { request } from 'http';
export default {
  
  data() {
    return {
      admin:{
        Account:'',//帐号
        Password:'',//密码
      },
    }
  },
  
  created() {
    
  },
  methods: {
    //登录事件
    
    isLogin(){
      let a = "Webservice接口地址"
      this.$store.dispatch('GetSystemURL',a).then(res=>{
        if(this.admin.Account==''){
          this.$Message.warning('请填写帐号!');
          return;
        }
        if(this.admin.Password==''){
          this.$Message.warning('请填写密码!');
          return;
        }
        else{
          //此处异步方法 
          this.$axios({
            url: '/'+res+'/'+"Login?userid=" + this.admin.Account+ "&password=" + this.admin.Password+ "&dNo=&dToken=",
            method:'get',
            //发送格式为json
            headers:{
            'Content-Type': 'application/json'
            }
          }).then(r=>{
            if(r.data.msg==='登录成功'){
              this.$Message.success(r.data.msg);
              //当前登录人员信息存放在sessionStorage中;
              sessionStorage.setItem('usercode',JSON.stringify(r.data.data.userCode));
              sessionStorage.setItem('un',JSON.stringify(r.data.data.userName));
              this.$router.push('/main');
            }
            else{
              this.$Message.error(r.data.msg);
              return;
            }
          })
        }
      })
    },
  },
}
</script>
