Authored by 王水玲

Merge branch 'release/5.2' of git.yoho.cn:fe/yohobuywap-node into release/5.2

... ... @@ -10,7 +10,7 @@ exports.index = (req, res, next) => {
token: params.token,
}).then(result => {
params.token = result;
params.uname = decodeURIComponent(params.uname);
params.uname = decodeURIComponent(params.uname.replace(/\%/g, escape('%')));
params.icon = params.icon || 'https://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/2/w/{width}/h/{height}';
res.render('myqrcode', {
title: '查看二维码',
... ...
... ... @@ -38,13 +38,16 @@ const _getUidFromUserAgent = (req) => {
*/
const _baseShop = (req, res, shopInfo, shopId) => {
listModel.getBaseShopData(req.query, shopInfo).then(result => {
listModel.getBaseShopData(Object.assign(req.query, {
channel: req.yoho.channel
}), shopInfo).then(result => {
if (result && result.baseShopHome && result.baseShopHome.banner) {
if (result.baseShopHome.banner.indexOf('?') < 0) {
result.baseShopHome.banner += '?imageMogr2/auto-orient/strip/thumbnail/x150/crop/640x150';
}
}
res.render('search/goods-list', {
res.render('search/goods-list', Object.assign({
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
... ... @@ -53,12 +56,9 @@ const _baseShop = (req, res, shopInfo, shopId) => {
goodList: result,
showDownloadApp: true,
pageFooter: true,
title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰',
description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
shopId: shopId,
shopPage: true
});
}, result.seoResult));
});
};
... ... @@ -142,19 +142,16 @@ const _shop = (req, res, shopId) => {
// 有领券功能,不缓存
res.set('Cache-Control', 'no-cache');
res.render('shop/index', {
res.render('shop/index', Object.assign({
module: 'product',
page: 'shop',
shopIndex: result,
shopHeadHide: true,
gender: req.query.gender,
channel: req.query.channel,
title: result.seoTitle + '|' + result.seoTitle + '潮流服装服饰-Yoho!Buy有货',
keywords: result.seoTitle + ',' + result.seoTitle + '服装服饰,' + result.seoTitle + '潮流服装服饰',
description: result.seoTitle + '|Yoho!Buy有货' + result.seoTitle + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
shopId: shopId,
shopPage: true
});
}, result.seoResult));
});
}
... ... @@ -273,11 +270,13 @@ const brand = (req, res, next) => {
if (req.query.from !== 'search' && brandLogo.type === '2' && brandLogo.shopId) {
_shop(req, res, brandLogo.shopId);
} else { // 获取品牌店铺信息
listModel.getBrandShops(brandId).then(brandShop => {
listModel.getBrandShops(brandId, req).then(brandShop => {
if (brandId === 0) {
params.query = domain;
}
params.seoResult = brandShop.seoResult;
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息 或者品牌关联多店铺
if (req.query.from === 'search' || brandShop.length > 0) {
params = _.assign({
... ... @@ -304,7 +303,7 @@ const brand = (req, res, next) => {
res.set('Cache-Control', 'no-cache');
}
res.render('search/goods-list', {
res.render('search/goods-list', Object.assign({
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
... ... @@ -313,12 +312,9 @@ const brand = (req, res, next) => {
goodList: params,
showDownloadApp: true,
pageFooter: true,
title: title + '|' + title + '潮流服装服饰-Yoho!Buy有货',
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
domain: req.query.domain,
shopPage: true
});
}, params.seoResult));
});
}
}).catch(next);
... ...
... ... @@ -1470,7 +1470,15 @@ const _detailDataPkg = (origin, ua) => {
dest.introUrl = '/product/detail/intro/' + origin.product_skn;
dest.id = origin.product_id;
dest.goodsId = origin.goods_id;
dest.isDepositAdvance = origin.is_deposit_advance === 'Y'; // 是否定金预售
dest.isSeckill = origin.is_secKill === 'Y'; // 是否秒杀
dest.isLimitBuy = origin.isLimitBuy; // 是否 限购
dest.isPresale = Boolean(origin.expect_arrival_time); // 是否普通预售
// 自定义 属性
dest.showCoupon = !(
dest.isDepositAdvance || dest.isSeckill || dest.isLimitBuy || dest.isPresale
); // 商品有限购、秒杀、定金预售、普通预售 不显示领券
return dest;
... ... @@ -1586,7 +1594,8 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
}
if (origin.is_secKill) {
dest.isDepositAdvance = origin.is_deposit_advance;// 判断定金预售字段
dest.isDepositAdvance = origin.isDeposit_advance;// A定金预售字段 = origin.is_deposit_advance === 'Y'; // 是否定金预售
dest.isPresale = Boolean(origin.expect_arrival_time)
}
// 商品返回 YOHO 币
... ...
... ... @@ -51,7 +51,11 @@ const _processBrandShops = (list) => {
*/
const _modifyWapUrl = (origin, shopId) => {
if (parseInt(_.get(origin, 'linkType', 0), 10) === 1) {
return helpers.urlFormat('', {filter_poolId: origin.categoryId, shop_id: shopId, title: origin.categoryName}, 'search'); //eslint-disable-line
return helpers.urlFormat('', {
filter_poolId: origin.categoryId,
shop_id: shopId,
title: origin.categoryName
}, 'search'); //eslint-disable-line
} else {
if (_.has(origin, 'url')) {
return origin.url;
... ... @@ -135,7 +139,71 @@ const _getShopCategory = (shopId, channel, gender) => {
};
/**
* TODO TAR 店铺和品牌收藏状态调用新的接口
* 处理店铺或者品牌 seo 数据
* @param channel
* @param info
* @param qs
* @returns {{}}
* @private
*/
const _getBrandShopSeo = (channel, info, qs) => {
let resData = {},
ctype = {
boys: {fashionType: '男装', brandType: '男生品牌'},
girls: {fashionType: '女装', brandType: '女生品牌'},
kids: {fashionType: '童装', brandType: '潮童品牌'},
lifestyle: {fashionType: '创意生活', brandType: '创意生活品牌'}
};
let params = {
nameEn: '',
name: ''
};
if (info) {
Object.assign(params, {
nameEn: _.get(info, 'brand_name_en', ''),
nameCn: _.get(info, 'brand_name_cn', ''),
name: _.get(info, 'brand_name', '')
});
params.name = `${params.nameEn} ${params.nameCn} ${params.name}`;
if (info.shop_name) {
Object.assign(params, {
nameEn: info.shop_name,
name: info.shop_name
});
}
}
if (qs && qs.gender) {
if (qs.gender === '1,3') {
channel = 'boys';
} else if (qs.gender === '2,3') {
channel = 'girls';
}
Object.assign(params, ctype[channel] || ctype.boys);
Object.assign(resData, {
title: `${params.nameEn} | ${params.name} ${params.brandType}`,
keywords: `${params.nameEn}, ${params.name} ${params.fashionType},${params.nameEn} ${params.brandType}`,
description: `${params.nameEn}正品网购。${params.name}官方授权!`
});
} else {
Object.assign(resData, {
title: `${params.nameEn} | ${params.name}官网`,
keywords: `${params.nameEn}, ${params.name}官网`,
description: `${params.nameEn}正品网购。${params.name}官方授权!`
});
}
resData.title += resData.title ? ' | YOHO!有货 100%正品保证' : '';
resData.description += resData.description ? ' YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。' : ''; // eslint-disable-line
return resData;
};
/**
*
* 调用接口获取品牌或者店铺的收藏状态
* @private
*/
... ... @@ -436,8 +504,11 @@ const _formShopData = (data, shopId, isApp) => {
*/
const getBaseShopData = (params, shopInfo) => {
/* tar add 161109 seo-info */
let seoResult = _getBrandShopSeo(params.channel, shopInfo, params);
let finalResult = {
cartUrl: helpers.urlFormat('/cart/index/index')
cartUrl: helpers.urlFormat('/cart/index/index'),
seoResult: seoResult
};
let shopId = params.shop_id || shopInfo.shops_id;
... ... @@ -490,6 +561,8 @@ const getShopData = (req, shopId, uid, isApp) => {
return _getShopInfo(shopId, uid).then(shopInfoResult => {
let seoResult = _getBrandShopSeo(channel, shopInfoResult, req.query);
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
return {
... ... @@ -515,7 +588,7 @@ const getShopData = (req, shopId, uid, isApp) => {
return Promise.all([
searchModel.getFilterSearchData({
shop_id: shopId,
type: 'default',//默认
type: 'default', // 默认
brand: brandData.join(','),
order: '0',
channel: channel
... ... @@ -551,7 +624,8 @@ const getShopData = (req, shopId, uid, isApp) => {
{
shopId: shopId,
uid: uid ? crypto.encryption('', uid + '') : '',
coverChannel: channel
coverChannel: channel,
seoResult: seoResult
}
);
});
... ... @@ -662,9 +736,10 @@ const getBrandLogoByDomain = (domain) => {
/**
* 根据brandId 获取相关店铺列表
* @param brandId
* @param req
* @return array
*/
const getBrandShops = (brandId) => {
const getBrandShops = (brandId, req) => {
return api.get('', {
method: 'app.shop.queryShopsByBrandId',
brand_id: brandId
... ... @@ -673,7 +748,9 @@ const getBrandShops = (brandId) => {
cache: true
}).then(result => {
if (_.isArray(result.data)) {
return _processBrandShops(result.data);
let seoResult = _getBrandShopSeo(req.channel, result.data[0], req.query);
return Object.assign(_processBrandShops(result.data), {seoResult: seoResult});
} else {
return [];
}
... ... @@ -784,9 +861,8 @@ const getShopCategory = (params) => {
/**
* 获取店铺优惠券列表
* @param {[int]} shop_id 店铺id
* @param {[int]} uid 当前用户id,空则不传
* @return {[array]}
* @param params
*/
const shopCouponsList = (params) => {
return api.get('', Object.assign({
... ...
... ... @@ -165,6 +165,7 @@
<input id="productSkn" type="hidden" value="{{productSkn}}">
<input id="brand-id" type="hidden" value="{{brandId}}">
<input id="product-limit" type="hidden" value="{{isLimitBuy}}">
<input id="product-coupon-switch" type="hidden" value="{{showCoupon}}">
<input type="hidden" class="data-bind" name="loginUrl" id="loginUrl" value="">
... ...
... ... @@ -19,3 +19,18 @@ function async_load(){
}
window.addEventListener('load', async_load, false);
</script>
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
... ...
... ... @@ -28,3 +28,7 @@ if ($('#remove-cart-count').length) {
});
}
/* tar add 161121 app del suspend cart */
if (queryString.app_version || queryString.appVersion) {
$('.suspend-cart').css('display', 'none');
}
... ...
... ... @@ -151,7 +151,9 @@ require('./detail/page-render')(function() {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
}
});
require('./detail/brand-coupon');
$(function() {
if ($('#product-coupon-switch').val() === 'true') {
require(['./detail/brand-coupon']); // amd
}
});
... ...
'use strict';
/**
* 商品详情: 品牌券
*/
var tip = require('plugin/tip');
var $ = require('yoho-jquery');
var $body = $(document.body);
var brandCoupon = {
skn: null,
brandId: null,
$entry: null,
$couponDrawer: null,
template: require('product/detail/coupon-list.hbs'),
init: function(skn, brandId) {
var self = this;
this.skn = skn;
this.brandId = brandId;
if (!(skn && brandId)) {
return;
}
this.fetchCoupons(this.skn, this.brandId)
.done(function(data) {
if (data.length) {
self.render(data);
self.domInit();
self.bindEvents();
/* global define */
// amd
define(function(require) {
'use strict';
/**
* 商品详情: 品牌券
*/
var tip = require('plugin/tip');
var $ = require('yoho-jquery');
var $body = $(document.body);
var brandCoupon = {
skn: null,
brandId: null,
$entry: null,
$couponDrawer: null,
template: require('product/detail/coupon-list.hbs'),
init: function(skn, brandId) {
var self = this;
this.skn = skn;
this.brandId = brandId;
if (!(skn && brandId)) {
return;
}
self.$entry.removeClass('hide');
this.fetchCoupons(this.skn, this.brandId)
.done(function(data) {
if (data.length) {
self.render(data);
self.domInit();
self.bindEvents();
self.$entry.removeClass('hide');
}
})
.fail();
},
domInit: function() {
this.$entry = $('.brand-coupon').removeClass('hide');
},
bindEvents: function() {
var self = this;
this.$entry.on('click', function() {
self.toggleDrawer(true);
});
this.$couponDrawer
.on('click', '.coupon-drawer-mask', $.proxy(this.toggleDrawer, this, false))
.on('click', '.coupon-btn-valid', $.proxy(this.saveCouponHandler, this));
},
render: function(data) {
this.$couponDrawer = $(this.template({
coupons: data
}));
this.$couponDrawer.appendTo('.good-detail-page');
return this;
},
// 获取 品牌券
fetchCoupons: function(skn, brandId) {
return $.get('/product/detail/coupon.json', {
skn: skn,
brandId: brandId
});
},
saveCoupon: function(couponId, callback) {
$.post('/product/detail/coupon/save.json', {
couponId: couponId
}).done(function(res) {
tip.show(res.message);
if (res.code === 200) {
callback(); // eslint-disable-line
} else {
tip.show(
res.message || '抱歉,您不符合领用条件'
);
if (res.redirect) {
setTimeout(function() {
location.href = res.redirect;
}, 1000);
}
}
})
.fail();
},
domInit: function() {
this.$entry = $('.brand-coupon').removeClass('hide');
},
bindEvents: function() {
var self = this;
this.$entry.on('click', function() {
self.toggleDrawer(true);
});
this.$couponDrawer
.on('click', '.coupon-drawer-mask', $.proxy(this.toggleDrawer, this, false))
.on('click', '.coupon-btn-valid', $.proxy(this.saveCouponHandler, this));
},
render: function(data) {
this.$couponDrawer = $(this.template({
coupons: data
}));
this.$couponDrawer.appendTo('.good-detail-page');
return this;
},
// 获取 品牌券
fetchCoupons: function(skn, brandId) {
return $.get('/product/detail/coupon.json', {
skn: skn,
brandId: brandId
});
},
saveCoupon: function(couponId, callback) {
$.post('/product/detail/coupon/save.json', {
couponId: couponId
}).done(function(res) {
tip.show(res.message);
if (res.code === 200) {
callback(); // eslint-disable-line
} else {
tip.show(
res.message || '抱歉,您不符合领用条件'
);
if (res.redirect) {
setTimeout(function() {
location.href = res.redirect;
}, 1000);
}
}
}).fail(function() {
tip.show('网络异常,请稍后再试');
});
},
// 收藏 品牌券
saveCouponHandler: function(event) {
var $btn = $(event.target);
var couponId = $btn.closest('.coupon').data('coupon');
this.saveCoupon(couponId, function() {
$btn.prop('disabled', true)
.removeClass('coupon-btn-valid')
.text('已领取');
});
event.stopPropagation();
},
toggleDrawer: function(bool) {
this.$couponDrawer.toggleClass('open', bool);
$body.toggleClass('coupon-drawer-open', bool);
}
};
$(function() {
if ($('#product-limit').val() !== '0') { // 限购商品 不展示优惠券
return;
}
}).fail(function() {
tip.show('网络异常,请稍后再试');
});
},
// 收藏 品牌券
saveCouponHandler: function(event) {
var $btn = $(event.target);
var couponId = $btn.closest('.coupon').data('coupon');
this.saveCoupon(couponId, function() {
$btn.prop('disabled', true)
.removeClass('coupon-btn-valid')
.text('已领取');
});
event.stopPropagation();
},
toggleDrawer: function(bool) {
this.$couponDrawer.toggleClass('open', bool);
$body.toggleClass('coupon-drawer-open', bool);
}
};
brandCoupon.init(
$('#productSkn').val(),
... ...
... ... @@ -35,9 +35,8 @@
}
.banner-swiper {
position: relative;
position: static;
height: 312px;
overflow: hidden;
ul {
position: relative;
... ...