shop.js 1.91 KB
/**
 * Created by PhpStorm.
 * User: Targaryen
 * Date: 2016/7/26
 * Time: 10:34
 */
'use strict';

const mRoot = '../models';
const shopModel = require(`${mRoot}/shop`);

module.exports = {

    /* 品牌店铺页面 */
    index: (req, res) => {
        res.render('shop/index', {
            module: 'product',
            page: 'shop'
        });
    },

    /* 获取品牌店铺介绍 */
    getShopInfo: (req, res, next) => {
        shopModel.getShopData({
            domain: req.query.domain,
            uid: req.user.uid
        }).then(result => {
            res.json(result);
        }).catch(next);
    },

    /* 获取商品列表 */
    getBrandShopGoods: (req, res, next) => {
        let filter = req.body.filter || {};

        shopModel.getBrandShopGoodsData({
            domain: filter.domain,
            sort: req.body.sort,
            page: req.body.page,
            channel: filter.channel || 'men',
            gender: filter.gender || '1,2,3',
            brand: filter.brand,
            shopId: filter.shopId,
            order: filter.order || 's_t_desc',
            limit: filter.limit || '60',
            color: filter.color,
            price: filter.price,
            size: filter.size,
            pd: filter.pd,
            tagsFilter: filter.tagsFilter
        }).then(result => {
            res.json(result);
        }).catch(next);
    },

    /* 收藏店铺 */
    collectShop: (req, res, next) => {
        shopModel.collectShopData({
            shopId: req.body.shopId,
            favId: req.body.favId,
            uid: req.user.uid,

            // uid: '8050882',
            type: 'shop',
            isFav: req.body.isFav
        }).then(result => {
            res.json(result);
        }).catch(next);
    },

    /* 品牌店铺分享页面 */
    shopShare: (req, res) => {
        res.render('shop/share', {
            module: 'product',
            page: 'shop-share'
        });
    }
};