/**
 * 简单验证 字段是否空
 * @param {*} allParam 
 * @param {*} validParam 
 */
function validParamIsEmpty(allParam, validParam) {

    for (let key in validParam) {
        if (!allParam[key]) {
            return { "code": -1, "msg": validParam[key] }
        }
    }
    return { "code": 0, "msg": "success" }

}

/**
 * 将表单序列化的字段转换为对象格式
 * @param {*} allParam 
 */
function serializeArrayToObj(arrayParam) {
    let objParam = {};
    for (let key in arrayParam) {
        objParam[arrayParam[key].name] = arrayParam[key].value
    }
    return objParam;
}

function checkEmailFormat() {

}

function checkMobileFormat() {

}

function checkPhoneFormat(obj) {
    var phone = {};
    phone.status = true;

    if (!obj) {
        phone.status = false;
        phone.message = '请输入手机号码'
    } else {
        let telre = /^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])\d{8}$/;
        if (!telre.test(obj)) {
            phone.status = false;
            phone.message = '请输入正确的手机号码'
        }
    }
    return phone;
}

function checkAgeFormat(obj) {
    var age = {};
    age.status = true;

    if (!obj) {
        age.status = false;
        age.message = '请填写年龄'
    } else {
        let pattern = /^(([0-9]|[1-9][1-9]|1[0-7][0-9])(\\.[0-9]+)?|180)$/;
        if (!pattern.test(obj)) {
            age.status = false;
            age.message = '请输入正确的年龄'
        }
    }
    return age;
}