Merge branch 'feature/guang' into release/5.7
Showing
12 changed files
with
73 additions
and
19 deletions
@@ -135,9 +135,16 @@ const del = (req, res, next) => { | @@ -135,9 +135,16 @@ const del = (req, res, next) => { | ||
135 | * [加入购物车] | 135 | * [加入购物车] |
136 | */ | 136 | */ |
137 | const add = (req, res, next) => { | 137 | const add = (req, res, next) => { |
138 | - if (!req.xhr) { | ||
139 | - return next(); | ||
140 | - } | 138 | + // for guang |
139 | + let allowOrigin = _.get(req, 'headers.origin', null) ? | ||
140 | + req.headers.origin : req.protocol + '://guang.' + req.headers.host; | ||
141 | + | ||
142 | + res.setHeader('Access-Control-Allow-Origin', allowOrigin); | ||
143 | + res.setHeader('Access-Control-Allow-Credentials', 'true'); | ||
144 | + | ||
145 | + // if (!req.xhr) { | ||
146 | + // return next(); | ||
147 | + // } | ||
141 | let shoppingKey = req.cookies._SPK || '', | 148 | let shoppingKey = req.cookies._SPK || '', |
142 | uid = req.user && req.user.uid; | 149 | uid = req.user && req.user.uid; |
143 | let productSku = req.body.productSku, | 150 | let productSku = req.body.productSku, |
@@ -214,7 +214,7 @@ const index = (req, res, next) => { | @@ -214,7 +214,7 @@ const index = (req, res, next) => { | ||
214 | 214 | ||
215 | let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); | 215 | let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); |
216 | 216 | ||
217 | - guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList); | 217 | + guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, isApp); |
218 | 218 | ||
219 | // 相关品牌 | 219 | // 相关品牌 |
220 | if (detail.getBrand && detail.getBrand.length) { | 220 | if (detail.getBrand && detail.getBrand.length) { |
@@ -330,7 +330,7 @@ const mini = (req, res, next) => { | @@ -330,7 +330,7 @@ const mini = (req, res, next) => { | ||
330 | gender); | 330 | gender); |
331 | let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); | 331 | let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); |
332 | 332 | ||
333 | - guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList); | 333 | + guang.detail.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, isApp); |
334 | 334 | ||
335 | // 相关品牌 | 335 | // 相关品牌 |
336 | if (detail.getBrand && detail.getBrand.length) { | 336 | if (detail.getBrand && detail.getBrand.length) { |
@@ -397,7 +397,7 @@ const foryoho = (req, res, next) => { | @@ -397,7 +397,7 @@ const foryoho = (req, res, next) => { | ||
397 | 397 | ||
398 | let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); | 398 | let goodsList = yield req.ctx(DetailModel).productInfoBySkns(processContents.allgoods); |
399 | 399 | ||
400 | - data.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList); | 400 | + data.content = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, isApp); |
401 | 401 | ||
402 | // 内容中的相关推荐和悬浮商品移到data层级 | 402 | // 内容中的相关推荐和悬浮商品移到data层级 |
403 | let relatedRecoIndex = data.content.findIndex((cont) => { | 403 | let relatedRecoIndex = data.content.findIndex((cont) => { |
@@ -111,7 +111,7 @@ | @@ -111,7 +111,7 @@ | ||
111 | <div class="post-block related-reco clearfix"> | 111 | <div class="post-block related-reco clearfix"> |
112 | <div class="related-reco-block related-reco-hide"> | 112 | <div class="related-reco-block related-reco-hide"> |
113 | {{#each relatedReco.goods}} | 113 | {{#each relatedReco.goods}} |
114 | - {{> detail/related-reco}} | 114 | + {{> detail/related-reco isApp=../relatedReco/isApp}} |
115 | {{/each}} | 115 | {{/each}} |
116 | </div> | 116 | </div> |
117 | {{#if relatedReco.moreNum}} | 117 | {{#if relatedReco.moreNum}} |
@@ -4,9 +4,11 @@ | @@ -4,9 +4,11 @@ | ||
4 | <div class="focus-small"></div> | 4 | <div class="focus-small"></div> |
5 | </div> | 5 | </div> |
6 | </div> | 6 | </div> |
7 | - <div class="lable-info-box"><a href="{{href}}">{{tagName}}</a></div> | ||
8 | - <div class="lable-btn"> | 7 | + <div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><a href="{{href}}">{{tagName}}</a></div> |
8 | + {{#unless isApp}} | ||
9 | + <div class="lable-btn add-to-cart" data-skn="{{product_skn}}"> | ||
9 | <span class="iconfont"></span> | 10 | <span class="iconfont"></span> |
10 | <span class="iconfont plus"></span> | 11 | <span class="iconfont plus"></span> |
11 | </div> | 12 | </div> |
13 | + {{/unless}} | ||
12 | </div> | 14 | </div> |
1 | <div class="one-good clearfix"> | 1 | <div class="one-good clearfix"> |
2 | + <a href="{{url}}"> | ||
2 | <img class="thumb lazy" data-original="{{image2 default_images w=152 h=204}}"> | 3 | <img class="thumb lazy" data-original="{{image2 default_images w=152 h=204}}"> |
4 | + </a> | ||
3 | <div class="content-container"> | 5 | <div class="content-container"> |
4 | <p class="reco-name"> | 6 | <p class="reco-name"> |
5 | - <span>{{product_name}}</span> | 7 | + <a href="{{url}}"><span>{{product_name}}</span> </a> |
6 | </p> | 8 | </p> |
7 | <p class="price"> | 9 | <p class="price"> |
8 | - <span class="sale-price">¥{{sales_price}}</span> | 10 | + <a href="{{url}}"><span class="sale-price">¥{{sales_price}}</span> |
9 | </p> | 11 | </p> |
12 | + {{#unless isApp}} | ||
10 | <p> | 13 | <p> |
11 | - <span class="check-detail"> | 14 | + <span class="check-detail add-to-cart" data-skn="{{product_skn}}"> |
12 | <span class="iconfont"></span> | 15 | <span class="iconfont"></span> |
13 | <span class="iconfont plus"></span> | 16 | <span class="iconfont plus"></span> |
14 | </span> | 17 | </span> |
15 | </p> | 18 | </p> |
19 | + {{/unless}} | ||
16 | </div> | 20 | </div> |
17 | </div> | 21 | </div> |
@@ -322,10 +322,17 @@ exports.index = (req, res, next) => { | @@ -322,10 +322,17 @@ exports.index = (req, res, next) => { | ||
322 | * @return {[type]} [description] | 322 | * @return {[type]} [description] |
323 | */ | 323 | */ |
324 | exports.indexData = (req, res, next) => { | 324 | exports.indexData = (req, res, next) => { |
325 | - if (!req.xhr) { | ||
326 | - return next(); | ||
327 | - } | ||
328 | - if (!req.body.id) { | 325 | + // for guang |
326 | + let allowOrigin = _.get(req, 'headers.origin', null) ? | ||
327 | + req.headers.origin : req.protocol + '://guang.' + req.headers.host; | ||
328 | + | ||
329 | + res.setHeader('Access-Control-Allow-Origin', allowOrigin); | ||
330 | + res.setHeader('Access-Control-Allow-Credentials', 'true'); | ||
331 | + | ||
332 | + // if (!req.xhr) { | ||
333 | + // return next(); | ||
334 | + // } | ||
335 | + if (!req.body.id && !req.body.productSkn) { | ||
329 | return next(); | 336 | return next(); |
330 | } | 337 | } |
331 | let uid = req.user.uid || 0; | 338 | let uid = req.user.uid || 0; |
public/js/guang/detail/guang-cart.js
0 → 100644
1 | +/* | ||
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2017-05-08 09:43:20 | ||
4 | + * @Last Modified by: Targaryen | ||
5 | + * @Last Modified time: 2017-05-08 10:59:37 | ||
6 | + */ | ||
7 | + | ||
8 | +const $ = require('yoho-jquery'); | ||
9 | +const chosePanel = require('common/chose-panel-new'); | ||
10 | +const detailFuns = require('product/detail/functions'); | ||
11 | + | ||
12 | +let $addToCart = $('.add-to-cart'); | ||
13 | + | ||
14 | +$addToCart.on('click', function(e) { | ||
15 | + let $this = $(e.currentTarget); | ||
16 | + let productSkn = $this.data('skn'); | ||
17 | + | ||
18 | + $.post(location.protocol + '//m.yohobuy.com/product/detail/info', { | ||
19 | + productSkn: productSkn | ||
20 | + }, function(data) { | ||
21 | + chosePanel.show({data}).then(result => { | ||
22 | + detailFuns.addToCart(result.sku.skuId, productSkn, result.buyNum); | ||
23 | + }); | ||
24 | + }); | ||
25 | +}); |
@@ -28,6 +28,7 @@ let time = 0; | @@ -28,6 +28,7 @@ let time = 0; | ||
28 | require('common'); | 28 | require('common'); |
29 | require('plugin/wx-share')(); | 29 | require('plugin/wx-share')(); |
30 | require('./detail-dynamic'); | 30 | require('./detail-dynamic'); |
31 | +require('./detail/guang-cart'); | ||
31 | 32 | ||
32 | let CollactionBlock = require('./collocation-block'); | 33 | let CollactionBlock = require('./collocation-block'); |
33 | 34 |
@@ -82,7 +82,7 @@ let functions = { | @@ -82,7 +82,7 @@ let functions = { | ||
82 | } | 82 | } |
83 | $.ajax({ | 83 | $.ajax({ |
84 | method: 'POST', | 84 | method: 'POST', |
85 | - url: '/cart/index/add', | 85 | + url: '//m.yohobuy.com/cart/index/add', |
86 | data: { | 86 | data: { |
87 | productSku: sku, | 87 | productSku: sku, |
88 | new_product_skn: skn, | 88 | new_product_skn: skn, |
@@ -157,6 +157,11 @@ $focus-size: 42px; | @@ -157,6 +157,11 @@ $focus-size: 42px; | ||
157 | white-space: nowrap; | 157 | white-space: nowrap; |
158 | } | 158 | } |
159 | 159 | ||
160 | + .lable-infobox-borderadius { | ||
161 | + border-top-right-radius: 40px; | ||
162 | + border-bottom-right-radius: 40px; | ||
163 | + } | ||
164 | + | ||
160 | .lable-info-box > a { | 165 | .lable-info-box > a { |
161 | color: #fff; | 166 | color: #fff; |
162 | } | 167 | } |
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | @import "common/good"; | 2 | @import "common/good"; |
3 | @import "common/loading"; | 3 | @import "common/loading"; |
4 | @import "common/suspend-home"; | 4 | @import "common/suspend-home"; |
5 | +@import "cart/chose-panel"; | ||
5 | @import "detail"; | 6 | @import "detail"; |
6 | @import "tvls"; | 7 | @import "tvls"; |
7 | @import "channel/side-nav"; | 8 | @import "channel/side-nav"; |
@@ -270,6 +270,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW | @@ -270,6 +270,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW | ||
270 | 270 | ||
271 | // 链接 | 271 | // 链接 |
272 | tagList[tagIndex].href = '//m.yohobuy.com/product/' + tag.product_skn + '.html'; | 272 | tagList[tagIndex].href = '//m.yohobuy.com/product/' + tag.product_skn + '.html'; |
273 | + tagList[tagIndex].isApp = isApp; | ||
273 | }); | 274 | }); |
274 | } | 275 | } |
275 | 276 | ||
@@ -336,6 +337,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW | @@ -336,6 +337,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW | ||
336 | 337 | ||
337 | finalDetail.push({ | 338 | finalDetail.push({ |
338 | relatedReco: { | 339 | relatedReco: { |
340 | + isApp: isApp, | ||
339 | goods: goodsData, | 341 | goods: goodsData, |
340 | moreNum: goodsData.length - 2 > 0 ? goodsData.length - 2 : 0 | 342 | moreNum: goodsData.length - 2 > 0 ? goodsData.length - 2 : 0 |
341 | } | 343 | } |
@@ -397,8 +399,8 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW | @@ -397,8 +399,8 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW | ||
397 | /** | 399 | /** |
398 | * 重新获取商品数据 | 400 | * 重新获取商品数据 |
399 | */ | 401 | */ |
400 | -const pushGoodsInfo = (finalDetail, goodsList) => { | ||
401 | - let goodsObj = _goodsArrayToObj(productPrcs.processProductList(goodsList)); | 402 | +const pushGoodsInfo = (finalDetail, goodsList, isApp) => { |
403 | + let goodsObj = _goodsArrayToObj(productPrcs.processProductList(goodsList, { isApp: isApp })); | ||
402 | 404 | ||
403 | _.forEach(finalDetail, (value, key) => { | 405 | _.forEach(finalDetail, (value, key) => { |
404 | if (value.relatedReco) { | 406 | if (value.relatedReco) { |
-
Please register or login to post a comment