...
|
...
|
@@ -12,6 +12,7 @@ const helpers = global.yoho.helpers; |
|
|
|
|
|
const shopHandler = require('./shop-handler');
|
|
|
const searchHandler = require('./search-handler');
|
|
|
const listHandler = require('./list-handler');
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const productProcess = require('../../../utils/product-process-simple');
|
|
|
|
...
|
...
|
@@ -48,8 +49,13 @@ function _getShopData(channel, params, shopInfo) { |
|
|
params = params || {};
|
|
|
|
|
|
let gender = _getGender(channel),
|
|
|
shopId = params.shopId;
|
|
|
shopId = params.shopId,
|
|
|
domain = params.domain;
|
|
|
let resData = {shopId: shopId};
|
|
|
const baseUrl = `/shop/${domain}-${shopId}`;
|
|
|
|
|
|
params.domain && delete params.domain;
|
|
|
params.shopId && delete params.shopId;
|
|
|
|
|
|
return co(function* () {
|
|
|
let result = yield Promise.props({
|
...
|
...
|
@@ -114,9 +120,9 @@ function _getShopData(channel, params, shopInfo) { |
|
|
if (result.sort.code === 200) {
|
|
|
let groupSort = _.get(result.sort, 'data', []);
|
|
|
|
|
|
resData.leftContent = searchHandler.handleSortData(groupSort, params, params, shopListUrl);
|
|
|
resData.leftContent = listHandler.handleSortData(groupSort, params, params, baseUrl);
|
|
|
|
|
|
_.set(resData, 'brandShopAd', {baseUrl: shopListUrl});
|
|
|
_.set(resData, 'brandShopAd', {baseUrl: baseUrl});
|
|
|
|
|
|
if (resData.allGoods) {
|
|
|
Object.assign(resData.allGoods, searchHandler.setShopSort(groupSort, Object.assign({},
|
...
|
...
|
@@ -206,9 +212,12 @@ function _getBaseShopData(channel, params, shopInfo) { |
|
|
params = params || {};
|
|
|
|
|
|
let searchParams = searchHandler.getSearchParams(params);
|
|
|
let shopId = params.shopId;
|
|
|
const shopId = params.shopId || params.shop_id;
|
|
|
const domain = params.domain;
|
|
|
const baseUrl = `/shop/${domain}-${shopId}`;
|
|
|
|
|
|
delete params.shopId;
|
|
|
params.shopId && delete params.shopId;
|
|
|
params.domain && delete params.domain;
|
|
|
|
|
|
return co(function* () {
|
|
|
let result = yield Promise.props({
|
...
|
...
|
@@ -268,7 +277,7 @@ function _getBaseShopData(channel, params, shopInfo) { |
|
|
|
|
|
// 获取左侧类目数据
|
|
|
if (result.sort.code === 200) {
|
|
|
let dps = {shopId: shopId};
|
|
|
let dps = {shop_id: shopId};
|
|
|
|
|
|
_.forEach(needParams, value => {
|
|
|
if (params[value]) {
|
...
|
...
|
@@ -277,14 +286,14 @@ function _getBaseShopData(channel, params, shopInfo) { |
|
|
});
|
|
|
|
|
|
Object.assign(resData.brand, {
|
|
|
leftContent: searchHandler.handleSortData(result.sort.data, dps, params)
|
|
|
leftContent: listHandler.handleSortData(result.sort.data, dps, params, baseUrl)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result.product.code === 200) {
|
|
|
let data = result.product.data;
|
|
|
let filters = Object.assign(searchHandler.handleFilterDataAll(data, params),
|
|
|
let filters = Object.assign(listHandler.handleFilterData(data, params, baseUrl),
|
|
|
_.get(resData, 'brand.leftContent.sort', {}));
|
|
|
|
|
|
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
|
...
|
...
|
@@ -292,12 +301,12 @@ function _getBaseShopData(channel, params, shopInfo) { |
|
|
|
|
|
Object.assign(resData.brand, {
|
|
|
filters: filters,
|
|
|
opts: searchHandler.handleOptsData(params, data.total, data.filter),
|
|
|
opts: listHandler.handleOptsData(params, data.total, data.filter, baseUrl),
|
|
|
totalCount: data.total,
|
|
|
footPager: searchHandler.handlePagerData(data.total, params),
|
|
|
footPager: listHandler.handlePagerData(data.total, params, false, baseUrl),
|
|
|
goods: productProcess.processProductList(data.product_list,
|
|
|
Object.assign({showDiscount: false, from: {type: 'shop', params: params}}, params)),
|
|
|
hasNextPage: searchHandler.handleNextPage(params, data.total),
|
|
|
hasNextPage: listHandler.handleNextPage(params, data.total, baseUrl),
|
|
|
|
|
|
// 最近浏览记录
|
|
|
latestWalk: 7
|
...
|
...
|
@@ -386,7 +395,7 @@ function getShopInfoAsync(domain, channel, params) { |
|
|
}).bind(this)();
|
|
|
}
|
|
|
|
|
|
function getShopListInfoAsync(channel, params) {
|
|
|
function _getShopListData(channel, params, shopInfo) {
|
|
|
let gender = _getGender(channel),
|
|
|
shopId = params.shopId,
|
|
|
navBar = params.navBar || 1;
|
...
|
...
|
@@ -396,7 +405,7 @@ function getShopListInfoAsync(channel, params) { |
|
|
return co(function* () {
|
|
|
let result = yield Promise.props({
|
|
|
header: headerModel.requestHeaderData(channel), // 头部数据
|
|
|
shopInfo: this.api.getShopInfo(shopId), // 店铺介绍
|
|
|
shopInfo: shopInfo ? shopInfo : this.api.getShopInfo(shopId), // 店铺介绍
|
|
|
decorator: this.searchApi.getShopDecorator(shopId), // 店铺装修数据
|
|
|
sort: this.searchApi.getSortList({shop_id: shopId}),
|
|
|
product: this.searchApi.getProductList(Object.assign(searchParams,
|
...
|
...
|
@@ -501,6 +510,29 @@ function getShopListInfoAsync(channel, params) { |
|
|
}).bind(this)();
|
|
|
}
|
|
|
|
|
|
// 基础店铺&经典店铺共用列表
|
|
|
function getShopListAsync(channel, params) {
|
|
|
let resData = {};
|
|
|
|
|
|
return co(function* () {
|
|
|
let result = yield this.api.getShopInfo(params.shopId);
|
|
|
let shopInfo = result.data;
|
|
|
|
|
|
// 根据店铺ID,未取到店铺信息,跳转至首页
|
|
|
if (result.code !== 200 || _.isEmpty(shopInfo)) {
|
|
|
return {redirect: helpers.urlFormat('')};
|
|
|
}
|
|
|
|
|
|
if (+shopInfo.shop_template_type === 2) { // 经典店铺
|
|
|
resData = yield this._getShopListData(channel, params, result);
|
|
|
} else {
|
|
|
resData = yield this._getBaseShopData(channel, params, shopInfo);
|
|
|
}
|
|
|
|
|
|
return Object.assign(resData, {templateType: +shopInfo.shop_template_type});
|
|
|
}).bind(this)();
|
|
|
}
|
|
|
|
|
|
function getShopGoodsData(shopId, channel, params) {
|
|
|
let gender = _getGender(channel);
|
|
|
let resData = {};
|
...
|
...
|
@@ -543,9 +575,10 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
this._getShopData = _getShopData.bind(this);
|
|
|
this._getBaseShopData = _getBaseShopData.bind(this);
|
|
|
this._getShopListData = _getShopListData.bind(this);
|
|
|
|
|
|
this.getShopInfoAsync = getShopInfoAsync.bind(this);
|
|
|
this.getShopListInfoAsync = getShopListInfoAsync.bind(this);
|
|
|
this.getShopListAsync = getShopListAsync.bind(this); // 基础店铺&经典店铺共用列表
|
|
|
this.getShopGoodsData = getShopGoodsData.bind(this);
|
|
|
}
|
|
|
|
...
|
...
|
|