<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" :style="{backgroundImage:'url(' + bg + ')'}">
     <div class="lbu-div">
<!--      <Carousel autoplay v-model="value2" :autoplay-speed="autoplaySpeed" loop>-->
<!--        <CarouselItem>-->
<!--            <img :src="首页1v1" alt="" style="width:100%;background: no-repeat">-->
<!--        </CarouselItem>-->
<!--        <CarouselItem>-->
<!--            <img :src="首页v1" alt="" style="width:100%;background: no-repeat">-->
<!--        </CarouselItem>-->
<!--      </Carousel>-->
    </div>
    <div class="login-con">
      <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/summary_login/Gmk.vue'
import bg from '@/assets/images/登录.png'
// import bg from '@/assets/images/登录页@2x.jpg' // 常规吉林项目登录页背景图
// import bg from '@/assets/summary/12345背景图.jpg' // 为避免检测更换为12345背景图
import lb1 from '@/assets/summary/lb1.jpg'
import lb2 from '@/assets/summary/lb2.jpg'
import 首页1v1 from '@/assets/summary/首页1v1.jpg'
import 首页1v1as from '@/assets/summary/首页1v1as.jpg'
import 首页v1 from '@/assets/summary/首页v1.jpg'
// import xeUtils from 'xe-utils'
import summary_back2 from '@/assets/summary/summary_back2.jpg'
import summary_back2as from '@/assets/summary/summary_back2as.png'
export default {
  data () {
    return {
      summary_back2,
      summary_back2as,
      autoplaySpeed: 3500,
      value2: 0,
      bg,
      首页1v1,
      首页v1,
      首页1v1as,
      lb1,
      lb2,
      loginStyle: {
        backgroundImage: 'url(' + bg + ')'
      },
      is_show: false,
      data: {
        userName: '',
        password: ''
      }
    }
  },
  components: {
    // LoginForm
  },
  created () {
  },
  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>
