Authored by 毕凯

Merge branch 'feature/shop-group' into 'release/6.6.1'

Feature/shop group



See merge request !1400
... ... @@ -109,3 +109,36 @@ exports.coupon = function(req, res, next) {
res.jsonp(result);
}).catch(next);
};
exports.shop = function(req, res, next) {
// let activity_template_id = req.query.activity_id;
let uid = req.user.uid || req.query.uid;
let app = req.query.app;
if (app && app.app_version && app.client_type && app.session_key && app.uid) {
uid = {
toString: () => {
return _.parseInt(app.uid);
},
sessionKey: app.session_key,
appVersion: app.app_version,
appSessionType: app.client_type
};
}
const params = Object.assign({
limit: 12,
yh_channel: (req.yoho.channel && channels[req.yoho.channel]) || '1',
imageType: req.query.displayStyle === '0' ? '1' : '2',
season: req.query.season || '1',
port: '1'
}, req.query.searchCondition);
if (uid && uid.toString()) {
params.uid = uid;
}
req.ctx(model).getShop(params).then((result) => {
res.jsonp(result);
}).catch(next);
};
... ...
... ... @@ -40,6 +40,13 @@ const _getProductBySkns = function(productObj, extraParams) {
* 获取店铺组店铺数据
*/
const _getShopGroup = (shopRawData) => {
// 个性化店铺组,前端去查询
if (shopRawData.searchCondition) {
shopRawData.individuation = true;
return Promise.resolve();
}
// 固定店铺组
return api.get('', {
method: 'app.shops.batchGetShops',
shop_ids: shopRawData.defaultShopIds
... ...
... ... @@ -79,6 +79,14 @@ class individuationModel extends global.yoho.BaseModel {
param: {cache: true}
});
}
getShop(params) {
return this.get({
data: Object.assign({
method: 'app.search.shopRecommend.template'
}, params),
param: {cache: true}
});
}
}
... ...
... ... @@ -264,6 +264,7 @@ router.get('/redbag/2017', redbag.index);
// 获取活动页面个性化推荐商品数据
router.get('/individuation', individuation.productLst);
router.get('/individuation/coupon', individuation.coupon);
router.get('/individuation/shop', individuation.shop);
// 活动页模版
router.get('/feature/:code.html', feature.index);
... ...
... ... @@ -101,7 +101,11 @@
{{#isEqualOr type 'shopGroup'}}
{{!-- 店铺组 --}}
{{#if individuation}}
<div class="shop-individuation" data-config="{{stringify this}}"></div>
{{else}}
{{> feature/shop-group}}
{{/if}}
{{/isEqualOr}}
{{#isEqualOr type 'productGroup'}}
... ...
<div class="shop-container{{#is-equal-or numOfOneRow '2'}} shop-two{{^}} shop-three{{/is-equal-or}} shop-individuation">
{{#renderData}}
{{#is-equal-or ../numOfOneRow '2'}}
<a href="{{href}}" class="pull-left shop-box">
<div class="shop-img">
<img class="left-icon" src="{{image2 ../lefTopImg q=85}}" alt="">
<img src="{{image2 shop_logo w=187 h=275 q=85}}" alt="">
</div>
<div class="shop-bottom-bar" style="background-image: url({{image2 ../brandImg w=290 h=60 q=85}})">
<span class="shop-name" style="{{#if ../shopNameFontColor}}color: {{../shopNameFontColor}}{{/if}}">{{shop_name}}</span>
</div>
</a>
{{^}}
<a href="{{href}}" class="pull-left shop-box {{#is-equal-or ../displayStyle '0'}}shop-logo{{/is-equal-or}}">
<div class="shop-img">
<img class="left-icon" src="{{image2 ../lefTopImg q=85}}" alt="">
<img src="{{image2 shop_logo w=156 h=106 q=85}}" {{#is-equal-or ../displayStyle '0'}}class="shop-logo-img"{{/is-equal-or}} alt="">
<span class="shop-name" style="{{#if ../shopNameFontColor}}color: {{../shopNameFontColor}}{{/if}}">{{shop_name}}</span>
</div>
<div class="shop-bottom-bar" style="background-image: url({{image2 ../brandImg w=290 h=60 q=85}});">
</div>
</a>
{{/is-equal-or}}
{{/renderData}}
</div>
... ...
... ... @@ -4,6 +4,7 @@ const Swiper = require('yoho-swiper');
const yoho = require('../yoho-app');
const qs = require('yoho-qs');
const cookie = require('yoho-cookie');
const shopTmpl = require('activity/feature/shop-group.hbs');
global.jQuery = $;
... ... @@ -260,6 +261,46 @@ function persenalCouponInit() {
});
}
function shopGroupInit() {
$('.shop-individuation').each(function() {
const $this = $(this);
const config = $this.data('config');
config.activity_id = $('.feature-page').data('id');
if (yoho.isApp) {
config.app = {
uid: cookie.get('app_uid') || qs.uid,
app_version: cookie.get('app_version') || qs.app_version,
client_type: cookie.get('app_client_type') || qs.client_type,
session_key: cookie.get('app_session_key') || qs.session_key
};
}
$.ajax({
url: '//m.yohobuy.com/activity/individuation/shop',
data: config,
dataType: 'jsonp'
}).then(res => {
if (res && res.data && res.data.length) {
config.renderData = res.data;
config.renderData.forEach(shop => {
if (config.jump2Shop === '0' && config.linkParams) {
shop.href = config.linkParams.replace(/\$shop_id/gi, shop.shops_id);
} else {
shop.href = `//m.yohobuy.com/product/shop?domain=${shop.shop_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${shop.shops_id},"shop_template_type":${shop.shop_template_type || "1"},"is_red_shop":${shop.is_red_shop || 1}}}`; // eslint-disable-line
}
});
$this.replaceWith(shopTmpl(config));
} else {
$this.remove();
}
});
});
}
$(function() {
if ($('.over').length) {
// 过期/删除 状态的 活动
... ... @@ -309,6 +350,9 @@ $(function() {
// 个性化券查询
persenalCouponInit();
// 个性化店铺组
shopGroupInit();
// 小程序相关处理
if (window.__wxjs_environment === 'miniprogram') {
require('./miniprogram');
... ...
... ... @@ -30,11 +30,21 @@ $shop-width-3: 187px;
top: 0;
z-index: 1;
}
.shop-name {
position: absolute;
margin-left: 0;
text-align: center;
left: 0;
bottom: 0;
width: 100%;
line-height: 50px;
}
}
.shop-name {
font-size: 24px;
margin-left: 5px;
margin-left: 8px;
white-space: nowrap;
width: 73%;
overflow: hidden;
... ... @@ -96,3 +106,48 @@ $shop-width-3: 187px;
}
}
}
/*
个性化店铺组与原有店铺组样式几乎完全不一样
*/
.shop-individuation {
&.shop-two,
&.shop-three {
margin-top: 10px;
}
&.shop-three {
padding-left: 32px;
.shop-box {
width: 184px;
margin-right: 8px;
.shop-bottom-bar {
height: 40px;
}
}
.shop-logo {
height: 126px;
margin-bottom: 8px;
.shop-bottom-bar,
.shop-name {
display: none;
}
.shop-img {
height: 100%;
}
.shop-logo-img {
position: relative;
width: 132px;
height: 88px;
left: 26px;
top: 20px;
}
}
}
}
... ...