<template>
    <view class="app_cotainer">
        <u--form labelPosition="left" :fromData="formValues" :model="formValues" :rules="rules" ref="uForm">
            <u-form-item labelWidth="70" label="姓名" prop="name" borderBottom>
                <u--input v-model="formValues.name" placeholder="请输入姓名"></u--input>
            </u-form-item>
            <u-form-item labelWidth="70" label="身份证" prop="idNumber" borderBottom>
                <u--input v-model="formValues.idNumber" placeholder="请输入身份证"></u--input>
            </u-form-item>
            <u-form-item labelWidth="70" label="手机号" prop="phone" borderBottom>
                <u--input v-model="formValues.phone" placeholder="请输入手机号"></u--input>
            </u-form-item>
            <u-form-item labelWidth="70" label="求职意愿" prop="willingJob" borderBottom>
                <u--input v-model="formValues.willingJob" placeholder="请输入求职意愿"></u--input>
            </u-form-item>
            <u-form-item labelWidth="70" label="期望薪资" prop="wage" borderBottom>
                <u--input type="number" v-model="formValues.wage" placeholder="请输入期望薪资"></u--input>
            </u-form-item>
        </u--form>
        <view class="btn_add">
            <u-button type="primary" size="large" text="提交信息" @click="confrim"></u-button>
        </view>
    </view>
</template>

<script>
    import {
        dateFormat
    } from '@/untils/format.js'
    import {
        setPeopleRegister
    } from '@/api/admin.js'
    import {
        addSuperviseComplaintInfo
    } from '@/api/content'
    const formData = {
        name: '',
        idNumber: '',
        phone: '',
        wage: '',
        willingJob: '',
    }
    const rules = {
        'name': {
            type: 'string',
            required: true,
            message: '请输入姓名',
            trigger: ['blur', 'change']
        },
        'idNumber': {
            type: 'string',
            required: true,
            pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
            message: '请输入身份证',
            trigger: ['blur', 'change']
        },
        'phone': {
            type: 'string',
            required: true,
            pattern: /^1[3-9]{1}\d{9}/,
            message: '请填写联系方式',
            trigger: ['blur', 'change']
        },
        "willingJob": {
            type: 'string',
            required: true,
            message: '请输入求职意愿',
            trigger: ['blur', 'change']
        },
        "wage": {
            type: 'number',
            required: true,
            min: 0,
            message: '请输入期望薪资',
            trigger: ['blur', 'change']
        },
    }
    export default {
        data() {
            return {
                formValues: Object.assign({}, formData),
                rules: Object.assign({}, rules),
            };
        },
        onLoad() {},
        computed: {},
        methods: {
            confrim() {
                this.$refs.uForm.validate().then(async (res) => {
                    let params = {
                        ...this.formValues,
                    }
                    uni.showLoading({
                        title: '请求中'
                    })
                    let resData = await setPeopleRegister(params)
                    uni.hideLoading()
                    if (resData.data?.code === 200) {
                        uni.$u.toast(resData.data.msg)
                        this.$api.sleep(1000).then(() => {
                            uni.navigateBack(1)
                        })
                    }
                }).catch((errors) => {
                    if (/[\u4e00-\u9fff]/.test(errors.message)) {
                        this.$api.msg(errors.message)
                    } else {
                        this.$api.msg('请输入信息')
                    }
                })
            }
        }
    }
</script>

<style lang="scss" scoped>
    .app_cotainer {
        padding: 24rpx;

        .picker_flag {
            // border: 0;
            // height: auto;
            display: flex;
            justify-content: flex-start;
            padding: 0;
        }

        .reply_info {}

        .btn_add {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 110rpx;
            background-color: $uni-bg-color-grey;
            padding: 24rpx 24rpx calc(10px + env(safe-area-inset-bottom) / 2) 24rpx;
            text-align: center;
            line-height: 110rpx;
        }
    }
</style>