<template>
  <view class="container">
    <view class="box">
      <u-form :model="form" ref="uForm">
        <u-form-item label="姓名"><u-input v-model="form.realName" /></u-form-item>
        <u-form-item label="身份证号"><u-input v-model="form.idCard" /></u-form-item>
      </u-form>
      <button @click="toFac()">人脸识别</button>
    </view>
  </view>
</template>

<script>
  import uniWeb from '../static/uni.webview.1.5.4.js'
  export default {
    data() {
      return {
        form: {
          realName: '',
          idCard: '',
        }
      }
    },
    onLoad(options) {
      console.log('options===>', options)
    },
    methods: {
      toFac() {
        if (!this.form.realName) {
          uni.$u.toast('请先输入真实姓名');
        }
        if (!this.form.idCard) {
          uni.$u.toast('请先输入身份证号');
        }
        this.$http.post('/auth/build_fac', this.form).then(res => {
          try {
            uniWeb.webView.postMessage({
              data: res.data
            })
          } catch (err) {
            console.log('err==>', err)
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    // background: url('../static/img/loginBg.png');
    background-size: contain;
    position: relative;

    .box {
      padding: 30rpx;
      padding-top: 200rpx;
      word-break: break-all;
    }
  }
</style>