Authored by 陈峰

修复商品详情、品牌搜索的pagecache的bug

... ... @@ -1163,7 +1163,6 @@ const _detailDataPkg = (origin, ua) => {
dest.feedbacks = {};
return dest;
}
dest.goodsName = origin.product_name;
// 是否是虚拟商品
... ... @@ -1561,6 +1560,12 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
refer: helpers.urlFormat('/product/show_' + origin.product_skn + '.html')
});
}
// 商品名称
if (!origin.product_name) {
dest.feedbacks = {};
return dest;
}
dest.goodsName = origin.product_name;
// 商品促销短语
origin.sales_phrase && (dest.goodsSubtitle = origin.sales_phrase);
... ... @@ -1684,7 +1689,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
// 缩略图
thumbImageList.push({
img: value.color_image
img: helpers.image(value.color_image, 60, 60)
});
// 商品库存总数
... ... @@ -1767,7 +1772,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
colors: _.toArray(colorGroup),
sizes: sizeGroup
});
// 限购商品
if (origin.isLimitBuy) {
return api.get('', {
... ...
... ... @@ -17,12 +17,12 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
// api: 'http://api.yoho.cn/',
api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
api: 'http://api-test1.yohops.com:9999/',
// api: 'http://api-test1.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test1.yohops.com:9999/',
... ...
{{#cartInfo}}
<div class="chose-panel">
<div class="chose-panel data-bind">
<div class="main">
<div class="infos {{#if ../tickets}}tickets-info{{/if}}">
<div class="infos">
<div class="basic-info" >
{{#thumbs}}
<img class="thumb {{#unless @first}}hide{{/unless}}" src={{image img 60 60}}>
{{/thumbs}}
<img class="thumb" src="">
<div class="text-info">
<p class="name">{{name}}</p>
<p class="name"></p>
<p class="price">
<span class="sale-price{{^price}} no-price{{/price}}">{{salePrice}}</span>
{{#if price}}
<span class="market-price">{{price}}</span>
{{/if}}
<span class="sale-price"></span>
<span class="market-price data-bind"></span>
</p>
</div>
</div>
<div class="chose-items">
<div class="color-list block-list">
<span>{{#if ../tickets}}日期{{else}}颜色{{/if}}</span>
{{# colors}}
<ul id="{{id}}" data-index="{{@index}}" class="size-row clearfix {{#unless @first}}hide{{/unless}}">
{{# color}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}" data-num="{{colorNum}}">
{{name}}
<span class="name"></span>
<ul id="" data-index="" class="size-row clearfix ">
<li class="block" data-num="">
</li>
{{/ color}}
</ul>
{{/ colors}}
</div>
<div class="size-list block-list {{#if ../single}}hide{{/if}}">
<span>{{#if ../tickets}}区域{{else}}尺码{{/if}}</span>
{{# sizes}}
<ul class="size-row clearfix {{#unless @first}}hide{{/unless}}">
{{# size}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-num="{{sizeNum}}" data-id="{{id}}" data-skuid="{{skuId}}">
{{name}}
<div class="size-list block-list">
<span class="name"></span>
<ul class="size-row clearfix">
<li class="block " data-num="" data-id="" data-skuid="">
</li>
{{/ size}}
</ul>
{{/ sizes}}
</div>
<div class="num">
<span>数量</span>
<span class="name">数量</span>
<div class="clearfix">
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont {{#if promotionId}}disabled{{/if}}">&#xe625;</span>
<span class="iconfont ">&#xe625;</span>
</a>
<input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont {{#if promotionId}}disabled{{/if}}">&#xe624;</span>
<span class="iconfont ">&#xe624;</span>
</a>
</div>
<span class="left-num"></span>
<input id="left-num" type="hidden" value="0">
<input id="limitNum" type="hidden" value="{{limit}}">
<input id="limitNum" type="hidden" value="">
</div>
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure">{{#if ../tickets}}立即购买{{else}}加入购物车{{/if}}</button>
<button id="chose-btn-sure" class="btn btn-sure"></button>
</div>
</div>
</div>
{{/cartInfo}}
<input id="promotionId" type="hidden" value="{{promotionId}}">
<input id="single" type="hidden" value="{{single}}">
\ No newline at end of file
<input id="promotionId" type="hidden" value="">
<input id="single" type="hidden" value="">
\ No newline at end of file
... ...
... ... @@ -13,7 +13,6 @@ module.exports = function(callback) {
});
};
function render(data) {
console.log(data)
if (data.history && data.history.list && data.history.list.length) {
var hisEl = $('.history>li').remove();
$.each(data.history.list, function(i, his) {
... ...
... ... @@ -106,7 +106,7 @@ function searchInput() {
function isLocalStorageSupported() {
var testKey = 'test',
storage = Window.prototype.localStorage;
storage = Window.prototype.localStorage || window.localStorage;
try {
storage.setItem(testKey, 'testValue');
... ...
var $ = require('yoho-jquery'),
dbClass = 'data-bind',
$chosePanel = $('.chose-panel');
module.exports = function(data, callback) {
render(data);
callback && callback();
};
function render(data) {
if (data.cartInfo) {
$chosePanel.removeClass(dbClass);
var cartInfo = data.cartInfo;
var thumbClone = $chosePanel.find('.thumb').remove();
for (var i = 0; i < cartInfo.thumbs.length; i++) {
var thumbEle = thumbClone.clone();
thumbEle.attr('src', cartInfo.thumbs[i].img)
if (i != 0) {
thumbEle.addClass('hide');
}
$chosePanel.find('.basic-info').prepend(thumbEle);
}
$chosePanel.find('.text-info>.name').text(cartInfo.name);
$chosePanel.find('.sale-price').text(cartInfo.salePrice);
if (!cartInfo.price) {
$chosePanel.find('.sale-price').addClass('no-price');
} else {
$chosePanel.find('.market-price').text(cartInfo.price).removeClass(dbClass);
}
var colorsClone = $chosePanel.find('.color-list>.size-row').remove();
var colorClone = colorsClone.find('li').remove();
for (var i = 0; i < cartInfo.colors.length; i++) {
var colors = cartInfo.colors[i];
var colorsEle = colorsClone.clone();
colorsEle.attr('id', colors.id).attr('data-index', i);
if (i != 0) {
colorsEle.addClass('hide');
}
for (var o = 0; o < colors.color.length; o++) {
var color = colors.color[o];
var colorEle = colorClone.clone();
colorEle.attr('data-num', color.colorNum).text(color.name);
if (color.chosed) {
colorEle.addClass('chosed');
}
if (!color.colorNum) {
colorEle.addClass('zero-stock');
}
colorsEle.append(colorEle);
}
$chosePanel.find('.color-list').append(colorsEle);
}
var sizesClone = $chosePanel.find('.size-list>.size-row').remove();
var sizeClone = sizesClone.find('li').remove();
for (var i = 0; i < cartInfo.sizes.length; i++) {
var sizes = cartInfo.sizes[i];
var sizesEle = sizesClone.clone();
if (i != 0) {
sizesEle.addClass('hide');
}
for (var o = 0; o < sizes.size.length; o++) {
var size = sizes.size[o];
var sizeEle = sizeClone.clone();
sizeEle.attr('data-num', size.sizeNum).attr('data-id', size.id).attr('data-skuid', size.skuId).text(size.name);
if (size.chosed) {
sizeEle.addClass('chosed');
}
if (!size.sizeNum) {
sizeEle.addClass('zero-stock');
}
sizesEle.append(sizeEle);
}
$chosePanel.find('.size-list').append(sizesEle);
}
}
if (data.tickets) {
$chosePanel.find('.infos').addClass('tickets-info');
$chosePanel.find('.color-list>.name').text('日期');
$chosePanel.find('.size-list>.name').text('区域');
} else {
$chosePanel.find('.color-list>.name').text('颜色');
$chosePanel.find('.size-list>.name').text('尺码');
}
if (data.single) {
$chosePanel.find('.size-list').addClass('hide');
}
if (data.cartInfo.promotionId) {
$('.btn-minus,.btn-plus').find('span').addClass('disabled');
}
$('#limitNum').val(data.limit);
$('#promotionId').val(promotionId);
$('#single').val(single);
$('#chose-btn-sure').text(data.tickets ? '立即购买' : '加入购物车')
}
... ...
var $ = require('yoho-jquery'),
chosePanel = require('../../common/chose-panel'),
dbClass = 'data-bind';
module.exports = function(callback) {
... ... @@ -111,5 +112,6 @@ function render(data) {
if (data.loginUrl) {
$('#loginUrl').val(data.loginUrl).removeClass(dbClass);
}
chosePanel(data);
$('.' + dbClass).remove();
}
... ...