Authored by yyq

merge

... ... @@ -132,7 +132,7 @@ const getShopRecommendAsync = (skn, page, limit) => {
*/
const getBundleAsync = (skn) => {
return api.get('', {
method: 'web.query.bundleSkn',
method: 'app.query.bundleSkn',
product_skn: skn
});
};
... ...
... ... @@ -1629,53 +1629,60 @@ const recommendAsync = (skn, page, limit) => {
})();
};
/**
* 获取套餐
* 处理单个套餐
*/
const getPackage = (skn) => {
const isPackage = (type) => type === BUNDLE_PACKAGE;
function handlePackage(pack) {
const isPackage = type => type === BUNDLE_PACKAGE;
return co(function * () {
let data = yield productAPI.getBundleAsync(skn);
let resData = {code: data.code},
packageList = [];
if (data.code === 200 && !_.isEmpty(data.data) && isPackage(_.get(data, 'data.bundleInfo.discountType'))) {
let bundleInfo = data.data.bundleInfo || {};
let productList = data.data.productList || {};
resData.data = {
bundleId: bundleInfo.bundleId,
salesPrice: bundleInfo.salesPriceStr,
pkgPrice: bundleInfo.discountPriceStr,
savePrice: bundleInfo.subPrice
};
_.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.format_sales_price,
colors: skuData.skuGoods
};
let bundleInfo = pack.bundleInfo || {};
let productList = pack.productList || [];
packageList.push(pkgData);
});
if (!isPackage(bundleInfo.discountType)) {
return {};
}
resData.data.packageData = packageList;
} else {
resData.code = 400;
resData.message = '没有数据';
}
let item = {
name: bundleInfo.tabName,
bundleId: bundleInfo.bundleId,
salesPrice: bundleInfo.salesPriceStr,
pkgPrice: bundleInfo.discountPriceStr,
savePrice: bundleInfo.subPrice
};
return resData;
})();
};
item.productList = _.map(productList, function(value) {
// sku商品信息
let skuData = _getSkuDataByProductBaseInfo(value);
return {
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.format_sales_price,
colors: skuData.skuGoods
};
});
return item;
}
/**
* 获取套餐
*/
const getPackage = co(function * (skn) {
let reqData = yield productAPI.getBundleAsync(skn);
let resData = {code: reqData.code};
if (reqData.code === 200 && !_.isEmpty(reqData.data)) {
resData.data = _.map(reqData.data, handlePackage);
} else {
resData.code = 400;
resData.message = '没有数据';
}
return resData;
});
module.exports = {
... ...
... ... @@ -21,7 +21,7 @@
</div>
{{/if}}
<div id="package" class="package-box clearfix"></div>
<div id="package" class="package-box clearfix hide"></div>
<div class="total-content">
<div class="other-infos">
... ...
... ... @@ -11,20 +11,20 @@ const isTest = process.env.NODE_ENV === 'test';
module.exports = {
app: 'web',
appVersion: '5.3.0', // 调用api的版本
appVersion: '5.5.0', // 调用api的版本
port: 6002,
siteUrl: 'http://www.yohobuy.com',
cookieDomain: '.yohobuy.com',
domains: {
// test3
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// prod
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// gray
// singleApi: 'http://single.gray.yohops.com/',
... ... @@ -32,8 +32,8 @@ module.exports = {
// service: 'http://service.gray.yohops.com/',
// dev
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api'
... ...
... ... @@ -3,7 +3,7 @@
<span class="pkg-close close right"><i class="iconfont"></i></span>
</div>
<div class="pkgDg-prodetal">
{{#packageData}}
{{#productList}}
<div class="pkg-product clearfix">
<a href="{{url}}" class="pkg-proImg"><img src="{{image2 src w=85 h=109}}" class="pro-img"/></a>
<div class="type-chose">
... ... @@ -41,7 +41,7 @@
</div>
</div>
</div>
{{/packageData}}
{{/productList}}
</div>
<div class="pkgDg-footer clearfix">
<p class="totalMoney left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;计:<em>{{pkgPrice}}</em></p>
... ...
<div class="title-header">优惠套装</div>
<div id="package-pro" class="package-pro clearfix" data-bundleid="{{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>
{{#if saveFlag}}<p class="save-text red-color">立省<em class="save-price">{{savePrice}}</em></p>{{/if}}
<span id="buy-detail" class="buy-product red-color">
<em>立即购买</em>
<div class="title-header">
{{# packageList}}
<span class="{{#if_cond @index '==' 0}}active{{/if_cond}}" data-id="package-{{@index}}">{{name}}</span>
{{/packageList}}
</div>
<div class="package-list">
{{# packageList}}
<div class="package-pro clearfix {{#if_cond @index '>=' 1}}hide{{/if_cond}}" data-bundleid="{{bundleId}}">
{{#productList}}
<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>
{{/productList}}
<div class="package-priceList">
<p>销售价:<em class="sale-price">{{salesPrice}}</em></p>
<p>套餐价:<em class="package-price red-color">{{pkgPrice}}</em></p>
{{#if saveFlag}}<p class="save-text red-color">立省<em class="save-price">{{savePrice}}</em></p>{{/if}}
<span id="buy-detail" class="buy-product red-color">
<em>立即购买</em>
</span>
</div>
</div>
{{/packageList}}
</div>
... ...
... ... @@ -68,6 +68,7 @@ var dialogTpl = require('hbs/product/coupon-dialog.hbs');
var consultSuccessTpl = require('hbs/product/consult-success.hbs');
var pkgData;// 套餐数据
var pkgDataList; // 套餐列表数据
var notifyTpl = require('hbs/product/notify.hbs');
var notifyOkTpl = require('hbs/product/notify-ok.hbs');
... ... @@ -1528,7 +1529,6 @@ window.fetchRecommend = window.once(loadRecommend);
// 加载套餐默认信息
$(function() {
if (!isPackageProduct) {
$('#package').addClass('hide');
return;
}
... ... @@ -1539,18 +1539,35 @@ $(function() {
skn: skn
}
}).then(function(result) {
if (result.code === 200 && result.data.packageData.length > 0) {
if (result.code === 200 && result.data.length > 0) {
var packageTpl = require('hbs/product/package.hbs'); // eslint-disable-line
pkgData = result.data;
$('#package').html(packageTpl(pkgData));
pkgDataList = result.data;
pkgData = pkgDataList[0];
$('#package').html(packageTpl({packageList: result.data})).removeClass('hide');
$('#package').on('click', '.title-header span', function() {
var $this = $(this);
if ($this.hasClass('active')) {
return;
}
$this.addClass('active')
.siblings().removeClass('active');
$('#package')
.find('.package-pro').eq($this.index())
.removeClass('hide')
.siblings().addClass('hide');
pkgData = pkgDataList[$this.index()];
});
// 详情页套餐区
$('.good-info .good-detail-text > a').dotdotdot({
wrap: 'letter'
});
} else {
$('#package').addClass('hide');
}
});
... ... @@ -1566,8 +1583,8 @@ $('.package-box').on('click', '#buy-detail', function() {
var isSingle = true, // eslint-disable-line
singleSkuList = [];
for (var i = 0; i < pkgData.packageData.length; i++) { //eslint-disable-line
var pData = pkgData.packageData[i]; //eslint-disable-line
for (var i = 0; i < pkgData.productList.length; i++) { //eslint-disable-line
var pData = pkgData.productList[i]; //eslint-disable-line
if (pData.colors.length === 1 && pData.colors[0].size.length === 1) {
singleSkuList.push(pData.colors[0].size[0].sku);
... ...
... ... @@ -870,10 +870,26 @@
border: 1px solid #eaeceb;
.title-header {
height: 45px;
line-height: 45px;
background-color: #f5f5f5;
border-bottom: 1px solid #eaeceb;
text-indent: 20px;
color: #666;
span {
margin-left: 20px;
margin-right: 20px;
display: inline-block;
text-align: center;
cursor: pointer;
}
.active {
color: black;
height: 42px;
border-bottom: 3px solid black;
}
}
.package-pro {
... ...