import { getTreeList } from '@/api/volunteer'

const sex_option = [
    {
        name: '男',
    },
    {
        name: '女',
    },
]

const city_option = [
    {
        name: '重庆',
    },
    {
        name: '四川',
    },
]

const rules = {
    name: [
        {
            type: 'string',
            required: true,
            message: '请填写姓名',
            trigger: ['blur', 'change']
        },
        {
            // 此为同步验证，可以直接返回true或者false，如果是异步验证，稍微不同，见下方说明
            validator: (rule, value, callback) => {
                // 调用uview-plus自带的js验证规则，详见：https://uview-plus.jiangruyi.com/js/test.html
                return uni.$u.test.chinese(value);
            },
            message: "姓名必须为中文",
            // 触发器可以同时用blur和change，二者之间用英文逗号隔开
            trigger: ["change", "blur"],
        },
    ],
    sex: [
        {
            type: 'string',
            max: 1,
            required: true,
            message: '请选择男或女',
            trigger: ['blur', 'change']
        }
    ],
    age: [
        {
            type: 'string',
            required: true,
            message: '请填写年龄',
            trigger: ['blur', 'change']
        }
    ],
    idCard: [
        {
            type: 'string',
            required: true,
            message: '请填写证件号',
            trigger: ['blur', 'change']
        }
    ],
    city: [
        {
            type: 'string',
            required: true,
            message: '请选择地区',
            trigger: ['blur', 'change']
        }
    ],
    address: [
        {
            type: 'string',
            required: true,
            message: '请填写地址',
            trigger: ['blur', 'change']
        }
    ],
    skillDescribe:[
        {
            type: 'string',
            required: true,
            message: '请填写技能简介',
            trigger: ['blur', 'change']
        }
    ],
    businessManagementId: [
        {
            type: 'string',
            required: true,
            message: '请选择服务项目',
            trigger: ['blur', 'change']
        }
    ]
}

//陪伴陪聊注册 1
const chatting = [
    {
        label: "姓名",
        key: "name",
        type: "input",
        rules: rules.name,
        required:true
    },
    {
        label: "性别",
        key: "sex",
        type: "select",
        option: sex_option,
        rules: rules.sex,
        required:true
    },
    {
        label: "年龄",
        key: "age",
        type: "input",
        rules: rules.age,
        required:true
    },
    {
        label: "手机号",
        key: "phonenumber",
        type: "phone-code",
    },
    // {
    //     label: "服务项目",
    //     key: "businessManagementId",
    //     type: "cascader",
    //     cascaderKey:'0',
    //     rules: rules.businessManagementId,
    //     required:true,
    //     apifun: ()=>{
    //         return new Promise((resolve, reject) => {
    //             getTreeList({ parentId: "1" }).then(res => {
    //                 resolve(res.data)
    //             })
    //         })
    //     },
    //     optionKey:'businessManagementOption'
    // },
    {
        label: "地区",
        key: "city",
        type: "city",
        option: city_option,
        rules: rules.city,
        required:true
    },
    {
        label: "详细地址",
        key: "address",
        type: "input",
        rules: rules.address,
        required:true
    },
    {
        label: "技能简介",
        key: "skillDescribe",
        type: "textarea",
        rules: rules.skillDescribe,
        required:true
    },
]

//孩子陪护(教育)2
const education = [
    {
        label: "姓名",
        key: "name",
        type: "input",
        rules: rules.name,
        required:true
    },
    {
        label: "性别",
        key: "sex",
        type: "select",
        option: sex_option,
        rules: rules.sex,
        required:true
    },
    {
        label: "年龄",
        key: "age",
        type: "input",
        rules: rules.age,
        required:true
    },
    {
        label: "手机号",
        key: "phonenumber",
        type: "phone-code",
    },
    // {
    //     label: "服务项目",
    //     key: "businessManagementId",
    //     type: "cascader",
    //     cascaderKey:'0',
    //     rules: rules.businessManagementId,
    //     required:true,
    //     apifun: ()=>{
    //         return new Promise((resolve, reject) => {
    //             getTreeList({ parentId: "2" }).then(res => {
    //                 resolve(res.data)
    //             })
    //         })
    //     },
    //     optionKey:'businessManagementOption'
    // },
    // {
    //     label: "证件号",
    //     key: "idCard",
    //     type: "input",
    //     rules: rules.idCard,
    //     required:true
    // },
    {
        label: "地区",
        key: "city",
        type: "city",
        option: city_option,
        rules: rules.city,
        required:true

    },
    {
        label: "详细地址",
        key: "address",
        type: "input",
        rules: rules.address,
        required:true
    },
    {
        label: "技能简介",
        key: "skillDescribe",
        type: "textarea",
        rules: rules.skillDescribe,
        required:true
    },
]


export { chatting,    education }