<template>
  <div class="sign-in">
    <div class="img"></div>
    <div class="fixed">
      <div class="background-left"></div>
      <div class="sign-in-box">
        <!-- 手机+密码登录模块 -->
        <phone-login
          v-if="showPlg"
          @change-email="changeEmail"
          @SetPassword="
            showPlg = false;
            showSpd = true;
          "
        ></phone-login>
        <!-- email登录模块 -->
        <email-login
          v-if="showEmail"
          @phone-email="phoneEmail"
          @SetPassword="
            showEmail = false;
            showSpd = true;
          "
        ></email-login>
        <!-- 设置密码模块 -->
        <set-password v-if="showSpd" @showLogin="showLogin"></set-password>
      </div>
    </div>
  </div>
</template>
<script>
import SetPassword from "@/components/signin/setPassword.vue";
import PhoneLogin from "@/components/signin/phoneLogin.vue";
import EmailLogin from "@/components/signin/emailLogin.vue";
export default {
  data() {
    return {
      showSpd: false, //设置密码
      showPlg: true, //手机登录
      showEmail: false, // 邮箱登录
    };
  },
  components: {
    SetPassword,
    PhoneLogin,
    EmailLogin,
  },
  computed: {
    getType: function () {
      return this.$store.state.businessType;
    },
  },
  methods: {
    showLogin() {
      this.showSpd = false;
      if (this.getType === 0 || this.getType === 1) {
        this.showPlg = true;
      } else {
        this.showEmail = true;
      }
    },
    // 切换至email登录
    changeEmail() {
      this.showEmail = true;
      this.showPlg = false;
    },
    // 切换至手机登录
    phoneEmail() {
      this.showEmail = false;
      this.showPlg = true;
    },
  },
};
</script>
<style lang="less" scoped>
.sign-in {
  position: relative;
  background: #ececec;
}
.img {
  position: absolute;
  left: 26px;
  top: 14px;
  width: 166px;
  height: 28px;
  background: url("../images/Home/home_logo.png") no-repeat center;
  background-size: 100% 100%;
}
.fixed {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 895px;
  box-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.07);
}
.sign-in-box {
  width: 443px;
  height: 554px;
  background: rgba(255, 255, 255, 1);
  border-radius: 4px;
  padding: 0 26px;
  float: left;
  position: relative;
}
.background-left {
  background: url("../../../assets/images/SigIn/login_bg.png") no-repeat center;
  background-size: 100%;
  float: left;
  background-color: #faf8fd;
  height: 554px;
  width: 400px;
}
</style>