require('common');

function setContYas(operid, params, flag) {
    params = $.extend({
        C_ID: window.queryString.yh_channel || window.cookie('yhChannel')
    }, params);

    if (window._yas && window._yas.sendCustomInfo) {
        let op,
            appop;

        if (typeof operid === 'object') {
            op = operid.op;
            appop = operid.appop;
        } else if (typeof operid === 'string') {
            op = operid;
        }

        window._yas.sendCustomInfo({
            op: op,
            appop: appop,
            param: JSON.stringify(params)
        }, flag);
    }
}

function countGoodsId() {
    let idStr = '';

    $('.installment-only .good-info').each(function(key, item) {
        if (key !== 0) {
            idStr += ',';
        }

        idStr += $(item).data('goodId');
    });

    return idStr;
}

exports.setContYas = setContYas;
exports.countGoodsId = countGoodsId;