shop-api.js 1.66 KB
/**
 * Created by TaoHuang on 2016/6/28.
 */
'use strict';

const config = global.yoho.config;

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    /**
     * 获取店铺装修的所有资源接口
     */
    shopsDecoratorListAsync(shopId) {
        return this.get({
            data: {
                method: 'app.shopsdecorator.getList',
                shop_id: shopId
            }, params: {cache: config.apiCache}
        });
    }

    /**
     * 获取店铺优惠券接口
     */
    shopCouponListAsync(shopId, uid) {
        let extra = {
            code: 200
        };

        if (!uid) {
            extra.cache = true;
        }

        return this.get({
            data: {
                method: 'shop.coupons.list',
                shop_id: shopId,
                uid: uid
            }, params: extra
        });
    }

    shopBannerAsync(shopId) {
        return this.get({
            data: {
                method: 'app.shop.banner',
                shop_id: shopId
            }
        });
    }

    queryShopsByBrandId(sid, bid) {
        return this.get({
            data: {
                method: 'app.product.queryShopsInfoById',
                brand_id: bid,
                shop_id: sid
            }
        });
    }

    /**
     * 根据shopId获取店铺基本信息
     * @return
     */
    getShopInfo(shopId, uid) {
        let finalParams = {
            method: 'app.shops.getIntro',
            shop_id: shopId || 0,
            uid: uid || 0
        };

        return this.get({
            data: finalParams,
            params: {cache: config.apiCache}
        });
    }
};