<template>
  <div>
    <el-dialog
      class="dialogForm"
      title=""
      :visible.sync="inviteVisible"
      width="500px"
      append-to-body
      :close-on-click-modal="false"
      :before-close="close"
    >
      <div class="content" v-if="show">
        <div class="title">邀请码激活</div>
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="110px"
          label-position="top"
        >
          <el-form-item label="邀请码：" prop="invitation">
            <el-input
              v-model="ruleForm.invitation"
              size="small"
              placeholder="请输入邀请码"
            ></el-input>
          </el-form-item>
          <el-form-item label="公司名称：" prop="name">
            <el-input
              v-model="ruleForm.name"
              size="small"
              placeholder="请输入公司名称"
            ></el-input>
          </el-form-item>
          <el-form-item label="联系人：" prop="contacts">
            <el-input
              v-model="ruleForm.contacts"
              size="small"
              placeholder="请输入联系人"
            ></el-input>
          </el-form-item>
          <el-form-item label="联系人手机：" prop="phoneNumber">
            <el-input
              v-model="ruleForm.phoneNumber"
              size="small"
              placeholder="请输入联系人手机号码"
            ></el-input>
          </el-form-item>
          <el-form-item label="联系人邮箱：" prop="email">
            <el-input
              v-model="ruleForm.email"
              size="small"
              placeholder="请输入联系人邮箱"
            ></el-input>
          </el-form-item>
          <el-form-item label="联系人地址：" prop="address">
            <el-input
              v-model="ruleForm.address"
              size="small"
              placeholder="请输入联系地址"
            ></el-input>
          </el-form-item>
        </el-form>
        <p>
          <el-checkbox v-model="choose"
            ><span class="text"
              >我已阅读并同意该系统的<a @click.prevent="checkConceal(1)"
                >用户协议</a
              >及<a @click.prevent="checkConceal(2)">隐私政策</a></span
            ></el-checkbox
          >
        </p>
        <div style="display: flex; justify-content: center; margin-top: 10px">
          <el-button @click="close" size="small" style="width: 150px"
            >取 消</el-button
          >
          <el-button
            type="primary"
            size="small"
            style="width: 150px"
            @click="submit"
            :loading="btnLoading"
            >激 活</el-button
          >
        </div>
      </div>
      <div v-else class="success">
        <div class="success_title">
            <div class="success_icon">
                <div class="icon">
                    <i class="el-icon-check"></i>
                </div>
                
            </div>
            <div class="foot_title">
                <p class="foot_title1">账号激活成功，正在审核中...</p>
                <p class="foot_title2">审核成功后将会有相关人员通知到您，请您耐心等待。</p>
            </div>
        </div>
            
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
        show:true,
      btnLoading: false,
      inviteVisible: false,
      // agreementVisible: false,
      choose: false,
      ruleForm: {},
      rules: {
        invitation: [
          { required: true, message: "请输入邀请码", trigger: "blur" },
        ],
        name: [{ required: true, message: "请输入公司名称", trigger: "blur" }],
        contacts: [
          { required: true, message: "请输入联系人", trigger: "blur" },
        ],
        phoneNumber: [
          { required: true, message: "请输入联系人手机号码", trigger: "blur" },
          {
            pattern:
              /(^((\+86)|(86))?(1[3-9])\d{9}$)|(^(0\d{2,3})-?(\d{7,8})$)/,
            message: "请输入正确的手机号码格式",
            trigger: "blur",
          },
        ],
        email: [
          { required: true, message: "请输入邮箱", trigger: "blur" },
          {
            pattern:
              /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\.\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
            message: "请输入正确的邮箱格式",
            trigger: "blur",
          },
        ],
      },
      passwordRule: {
        password: [
          { required: true, message: "请输入管理员密码", trigger: "blur" },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    submit() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          if (!this.choose) {
            this.$message.error("请先阅读并同意用户协议，才能继续注册");
            return false;
          }
          this.btnLoading = true;
          this.$api
            .addByInvitation(this.ruleForm)
            .then((response) => {
            //   this.$message.success("账号注册成功");
              // this.$emit('username',this.ruleForm.username)
              // this.close()
              this.$refs.ruleForm.resetFields();
              this.show = false
              this.btnLoading = false;
            })
            .catch((error) => {
              this.btnLoading = false;
            });
        } else {
          return false;
        }
      });
    },
    close() {
      this.ruleForm = {};
      this.inviteVisible = false;
    },
    checkConceal(id) {
      const router = this.$router.resolve({
        path: "/agreeConceal",
        query: {
          id: id,
        },
      });
      window.open(router.href, "_blank");
    },
    open() {
      this.inviteVisible = true;
      this.show = true
    },
  },
};
</script>
<style>
.agreement {
  border-radius: 10px;
}
.agreement .el-dialog__body {
  padding: 0;
}
.dialogForm .el-form-item__error {
  display: none;
}
.dialogForm .el-dialog__body {
  padding-top: 10px;
}
.dialogForm .el-checkbox__input.is-checked + .el-checkbox__label {
  color: #606266;
}
.content .el-form-item__label {
  height: 30px;
  padding: 0;
}
.content .el-form-item {
  margin: 0;
}
</style>
<style lang="scss" scoped>
.success{
    height: 521px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.success_title{
      .success_icon{
        width: 150px;
        height: 150px;
        margin: 0 auto;
        border-radius: 50%;
        background: #1fad25;
        font-size: 40px;
        position: relative;
        .icon{
            height: 50px;
            width: 40px;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
            color: white;
        }
    }
    .foot_title{
       text-align: center;
       font-size: 16px;
       margin-top: 30px;
        .foot_title1{
          color: black;
          font-weight: 800;
          font-size:20px;
          margin-bottom: 16px;
        }
    }
}

.content_body {
  margin: 20px 0;
}
.content_foot {
  display: flex;
  justify-content: space-between;
}
// .item1{
// }
// .item2{
// animation: show 1s;
// }
@keyframes show {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}
.footer {
  display: flex;
  justify-content: space-around;
  height: 50px;
  box-shadow: 1px white;
  border-top: 1px solid gray;
  div {
    cursor: pointer;
    width: 100%;
    text-align: center;
    line-height: 50px;
  }
}
.logo {
  margin-right: 10px;
  width: 135px;
  height: 35px;
}
.logo-bar {
  padding: 20px;
}
// .content{
//   width: 800px;
//   background: rgb(58, 55, 55);
//   opacity: 0.8;
//   padding: 20px;
//   padding-right:30px;
//   height: 550px;
//   border-radius: 5px;
//   position: absolute;
//   left: 0;
//   right: 0;
//   top: 0;
//   bottom: 0;
//   margin: auto;
// }
.main {
  z-index: 1;
}
.register {
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}
.vue-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at top left,
    rgba(105, 155, 200, 1) 0%,
    rgba(181, 197, 216, 1) 57%
  );
}
.title {
  // color: white;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 22px;
  text-align: center;
  letter-spacing: 4px;
}
p {
  margin-top: 0px;
  margin-bottom: 0;
}

.text {
  font-size: 12px;
  a {
    font-size: 12px;
    color: #1976d2;
  }
  a:hover {
    text-decoration: underline;
  }
}
</style>
<style>
/* .el-dialog__header {
    padding: 0;
}
.el-dialog__body {
    padding: 20px 20px 10px;
    color: #606266;
    font-size: 14px;
    word-break: break-all;
} */
</style>