<template>
  <div class="welcome">
    <div class="top">
      <div class="pic">
        <img src="../../../assets/images/my_pay_01.png" />
      </div>
      <h1>欢迎您</h1>
      <p class="t1">
        申请紫荆-中国未来金融领袖计划项目，请在填写以下内容并<br />
        提交报名申请后，扫码支付本项目的申请费共计<span>800</span>元。
      </p>
    </div>
    <div class="form">
      <el-form :model="ruleForm" :rules="rules" label-width="70px" ref="ruleForm">
        <el-form-item label="姓名" prop="real_name_cn">
          <el-input v-model="ruleForm.real_name_cn"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="phone_number">
          <el-input v-model="ruleForm.phone_number" :maxlength="11"></el-input>
        </el-form-item>
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="ruleForm.email"></el-input>
        </el-form-item>
        <div class="buttons">
          <el-button type="primary" class="button-submit" @click="handleSubmit">提交</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
import * as api from '@/api/my'
export default {
  data() {
    return {
      material: {},
      progress: {},
      ruleForm: {
        real_name_cn: '',
        phone_number: '',
        email: ''
      },
      rules: {
        real_name_cn: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        phone_number: [{ required: true, pattern: /^1[3-9]\d{9}$/, message: '请输入手机号', trigger: 'blur' }],
        email: [{ type: 'email', required: true, message: '请输入邮箱', trigger: 'blur' }]
      }
    }
  },
  methods: {
    handleSubmit() {
      this.$refs.ruleForm.validate().then(this.handleSubmitRequest)
    },
    handleSubmitRequest() {
      const params = {
        basic_info: this.ruleForm
      }
      api.updateApplication(params).then(response => {
        if (response.error === '0') {
          this.$emit('update', response.data)
        } else {
          this.$message({ type: 'error', message: response.message })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.welcome {
  margin: 0 auto;
  padding: 20px 0;
}
.top {
  padding: 40px 0;
  .pic {
    text-align: center;
  }
  h1 {
    padding: 20px 0;
    font-size: 24px;
    font-weight: 500;
    color: #222;
    line-height: 1;
    text-align: center;
  }
}
.t1 {
  font-size: 14px;
  color: #262626;
  line-height: 20px;
  text-align: center;
  span {
    color: #ffa448;
  }
}
.buttons {
  text-align: center;
}
.button-submit {
  width: 100px;
  margin: 0 auto;
}
.form {
  max-width: 350px;
  margin: 0 auto;
}
</style>
