Authored by 郭成尧

Merge branch 'feature/guang' into release/5.7

... ... @@ -135,9 +135,16 @@ const del = (req, res, next) => {
* [加入购物车]
*/
const add = (req, res, next) => {
if (!req.xhr) {
return next();
}
// for guang
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://guang.' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
// if (!req.xhr) {
// return next();
// }
let shoppingKey = req.cookies._SPK || '',
uid = req.user && req.user.uid;
let productSku = req.body.productSku,
... ...
... ... @@ -214,7 +214,7 @@ const index = (req, res, next) => {
let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList);
guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, isApp);
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
... ... @@ -330,7 +330,7 @@ const mini = (req, res, next) => {
gender);
let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList);
guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, isApp);
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
... ... @@ -397,7 +397,7 @@ const foryoho = (req, res, next) => {
let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods);
data.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList);
data.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, isApp);
// 内容中的相关推荐和悬浮商品移到data层级
let relatedRecoIndex = data.content.findIndex((cont) => {
... ...
... ... @@ -111,7 +111,7 @@
<div class="post-block related-reco clearfix">
<div class="related-reco-block related-reco-hide">
{{#each relatedReco.goods}}
{{> detail/related-reco}}
{{> detail/related-reco isApp=../relatedReco/isApp}}
{{/each}}
</div>
{{#if relatedReco.moreNum}}
... ...
... ... @@ -4,9 +4,11 @@
<div class="focus-small"></div>
</div>
</div>
<div class="lable-info-box"><a href="{{href}}">{{tagName}}</a></div>
<div class="lable-btn">
<div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><a href="{{href}}">{{tagName}}</a></div>
{{#unless isApp}}
<div class="lable-btn add-to-cart" data-skn="{{product_skn}}">
<span class="iconfont">&#xe62c;</span>
<span class="iconfont plus">&#xe624;</span>
</div>
{{/unless}}
</div>
\ No newline at end of file
... ...
<div class="one-good clearfix">
<img class="thumb lazy" data-original="{{image2 default_images w=152 h=204}}">
<a href="{{url}}">
<img class="thumb lazy" data-original="{{image2 default_images w=152 h=204}}">
</a>
<div class="content-container">
<p class="reco-name">
<span>{{product_name}}</span>
<a href="{{url}}"><span>{{product_name}}</span> </a>
</p>
<p class="price">
<span class="sale-price">&yen;{{sales_price}}</span>
<a href="{{url}}"><span class="sale-price">&yen;{{sales_price}}</span>
</p>
{{#unless isApp}}
<p>
<span class="check-detail">
<span class="check-detail add-to-cart" data-skn="{{product_skn}}">
<span class="iconfont">&#xe62c;</span>
<span class="iconfont plus">&#xe624;</span>
</span>
</p>
{{/unless}}
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -322,10 +322,17 @@ exports.index = (req, res, next) => {
* @return {[type]} [description]
*/
exports.indexData = (req, res, next) => {
if (!req.xhr) {
return next();
}
if (!req.body.id) {
// for guang
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://guang.' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
// if (!req.xhr) {
// return next();
// }
if (!req.body.id && !req.body.productSkn) {
return next();
}
let uid = req.user.uid || 0;
... ...
/*
* @Author: Targaryen
* @Date: 2017-05-08 09:43:20
* @Last Modified by: Targaryen
* @Last Modified time: 2017-05-08 10:59:37
*/
const $ = require('yoho-jquery');
const chosePanel = require('common/chose-panel-new');
const detailFuns = require('product/detail/functions');
let $addToCart = $('.add-to-cart');
$addToCart.on('click', function(e) {
let $this = $(e.currentTarget);
let productSkn = $this.data('skn');
$.post(location.protocol + '//m.yohobuy.com/product/detail/info', {
productSkn: productSkn
}, function(data) {
chosePanel.show({data}).then(result => {
detailFuns.addToCart(result.sku.skuId, productSkn, result.buyNum);
});
});
});
... ...
... ... @@ -28,6 +28,7 @@ let time = 0;
require('common');
require('plugin/wx-share')();
require('./detail-dynamic');
require('./detail/guang-cart');
let CollactionBlock = require('./collocation-block');
... ...
... ... @@ -82,7 +82,7 @@ let functions = {
}
$.ajax({
method: 'POST',
url: '/cart/index/add',
url: '//m.yohobuy.com/cart/index/add',
data: {
productSku: sku,
new_product_skn: skn,
... ...
... ... @@ -157,6 +157,11 @@ $focus-size: 42px;
white-space: nowrap;
}
.lable-infobox-borderadius {
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
}
.lable-info-box > a {
color: #fff;
}
... ...
... ... @@ -2,6 +2,7 @@
@import "common/good";
@import "common/loading";
@import "common/suspend-home";
@import "cart/chose-panel";
@import "detail";
@import "tvls";
@import "channel/side-nav";
... ...
... ... @@ -270,6 +270,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW
// 链接
tagList[tagIndex].href = '//m.yohobuy.com/product/' + tag.product_skn + '.html';
tagList[tagIndex].isApp = isApp;
});
}
... ... @@ -336,6 +337,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW
finalDetail.push({
relatedReco: {
isApp: isApp,
goods: goodsData,
moreNum: goodsData.length - 2 > 0 ? goodsData.length - 2 : 0
}
... ... @@ -397,8 +399,8 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW
/**
* 重新获取商品数据
*/
const pushGoodsInfo = (finalDetail, goodsList) => {
let goodsObj = _goodsArrayToObj(productPrcs.processProductList(goodsList));
const pushGoodsInfo = (finalDetail, goodsList, isApp) => {
let goodsObj = _goodsArrayToObj(productPrcs.processProductList(goodsList, { isApp: isApp }));
_.forEach(finalDetail, (value, key) => {
if (value.relatedReco) {
... ...