index.js 1.01 KB

let apiUrl = {
    brand: '/platform/getSellerBrandInfo',
    sort: '/platform/getSellerSortInfo',
    color: '/platform/querySellerProductColors',
    size: '/platform/querySortSize'
};

const request = require('axios');

function getBrand(shopId) {
    return request.get(apiUrl.brand, {
        params: {
            shopsId:shopId
        }
    }).then((result) => result.data)
}

function getSort(shopId, brandId, level , sortId) {
    let opts = {
        shopsId: shopId,
        brandId: brandId,
        level: level
    };

    if (sortId) {
        Object.assign(opts, {sortId});
    }

    return request.get(apiUrl.sort, {
        params: opts
    }).then((result) => result.data);
}

function getColor() {
    return request.get(apiUrl.color).then((result) => result.data)
}

function getSize(smallSortId) {
    return request.get(apiUrl.size, {
        params: {
            sortId: smallSortId
        }
    }).then(result => result.data)
}

export default {
    getBrand,
    getSort,
    getColor,
    getSize
}