<style lang="less">
@import "./login.less";
</style>

<template>
<div class="a">
  <div class="login">
    <div class="login-main">
      <div class="login-img">
        <img src="../../assets/images/vector.png">
        <!-- <img class="img_logo" src="../../assets/images/11@2x.png"> -->
      </div>
      <div class="login-con">
        <div class="title">
            <h4>欢迎来到</h4>
            <h4>一幕数字藏品商户平台!</h4>
        </div>
        <div class="form-con">
          <login-form
            ref="loginForm"
            @on-success-valid="handleSubmit"
            :loginErrMsg="loginErrMsg"
            :loginBtnType="loginBtnType"

          ></login-form>
        </div>
      </div>
    </div>

  </div>
</div>

</template>

<script>
import LoginForm from '_c/login-form'
import { mapMutations, mapActions, mapGetters } from 'vuex'
import { setUid, setAccount, setToken, setLocalStorage } from '@/libs/util'
import routers from '@/router/routers'
export default {
  components: {
    LoginForm
  },
  data () {
    return {
      loginErrMsg: '',
      loginBtnType: 'primary',
      loginLoading: false
    }
  },
  methods: {
    ...mapMutations(['setAccount', 'setBrandId', 'setBrandPrefix', 'setToken', 'setUid', 'setType', 'setHeadImg']),
    handleSubmit ({ account, password, code, vKey }) {
      this.loginLoading = true
      // this.loginBtnType = 'primary'
      // this.loginErrMsg = ''

      // this.api({
      //   apiName: 'login',
      //   postdata: {
      //     account,
      //     password
      //   },
      //   success: (res) => {
      //     let { adminId, token, brandId, brandPrefix, type, headImg } = res.data
      //     this.setAccount(account)
      //     this.setBrandId(brandId)
      //     this.setBrandPrefix(brandPrefix)
      //     this.setUid(adminId)
      //     this.setToken(token)
      //     this.setType(type)
      //     this.setHeadImg(headImg)
      //     this.loginLoading = false
      //     this.$router.push({
      //       name: this.$config.homeName
      //     })
      //   },
      //   failed: () => {
      //     this.loginLoading = false
      //   },
      //   error: (res) => {
      //     console.log(res)
      //     setTimeout(() => {
      //       this.loginLoading = false
      //       this.loginBtnType = 'error'
      //       if (res instanceof Object) {
      //         this.loginErrMsg = res.msg + '！'
      //       } else {
      //         this.loginErrMsg = res + '!'
      //       }
      //     }, 500)
      //   }
      // })
    }
  }
}
</script>

<style lang="less" scoped>
   *{
      margin: 0;
      padding: 0;
    }
</style>
