<style lang="less">
  @import './login.less';
  //.button-new {
  //  margin-top: 30px;
  //  width: 280px;
  //  border-radius: 40px;
  //}
  //input:-webkit-autofill , textarea:-webkit-autofill, select:-webkit-autofill {
  //  -webkit-text-fill-color: black !important;
  //  -webkit-box-shadow: 0 0 0px 1000px transparent  inset !important;
  //  background-color:transparent;
  //  background-image: none;
  //  transition: background-color 50000s ease-in-out 0s; //背景色透明  生效时长  过渡效果  启用时延迟的时间
  //}
  //input {
  //  background-color: transparent;
  //  outline:none
  //}
  //.login > .ivu-card-body {
  //  padding: 16px;
  //  background-color: #f2f2f2;
  //}
  //.ivu-card-body {
  //  padding: 16px;
  //}
  //.ivu-input-group > .ivu-input:last-child, .ivu-input-group-append {
  //  border-bottom-left-radius: 0 !important;
  //  border-top-left-radius: 0 !important;
  //  border-top-style: none;
  //  border-right-style: none;
  //  border-left-style: none;
  //  border-bottom-style: none;
  //  border-bottom: #999 1px solid;
  //  background-color: transparent;
  //  border-radius: 0px;
  //  height: 60px;
  //  font-size: 20px;
  //}
  //input:focus{
  //  outline: none;
  //}
  //.ivu-input-group-prepend, .ivu-input-group-append {
  //  padding: 4px 7px;
  //  font-size: inherit;
  //  font-weight: normal;
  //  line-height: 1;
  //  color: #515a6e;
  //  text-align: center;
  //  background-color: #f2f2f2;
  //  /* border: 1px solid #dcdee2; */
  //  border-radius: 0px;
  //  border-bottom: 1px solid #999;
  //  border-top-style: none;
  //  border-right-style: none;
  //  border-left-style: none;
  //}
  //  //-----下面样式 为了适配 疫情系统
  //  .login /deep/ .ivu-card{
  //      background: none;
  //  }
  //  .login /deep/ .ivu-input-group-prepend, .ivu-input-group-append{
  //      background: none;
  //      color: black;
  //  }
  //  .login /deep/ .ivu-form-item-error .ivu-input-group-prepend, .ivu-form-item-error .ivu-input-group-append{
  //      border: none;
  //  }
  //.login /deep/ .ivu-input-group > .ivu-input:last-child, .ivu-input-group-append{
  //    color: black;
  //}
</style>

<template>
  <div class="login" v-if="is_show">
    <div class="login-con">
<!--      <Card icon="log-in" title="" :bordered="false" style="margin-left: 20%;margin-top: 15%;">-->
<!--        <div class="form-con">-->
<!--          <login-form @on-success-valid="handleSubmit"></login-form>-->
<!--&lt;!&ndash;          <p class="login-tip">输入任意用户名和密码即可</p>&ndash;&gt;-->
<!--        </div>-->
<!--      </Card>-->
      <hd-login :loginStyle="loginStyle" :fun="beforeLogin"></hd-login>
    </div>
  </div>
</template>

<script>
// import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
import Gmk from '@/view/login/Gmk.vue'
import bg from '@/assets/images/qstb_backimg.png'
export default {
  data () {
    return {
      loginStyle: {
        backgroundImage: 'url(' + bg + ')'
      },
      is_show: false,
      data: {
        userName: '',
        password: ''
      }
    }
  },
  components: {
    // LoginForm
  },
  mounted (option) {
    console.log(this.$route.query.username, '12222')
    if (this.$route.query.username) {
      this.handleSubmit({ userName: this.$route.query.username, password: '000000' })
    } else {
      this.is_show = true
    }
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ userName, password }) {
      console.log('登录')
      this.handleLogin({ userName, password }).then(res => {
        if (res.errcode === 0) {
          if (res.data.errcode === 0) {
            // this.$Message.success('登录成功')
            this.getUserInfo().then(resx => {
              console.log(resx, this.$config.homeName, '用户信息')
              Gmk.userName = userName
              Gmk.password = password
              Gmk.currentUrl = window.location.href
              console.log(Gmk.currentUrl, '1a')
              if (Gmk.currentUrl.indexOf('localhost') !== -1) {
                Gmk.istest = true
                console.log(Gmk.istest, '2a')
              } else if (Gmk.currentUrl.indexOf('http://iview') !== -1) {
                console.log(Gmk.istest, '3a')
                Gmk.istest = true
              } else {
                console.log(Gmk.istest, '4a')
                Gmk.istest = false
              }
              this.$router.push({
                name: this.$config.homeName
              })
            })
          } else {
            this.$Message.error(res.data.errmsg)
          }
        } else {
          this.$Message.error(res.errmsg)
        }
      })
    },
    // getOfficeInfoAction () {
    //   getOfficeInfo().then(res => {
    //     if (res.data.errcode === 0) {
    //       // let severUserInfo = this.$common.xeUtils.clone(this.$store.state.user.severUserInfo)
    //       // const param = {
    //       //   ...severUserInfo.data, // 原登录信息
    //       //   record_number: res.data.data.record_number, // 全宗号
    //       //   office_code: res.data.data.office_code // 单位编码
    //       // }
    //       // severUserInfo.data = param
    //       // this.setUserInfo(severUserInfo)
    //       // console.log('缓存', window.localStorage)
    //       window.localStorage.removeItem('record_number')
    //       window.localStorage.removeItem('company_type')
    //       window.localStorage.setItem('record_number', res.data.data.record_number)
    //       window.localStorage.setItem('company_type', res.data.data.company_type)
    //     }
    //   })
    // },
    async beforeLogin () {
      let rest = await this.getUserInfo()
      console.log(rest)
      if (rest.errcode === 0) {
        return true
      } else {
        return true
      }
    }
  }
}
</script>

<style>

</style>
