yoho-plugin-helper.js 742 Bytes
/**
 * Created by TaoHuang on 2017/5/11.
 */

/**
 * 使用skn ,sku 拿到商品图片
 * @param skn
 * @param sku
 * @param size
 * @returns {string}
 */
function sknImage ({skn, sku, size}) {
    let baseUrl = '/Api/platform/getRemoteImageUrlBySku';
    let params = [];

    if (skn) {
        params.push(`skn_id=${skn}`);
    }

    if (sku) {
        params.push(`sku_id=${sku}`);
    }

    params.push(size ? `size=${size}` : 'size=80x80');

    return `${baseUrl}?${params.join('&')}`;
}

let helper = {
    install(vue) {
        Object.defineProperty(vue.prototype, '$helper', {
            get(){
                return {
                    sknImage
                }
            }
        });
    }
};

export default helper;