<template>
  <div class="rpm-login other-container" style="margin-top: 178px;">
    <IHeader/>
    <div class="rpm-contact" >
      <div class="rpm-contact__title">三明市住建系统内业综合平台</div>
      <div class="rpm-contact__item">
        <el-avatar shape="square" size="small" icon="el-icon-message" />
        595705120@qq.com
      </div>
    </div>
    <SignInForm v-if="visibleForm === 'signIn'" @show-form="showForm" />
    <SignUpForm v-if="visibleForm === 'signUp'" @show-form="showForm" />
    <ForgotPwdForm v-if="visibleForm === 'forgotPwd'" @show-form="showForm" />
    <ResetPwdForm v-if="visibleForm === 'resetPwd'" @show-form="showForm" />
  </div>
</template>

<script>
//import logo from '@/icons/img/logo.png'
import logo from '@/icons/img/logo.jpg'
import SignInForm from './components/SignInForm'
import SignUpForm from './components/SignUpForm'
import ForgotPwdForm from './components/ForgotPwdForm'
import ResetPwdForm from './components/ResetPwdForm'
import IHeader from "../other/components/IHeader";
import IFooter from "../other/components/IFooter";


export default {
  name: 'Login',
  components: { SignInForm, SignUpForm, ForgotPwdForm, ResetPwdForm,IHeader, IFooter},
  data() {
    return {
      url: logo,
      visibleForm: 'signIn'
    }
  },
  watch: {
    $route: {
      handler: function(route) {
        console.log("route", route)
        const query = route.query
        if (query) {
          this.redirect = query.redirect
          this.otherQuery = this.getOtherQuery(query)
        }
      },
      immediate: true
    }
  },
  methods: {
    showForm(form) {
      //console.log('form', form)
      this.visibleForm = form;
    },
    getOtherQuery(query) {
      return Object.keys(query).reduce((acc, cur) => {
        if (cur !== 'redirect') {
          acc[cur] = query[cur]
        }
        return acc
      }, {})
    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/styles/variables.scss";

.rpm-login {
  position: relative;
  margin-left: auto;
  margin-right: auto;
  width: 900px;
  .rpm-logo {
    padding-top: 30px;
    height: 40px;
    text-align: center;
    .el-image, .el-avatar {
      margin-right: 20px;
      background-color: $rpm-theme-color;
    }
    .rpm-logo__title {
      line-height: 40px;
      display: inline-block;
      font-size: 30px;
      font-weight: bold;
      color: $rpm-theme-color;
      overflow: hidden;
    }
  }
  .rpm-contact {
    position: absolute;
    top: 250px;
    left: 100px;
    .rpm-contact__title {
      margin-left: 0px;
      margin-bottom: 40px;
      font-size: 24px;
      font-weight: bold;
    }
    .rpm-contact__item {
      position: relative;
      margin-top: 10px;
      padding-left: 36px;
      height: 40px;
      line-height: 40px;
      font-size: 16px;
      .el-avatar {
        position: absolute;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        background-color: $rpm-theme-color;
        color: white;
      }
    }
  }
}
</style>
