<script setup>
import {reactive, ref} from "vue";
import XInfoModal from "../../../components/XInfoModal.vue";
import XForm from "../../../components/XForm.vue";
import XFormItem from "../../../components/XFormItem.vue";
import XInput from "../../../components/XInput.vue";
import SendMsg from "../../../components/SendMsg.vue";

const XFormRef = ref();
const show = defineModel('show');
const rules = {
    oldPhone: {
        reg: /^\[1][3-9]\d{9}$/,
        msg: '请输入正确的手机号',
    },
    oldVerificationCode: {
        reg: /.+/,
        msg: '请输入正确的手机号',
    },
    newPhone: {
        reg: /^\[1][3-9]\d{9}$/,
        msg: '请输入正确的手机号',
    },
    newVerificationCode: {
        reg: /.+/,
        msg: '请输入正确的手机号',
    },
};
const form = reactive({
    oldPhone: null,
    oldVerificationCode: null,
    newPhone: null,
    newVerificationCode: null,
});

const success = () => {
    XFormRef.value.verify();
}
</script>

<template>
    <x-info-modal v-model:show="show" @success="success">
        <view class="title">更换手机号</view>

        <x-form ref="XFormRef" :model="form" :rules="rules">
            <x-form-item label="原手机号">
                <x-input height="72rpx" placeholder="原手机号" v-model:model-value="form.oldPhone"></x-input>
            </x-form-item>
            <x-form-item label="验证码">
                <send-msg height="72rpx" v-model:model-value="form.oldVerificationCode"></send-msg>
            </x-form-item>
            <x-form-item label="原手机号">
                <x-input height="72rpx" placeholder="新手机号" v-model:model-value="form.oldPhone"></x-input>
            </x-form-item>
            <x-form-item label="验证码">
                <send-msg height="72rpx" v-model:model-value="form.newVerificationCode"></send-msg>
            </x-form-item>
        </x-form>
    </x-info-modal>
</template>

<style scoped lang="scss">
.title {
    color: rgb(29, 33, 41);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0;
    text-align: center;
    margin-bottom: 20rpx;
}
</style>
