Authored by htoooth

merge

... ... @@ -250,6 +250,23 @@ const recommend = (req, res, next) => {
.catch(next);
};
/**
* 获取套餐
*/
const getPackage = (req, res, next) => {
let skn = req.query.skn || '';
if (!skn) {
return res.json({
code: 400,
message: '服务器错误'
});
}
service.getPackage(skn)
.then(result => res.json(result))
.catch(next);
};
module.exports = {
showMain,
indexHotArea,
... ... @@ -258,7 +275,8 @@ module.exports = {
createConsult,
productHeader: detailHeader,
detailReturn,
recommend
recommend,
getPackage
};
... ...
... ... @@ -142,7 +142,7 @@ const getShopRecommendAsync = (skn, page, limit) => {
*/
const getBundleAsync = (skn) => {
return api.get('', {
method: 'query.product.bundleSkn',
method: 'web.query.bundleSkn',
product_skn: skn
});
};
... ...
... ... @@ -1542,6 +1542,49 @@ const recommendAsync = (skn, page, limit) => {
})();
};
/**
* 获取套餐
*/
const getPackage = (skn) => {
return co(function * () {
let data = yield productAPI.getBundleAsync(skn);
let resData = {code: data.code},
packageList = [];
if (data.code === 200) {
let bundleInfo = data.data.bundleInfo || {};
let productList = data.data.productList || {};
resData.data = {
bundleId: bundleInfo.bundleId,
salesPrice: bundleInfo.salesPrice,
pkgPrice: bundleInfo.discountPrice,
savePrice: (bundleInfo.salesPrice - bundleInfo.discountPrice).toFixed(2)
};
_.forEach(productList, function(value) {
// sku商品信息
let skuData = _getSkuDataByProductBaseInfo(value);
let pkgData = {
skn: value.product_skn,
url: helpers.urlFormat(url.parse(value.product_url).pathname, null, 'item'),
src: value.default_images,
productName: value.product_name,
productPrice: value.sales_price,
colors: skuData.skuGoods
};
packageList.push(pkgData);
});
resData.data.packageData = packageList;
}
return resData;
})();
};
module.exports = {
getShareOrderListAsync: commentService.getShareOrderListAsync, // 获取评论列表
indexConsultAsync: consultService.indexAsync, // 获取咨询列表
... ... @@ -1551,5 +1594,6 @@ module.exports = {
saveRecentGoodInCookies, // 保存最近的商品
getDetailHeader,
saleReturn,
recommendAsync
recommendAsync,
getPackage
};
... ...
... ... @@ -67,6 +67,7 @@ router.get('/detail/return', detail.detailReturn);// 特殊商品退换货
router.get('/detail/recommend', detail.recommend);// 推荐商品
router.get('/index/isfav', favorite.isFavoriteBrand);// 品牌收藏状态
router.get('/detail/coupon', auth, coupon.acquire); // 获得优惠券
router.get('/detail/getPacakge', detail.getPackage);// 获取套餐
// 搜索
router.get('/search/index', search.index);
... ...
... ... @@ -35,7 +35,7 @@
<div id="size-title-json" style="display:none;">{{sizeTitleJson}}</div>
<div class="total-content">
{{> product/package}}
<div id="package" class="package-box clearfix"></div>
<div class="other-infos">
<div class="description-material info-block getnav" id="goodsMessage" data-id="0">
... ... @@ -373,8 +373,9 @@
</div>
<div class="common-question buy-consults">
<p>购买咨询&nbsp;&nbsp;4</p>
<p>购买咨询&nbsp;&nbsp;<em class="consult-num">0</em></p>
</div>
<div id="consults-ul">
<div class="common-question">
<p>
<span class="top-question">
... ... @@ -417,9 +418,9 @@
</div>
</div>
</div>
</div>
<div class="common-question">
<p>
<span>
<i class="iconfont">&#xe696;</i><small class="leave-message">
客服留言:&nbsp;&nbsp;感谢你的咨询,YOHO潮流网站双十一期间服装五折抢购
... ... @@ -430,7 +431,9 @@
</div>
</div>
<div class="consults-devide">
</div>
<div class="common-question">
<textarea id="textbox"></textarea>
<span id="submit-consult" class="btn">提交咨询</span>
... ... @@ -553,47 +556,3 @@
})();
</script>
{{/statGoodsInfo}}
<script type="text/html" id="packageDialog">
<div class="pkgDg-header">
<p class="left">潮流搭配</p>
<span class="pkg-close close right"><i class="iconfont"></i></span>
</div>
<div class="pkgDg-prodetal">
<div class="pkg-product clearfix">
<a href="#" class="pkg-proImg"><img src="//img12.static.yhbimg.com/goodsimg/2016/11/02/14/0293f6afc458261c612853b2fb371c9a7a.jpg?imageMogr2/thumbnail/75x100/extent/75x100/background/d2hpdGU=/position/center/quality/90" class="pro-img"/></a>
<div class="type-chose">
<div class="chose-color row clearfix">
<span class="title pull-left">&nbsp;&nbsp;色:</span>
<ul class="colors pull-left clearfix">
<li class="focus pull-left" title="Reshake 男款logo刺绣织带装饰棉服外套 黑色" data-color="黑色" data-total="10">
<img src="//img12.static.yhbimg.com/goodsimg/2016/11/02/14/0293f6afc458261c612853b2fb371c9a7a.jpg?imageMogr2/thumbnail/40x40/extent/40x40/background/d2hpdGU=/position/center/quality/90"><span class="color-name">黑色</span>
</li>
</ul>
</div>
<div class="chose-size row clearfix">
<span class="title pull-left"> &nbsp;&nbsp;码: </span>
<div id="sizes" class="size-wrapper pull-left">
<ul class="size">
<li data-sku="1848512" data-num="1" data-name="46" data-title="">46</li>
<li data-sku="1848514" data-num="4" data-name="48" data-title="">48</li>
<li data-sku="1848516" data-num="4" data-name="50" data-title="">50</li>
<li data-sku="1848518" data-num="1" data-name="52" data-title="">52</li>
<span class="size-warn warn-tip hide"> <i class="iconfont"></i> 请选择尺码 </span>
</ul>
<p class="color-size-tip hide"></p>
</div>
</div>
<div class="chose-done">您已选择:<span>“黑色”</span><span>“M码”</span></div>
</div>
</div>
</div>
<div class="pkgDg-footer clearfix">
<p class="totalMoney left">合计:<em>138.00</em></p>
<span class="buy-product red-color right">
<em>立即购买</em>
</span>
</div>
</script>
... ...
<div class="package-box clearfix">
<div class="title-header">优惠套装</div>
<div class="package-pro clearfix">
<div class="good-info" data-skn="" data-from="">
<div class="good-detail-img">
<a class="good-thumb" href="" target="_blank">
<img class="lazy" src="//img11.static.yhbimg.com/goodsimg/2016/11/24/14/012a2e26bd48f26654cbbe724280cd29d9.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90" style="display: block;">
</a>
</div>
<div class="good-detail-text stu-good-detail ">
<a href="" target="_blank">PALLADIUM Pampa Cuff WP Lux 男 高帮牛皮防水休闲鞋</a>
<p class="price ">
<span class="sale-price red-color">
¥1078.20
</span>
</p>
</div>
</div>
<div class="spliter">+</div>
<div class="good-info" data-skn="" data-from="">
<div class="good-detail-img">
<a class="good-thumb" href="" target="_blank">
<img class="lazy" src="//img11.static.yhbimg.com/goodsimg/2016/11/24/14/012a2e26bd48f26654cbbe724280cd29d9.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90" style="display: block;">
</a>
</div>
<div class="good-detail-text stu-good-detail ">
<a href="" target="_blank">PALLADIUM Pampa Cuff WP Lux 男 高帮牛皮防水休闲鞋</a>
<p class="price ">
<span class="sale-price red-color">
¥1078.20
</span>
</p>
</div>
</div>
<div class="spliter">+</div>
<div class="good-info" data-skn="" data-from="">
<div class="good-detail-img">
<a class="good-thumb" href="" target="_blank">
<img class="lazy" src="//img11.static.yhbimg.com/goodsimg/2016/11/24/14/012a2e26bd48f26654cbbe724280cd29d9.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90" style="display: block;">
</a>
</div>
<div class="good-detail-text stu-good-detail ">
<a href="" target="_blank">PALLADIUM Pampa Cuff WP Lux 男 高帮牛皮防水休闲鞋</a>
<p class="price ">
<span class="sale-price red-color">
¥1078.20
</span>
</p>
</div>
</div>
<div class="spliter">+</div>
<div class="good-info" data-skn="" data-from="">
<div class="good-detail-img">
<a class="good-thumb" href="" target="_blank">
<img class="lazy" src="//img11.static.yhbimg.com/goodsimg/2016/11/24/14/012a2e26bd48f26654cbbe724280cd29d9.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90" style="display: block;">
</a>
</div>
<div class="good-detail-text stu-good-detail ">
<a href="" target="_blank">PALLADIUM Cuff WP Lux 男 高帮牛皮防水休闲鞋</a>
<p class="price ">
<span class="sale-price red-color">
¥1078.20
</span>
</p>
</div>
</div>
<div class="spliter">=</div>
<div class="package-priceList">
<p>销售价:<em class="sale-price">¥633.00</em></p>
<p>套餐价:<em class="package-price red-color">¥520.00</em></p>
<p class="save-text red-color">立省<em class="save-price">¥113.00</em></p>
<span id="buy-detail" class="buy-product red-color">
<em>立即购买</em>
</span>
</div>
</div>
</div>
{{# consults}}
<!-- {{# consults}}
<li>
<div class="user-info clearfix">
<img class="user-avatar" src="{{avatar}}">
... ... @@ -10,4 +10,25 @@
</div>
<p class="consult">{{answer}}</p>
</li>
{{/ consults}} -->
{{# consults}}
<div class="common-question">
<p>
<span class="top-question">
<i class="iconfont">&#xe695;</i>
<small>183****3432&nbsp;&nbsp;&nbsp;{{question}}</small>
<small class="right-time">{{date}}</small>
</span>
<span>
<i class="iconfont">&#xe696;</i>
{{answer}}
</span>
</p>
<div class="common-zan">
<div class="zan-content">
<span class="icon-border"><i class="iconfont getzan">&#xe626;</i>赞(5)</span>
<span><i class="iconfont">&#xe611;</i>有用(5)</span>
</div>
</div>
</div>
{{/ consults}}
... ...
<div class="pkgDg-header">
<p class="left">潮流搭配</p>
<span class="pkg-close close right"><i class="iconfont"></i></span>
</div>
<div class="pkgDg-prodetal">
{{#packageData}}
<div class="pkg-product clearfix">
<a href="{{url}}" class="pkg-proImg"><img src="{{image src 85 109}}" class="pro-img"/></a>
<div class="type-chose">
<div class="chose-color row clearfix">
<span class="title pull-left">&nbsp;&nbsp;色:</span>
<ul class="pkg-colors colors pull-left clearfix">
{{#each colors}}
<li class="{{#if focus}}focus{{/if}} {{#if disable}}disable{{/if}} pull-left"
title="{{title}}" data-color="{{name}}" data-total="{{total}}">
<img src="{{src}}"><span class="color-name">{{name}}</span>
</li>
{{/each}}
</ul>
</div>
<div class="chose-size row clearfix">
<span class="title pull-left">&nbsp;&nbsp;码: </span>
<div class="pkg-sizes size-wrapper pull-left">
{{> pkg-size}}
</div>
</div>
<div class="chose-done">您已选择:
<span class="pkg-color">“黑色”</span>
<span class="pkg-size"></span>
</div>
</div>
</div>
{{/packageData}}
</div>
<div class="pkgDg-footer clearfix">
<p class="totalMoney left">合计:<em>{{pkgPrice}}</em></p>
<span id="pay-pkg" class="buy-product red-color right">
<em>立即购买</em>
</span>
</div>
... ...
<div class="title-header">优惠套装</div>
<div id="package-pro" class="package-pro clearfix" data-skn="{{bundleId}}">
{{#packageData}}
<div class="good-info" data-skn="{{skn}}">
<div class="good-detail-img">
<a class="good-thumb" href="{{url}}" target="_blank">
<img class="lazy" src="{{image src 100 135}}" style="display: block;">
</a>
</div>
<div class="good-detail-text stu-good-detail ">
<a href="{{url}}" target="_blank">{{productName}}</a>
<p class="price ">
<span class="sale-price red-color">
¥{{productPrice}}
</span>
</p>
</div>
</div>
<div class="spliter">{{#if @last}}={{/if}}{{#unless @last}}+{{/unless}}</div>
{{/packageData}}
<div class="package-priceList">
<p>销售价:<em class="sale-price">¥{{salesPrice}}</em></p>
<p>套餐价:<em class="package-price red-color">¥{{pkgPrice}}</em></p>
<p class="save-text red-color">立省<em class="save-price">¥{{savePrice}}</em></p>
<span id="buy-detail" class="buy-product red-color">
<em>立即购买</em>
</span>
</div>
</div>
... ...
{{#each colors}}
<ul class="size{{#unless focus}} hide{{/unless}}">
{{#each size}}
<li {{#unless num}}class="disable"{{/unless}} data-sku="{{sku}}"
data-num="{{num}}" data-name="{{name}}" data-title="{{title}}">{{name}}</li>
{{/each}}
<span class="size-warn warn-tip hide"> <i class="iconfont">&#xe61f;</i> 请选择尺码 </span>
</ul>
{{/each}}
... ...
... ... @@ -14,12 +14,13 @@ var $ = require('yoho-jquery');
var lazyLoad = require('yoho-jquery-lazyload');
var yas = require('../common/data-yas');
var dataLazyLoad = require('../plugins/lazy-load')(document);
var handlebars = require('yoho-handlebars');
var setPager = require('./detail/pager');
var bindEvent = $.Callbacks(); // eslint-disable-line
var clickAcquireCouponEvent = $.Callbacks('unique'); // eslint-disable-line
var Dialog = require('../common/dialog').Dialog;
var $main = $('.main'),
id = $main.data('id'),
md5 = $main.data('md5'),
... ... @@ -50,6 +51,9 @@ var $saleReturn = $('#saleReturn');
var dialogTpl = require('hbs/product/coupon-dialog.hbs');
var $goodsIdArr = [];
var pkgData;// 套餐数据
var notifyTpl = require('hbs/product/notify.hbs');
var $goodsIdArr = [],
... ... @@ -66,9 +70,6 @@ function isEmpty(el) {
require('../plugins/slider');
require('../common/center-slider');
// handlebars模板
pkgFn = handlebars.compile($('#packageDialog').html() || '');
bindEvent.add(function() {
var $imgShow = $('#img-show'),
$thumbs = $('#thumbs > .thumb-wrap');
... ... @@ -225,7 +226,7 @@ bindEvent.add(function() {
move(e);
});
//促销弹出框
// 促销弹出框
var icon = {
unfold: '&#xe610;',
fold: '&#xe615;'
... ... @@ -631,17 +632,6 @@ bindEvent.add(function() {
}
});
// 套餐
$('#buy-detail').click(function() {
var opt = {
className: 'pkg-dialog',
closeIcon: false,
content: pkgFn({msg: '测试信息!'})
};
new Dialog(opt).show();
});
// 继续购物
$('#keep-shopping').click(function() {
$('#type-chose').slideDown(SLIDETIME);
... ... @@ -872,10 +862,6 @@ $('#brand-favour').click(function() {
// $modelContent.slideDown(SLIDETIME);
// }
// });
// 详情页套餐区
$('.good-info .good-detail-text > a').dotdotdot({
wrap: 'letter'
});
// 售后服务
$('.after-service-switch').click(function() {
... ... @@ -1027,7 +1013,7 @@ function fetchComment() {
});
// 顾客咨询
function loadConsults() {
function loadConsults(nowPage) {
if (loadingConsults) {
return;
}
... ... @@ -1039,11 +1025,11 @@ function fetchComment() {
url: '/product/detail/consult',
data: {
productId: id,
page: consultPage
page: nowPage
}
}).then(function(data) {
var res;
var totalnum;
if (data.code === 200) {
res = data.data;
... ... @@ -1055,16 +1041,35 @@ function fetchComment() {
// 更新总数显示
$consultNum.text(res[0].total);
$consultsUl.append(consultsTpl({
totalnum = Math.ceil(res[0].total / 10) * 20;
$consultsUl.empty().append(consultsTpl({
consults: res
}));
consultPage++;
baseUrl = '/product/detail/consult?productId=' + id + '&filterId=7';
$('.consults-devide').empty().append(
setPager({baseUrl: baseUrl, totalRecords: totalnum, page: nowPage, type: 'ellipsis', theme: 'msg-pager'})
);
}
}).always(function() {
loadingConsults = false;
});
}
$('.consults-devide').on('click', 'a', function() {
var $this = $(this);
var href = $this.data('page');
var data = href.split('?')[1].split('&');
var result = data.map(function(i) {
return i.split('=')[1];
});
loadConsults(result[2]);
});
$('.consult-comment').on('click', '.load-more', function() {
var $this = $(this);
... ... @@ -1305,6 +1310,118 @@ $('.recommend-slider').on('click', '.img-item', function() {
window.loadRecommend = loadRecommend;
// 加载套餐默认信息
$(function() {
return $.ajax({
type: 'GET',
url: '/product/detail/getPacakge',
data: {
skn: '51127118'
}
}).then(function(result) {
if (result.code === 200) {
var packageTpl = require('hbs/product/package.hbs');
pkgData = result.data;
$('#package').html(packageTpl(pkgData));
// 详情页套餐区
$('.good-info .good-detail-text > a').dotdotdot({
wrap: 'letter'
});
}
});
});
// 套餐点击事件
$('.package-box').on('click', '#buy-detail', function() {
var pkgDetailTpl = require('hbs/product/package-dialog.hbs');
var opt = {
className: 'pkg-dialog',
closeIcon: false,
content: pkgDetailTpl(pkgData)
};
new Dialog(opt).show();
var $pkSizes = $('.pkg-sizes'),
$pkColors = $('.pkg-colors');
// 选择颜色
$pkColors.on('click', 'li', function() {
var $this = $(this);
var index = $this.index();
var $colorName = $this.find('.color-name');
var $pkType = $this.closest('.type-chose');
var $pkSizesUl = $pkType.find('.pkg-sizes ul');
var $pkgColor = $pkType.find('.chose-done .pkg-color');
var $pkgSize = $pkType.find('.chose-done .pkg-size');
if ($this.hasClass('focus') || $this.hasClass('disable')) {
return;
}
$this.addClass('focus').siblings('.focus').removeClass('focus');
// 取消尺码的选择
$pkSizesUl.find('li').removeClass('focus');
$pkgColor.html('"' + $colorName.html() + '"');
$pkgSize.html('');
$pkSizesUl.addClass('hide').eq(index).removeClass('hide');
});
// 选择尺码
$pkSizes.on('click', 'li', function() {
var $this = $(this);
var $pkType = $this.closest('.type-chose');
var $pkgSize = $pkType.find('.chose-done .pkg-size');
var $pkgSizeWarn = $pkType.find('.pkg-sizes .size-warn');
if ($this.hasClass('focus') || $this.hasClass('disable')) {
return;
}
$this.addClass('focus').siblings('.focus').removeClass('focus');
$pkgSize.html('"' + $this.html() + '码"');
$pkgSizeWarn.addClass('hide');
});
// 立即购买跳转
$('#pay-pkg').on('click', function() {
window.location.href = '//www.yohobuy.com/cart/easypay?bundle=1124&sku=809291,789239';
});
});
// 推荐和浏览切换
// $('.individual-comment').on('click', '.title', function() {
// var $this = $(this),
// index = $this.index();
//
// var $latestWalk = $('.latest-walk'),
// $recommendComment = $('#recommend-shop');
//
// if ($this.hasClass('cur')) {
// return;
// }
//
// $this.addClass('cur');
// $this.siblings('.cur').removeClass('cur');
//
// if (index === 0) {
// // 店铺推荐
// $recommendComment.slideDown(SLIDETIME);
// $latestWalk.slideUp(SLIDETIME);
// } else {
// // 最近游览
// fetchLatestWalk(); // eslint-disable-line
// $recommendComment.slideUp(SLIDETIME);
// $latestWalk.slideDown(SLIDETIME);
// }
// });
$('.bottom-tab').on('click', '.bottom-title', function() {
var $this = $(this),
index = $this.index();
... ...
... ... @@ -454,7 +454,7 @@
li {
margin-right: 10px;
cursor: pointer;
border: 1px solid #bbbbbb;
border: 1px solid #eaeceb;
height: 34px;
&.focus {
... ... @@ -462,6 +462,10 @@
}
}
li.disable {
opacity: .6;
}
.color-name {
float:left;
height: 34px;
... ... @@ -2136,11 +2140,15 @@
li {
margin-right: 10px;
cursor: pointer;
border: 1px solid white;
border: 1px solid #eaeceb;
height: 34px;
&.focus {
border-color: black;
border-color: black;
}
&.disable {
opacity: 0.5;
}
}
... ... @@ -2275,6 +2283,10 @@
.chose-done {
font-size: 12px;
text-align: left;
.pkg-size {
margin-left: 15px;
}
}
}
... ... @@ -2302,6 +2314,13 @@
}
}
.consults-devide{
.msg-pager{
text-align: center;
margin: 0 auto;
}
}
.notify-goods-wrapper {
.ring {
color: #d42838;
... ...