Helper.js 963 Bytes

'use strict';


function excludeParams(groupParams, needGender=true){
    let newParams = {};
    try{
        let params = groupParams.toJS();

        for(let key in params){
            if(params[key]){
                newParams[key] = params[key]
            }
        }

        //gender 需要进行空处理,防止原生会添加默认值
        if(needGender && !newParams["gender"]){
            newParams["gender"] = "";
        }

        //size因为字段是关键字,使用了g_size替换
        if(newParams["g_size"]){
            newParams["size"] = newParams["g_size"];
            delete newParams["g_size"]
        }
    }catch(e){

    }

    return newParams;
}

function joinWxProgramPath(wxPath, groupParams){
    let params = excludeParams(groupParams, false);
    for(let key in params){
        wxPath = wxPath + "&" + key + "=" + params[key];
    }
    return wxPath;
}

module.exports = {
	excludeParams,
	joinWxProgramPath
};