<template>
  <div class="logins">
    <br><br><br><br><br><br><br>
    <img :src="login1" style="margin: 0 auto;display: block;">
    <br>
    <div class="avsd">拜访平台登录</div>
    <br>
    <br><br>
    <br>
    <br>
    <br>
    <br>
    <van-field v-model="formdata.username" label="账号" placeholder="请输入账号"/>
    <br>
    <van-field v-model="formdata.password" type="password" label="密码" placeholder="请输入密码"/>
    <br><br><br>
    <van-button type="info" size="small" plain class="Btn100" @click="login" style="margin:0 auto;">登录</van-button>
  </div>
</template>
<script>
import login1 from "../../assets/logo1.png"
import {mobileLogin} from "@/api/index";

export default {
  name: "login",
  data() {
    return {
      formdata:{
        username: "",
        password:"",
      },
      login1:login1
    }
  },
  methods: {
    login() {
      if (this.formdata.username.trim()!= ""&&this.formdata.password.trim()!="") {
        mobileLogin(this.formdata).then(res=>{
            if(res.code==200){
              localStorage.setItem('loginName', this.formdata.username)
              localStorage.setItem('loginType',"cs")
                this.$router.push("/")
            }else{
              this.$toast(res.msg)
            }
        })


      } else {
        this.$toast("账号密码不能为空")
      }
    }
  }
}
</script>

<style scoped>
.logins {
  padding: 10px;
}
.Btn100 {
  margin: 0 auto 10px;
  display: block;
  width: 100%;
  border-radius: 5px;
  color: #fff !important;
  background-color: #0057ba;
  border: 1px solid #0057ba;
  height: 44px;
  font-size: 16px;
}
.avsd{
  margin: 0 auto;
  width: 98px;
  font-size: 16px;
  color:#0057ba;
}
</style>