<template>
  <el-dialog class="dialog-invite" title="企业邀请" :visible.sync="inviteDialogVisible" width="480px">
      <div class="invite-item">邀请码<br />{{infoRow.inviteCode}}</div>
      <div class="invite-item">发送至 {{infoRow.name}} 邮箱<br />{{infoRow.linkemail}}</div>
      <div class="el-btn-col">
        <div class="el-btn-col-box">
          <el-button type="primary" @click="publishInvite">发送</el-button>
        </div>
      </div>
  </el-dialog>
</template>

<script>
import { inviteMail } from '@/api/companyCen'

export default {
  data() {
    return {
      inviteDialogVisible: false,
      infoRow: {},
      companyId: ''
    }
  },
  methods: {
    queryInviteInfo(row) {
      var that = this
      if (row) {
        that.infoRow = row
        that.companyId = row.id
        setTimeout(function() {
          that.inviteDialogVisible = true
        }, 0)
      }
    },
    publishInvite() {
      var that = this
      that.$http.post(inviteMail, {
        id: that.companyId
      }, function(res) {
        if (res.success) {
          if (res.data === 0) {
            that.$message({
              message: '邮箱发送成功，请耐心等待',
              type: 'success'
            })
          }
          that.inviteDialogVisible = false
        }
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
  .dialog-invite .el-dialog__body{
    text-align: center;
    line-height: 32px;
    font-size: 16px;
    .invite-item{
      margin: 15px 0;
    }
    .el-btn-col{
      margin-top: 30px;
    }
  }
</style>
