Authored by OF1706

Merge branch 'feature/shoppingCart' of http://git.yoho.cn/fe/yohobuy-node into feature/shoppingCart

@@ -278,9 +278,74 @@ const getTogetherProduct = (req, res) => { @@ -278,9 +278,74 @@ const getTogetherProduct = (req, res) => {
278 message: '凑单商品' 278 message: '凑单商品'
279 };*/ 279 };*/
280 280
281 - let ret = yield service.getTogetherProduct(page);  
282 -  
283 - return res.send(ret); 281 + // let ret = yield service.getTogetherProduct(page);
  282 +
  283 + // return res.send(ret);
  284 + // test
  285 + return res.send({
  286 + 'code': 200,
  287 + 'message': '',
  288 + 'data': {
  289 + 'header': '\u51d1\u5355\u5546\u54c1',
  290 + 'hasPrev': true,
  291 + 'hasNext': true,
  292 + 'item': [{
  293 + 'id': 675944,
  294 + 'skn': 51486050,
  295 + 'href': '\/\/item.yohobuy.com\/product\/pro_675944_831288\/MYFUN yinliaopingxiuhuanvmianwa 1611DPA0195.html',
  296 + 'title': 'MY FUN \u996e\u6599\u74f6\u7ee3\u82b1\u5973\u68c9\u889c',
  297 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2017\/01\/12\/08\/01fcff8810cf74104dcb166d971a3fca91.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  298 + 'alt': 'MY FUN \u996e\u6599\u74f6\u7ee3\u82b1\u5973\u68c9\u889c',
  299 + 'price': '19.00',
  300 + 'marketPrice': '49.00'
  301 + }, {
  302 + 'id': 675942,
  303 + 'skn': 51486048,
  304 + 'href': '\/\/item.yohobuy.com\/product\/pro_675942_831286\/MYFUN siyecaoxiuhuanvmianwa 1611DPA0194.html',
  305 + 'title': 'MY FUN \u56db\u53f6\u8349\u7ee3\u82b1\u5973\u68c9\u889c',
  306 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2017\/01\/12\/08\/01b5f0a983a76de8fe730e67247cdac0e6.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  307 + 'alt': 'MY FUN \u56db\u53f6\u8349\u7ee3\u82b1\u5973\u68c9\u889c',
  308 + 'price': '19.00',
  309 + 'marketPrice': '49.00'
  310 + }, {
  311 + 'id': 675876,
  312 + 'skn': 51485982,
  313 + 'href': '\/\/item.yohobuy.com\/product\/pro_675876_831220\/MYFUN caitiaowennanshizhangtongwa 1611DPA0045.html',
  314 + 'title': 'MYFUN \u5f69\u6761\u7eb9\u7537\u58eb\u957f\u7b52\u889c',
  315 + 'img': '\/\/img12.static.yhbimg.com\/goodsimg\/2017\/01\/12\/10\/0290b5aafe4137bc7c5ec90f3963546cb9.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  316 + 'alt': 'MYFUN \u5f69\u6761\u7eb9\u7537\u58eb\u957f\u7b52\u889c',
  317 + 'price': '19.00',
  318 + 'marketPrice': '39.00'
  319 + }, {
  320 + 'id': 675874,
  321 + 'skn': 51485980,
  322 + 'href': '\/\/item.yohobuy.com\/product\/pro_675874_831218\/MYFUN caitiaowennanshizhangtongwa 1611DPA0043.html',
  323 + 'title': 'MY FUN \u5f69\u6761\u7eb9\u7537\u58eb\u957f\u7b52\u889c',
  324 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2017\/01\/12\/10\/01604804248080b4c8cd60dd623e569d24.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  325 + 'alt': 'MY FUN \u5f69\u6761\u7eb9\u7537\u58eb\u957f\u7b52\u889c',
  326 + 'price': '19.00',
  327 + 'marketPrice': '39.00'
  328 + }, {
  329 + 'id': 675872,
  330 + 'skn': 51485978,
  331 + 'href': '\/\/item.yohobuy.com\/product\/pro_675872_831216\/MYFUN ertiaogangnanshizhongtongwa 1611DPA0034.html',
  332 + 'title': 'MY FUN \u7537\u58eb\u4e2d\u7b52\u889c',
  333 + 'img': '\/\/img12.static.yhbimg.com\/goodsimg\/2017\/01\/12\/10\/02888bca5ef68cb669a0c47ae31232d87e.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  334 + 'alt': 'MY FUN \u7537\u58eb\u4e2d\u7b52\u889c',
  335 + 'price': '15.00',
  336 + 'marketPrice': '29.00'
  337 + }, {
  338 + 'id': 675870,
  339 + 'skn': 51485976,
  340 + 'href': '\/\/item.yohobuy.com\/product\/pro_675870_831214\/MYFUN ertiaogangnanshizhongtongwa 1611DPA0033.html',
  341 + 'title': 'MY FUN \u7537\u58eb\u4e2d\u7b52\u889c',
  342 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2017\/01\/12\/10\/015ef2fb172c81a128b8c6603f89671f03.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  343 + 'alt': 'MY FUN \u7537\u58eb\u4e2d\u7b52\u889c',
  344 + 'price': '15.00',
  345 + 'marketPrice': '29.00'
  346 + }]
  347 + }
  348 + });
284 })(); 349 })();
285 }; 350 };
286 351
@@ -300,9 +365,72 @@ const getRecommendProductAction = (req, res) => { @@ -300,9 +365,72 @@ const getRecommendProductAction = (req, res) => {
300 page = 1; 365 page = 1;
301 } 366 }
302 367
303 - let ret = yield service.getRecommendProduct(channel, uid, udid, page);  
304 -  
305 - res.send(ret); 368 + // let ret = yield service.getRecommendProduct(channel, uid, udid, page);
  369 +
  370 + // res.send(ret);
  371 +
  372 + res.send({
  373 + 'code': 200,
  374 + 'message': '',
  375 + 'data': {
  376 + 'header': '\u4e3a\u60a8\u4f18\u9009',
  377 + 'hasPrev': false,
  378 + 'hasNext': true,
  379 + 'item': [{
  380 + 'id': 493102,
  381 + 'skn': 51295054,
  382 + 'href': '\/\/item.yohobuy.com\/product\/pro_493102_450622\/LIFEAFTERLIFEDaYiLALA603WO97.html',
  383 + 'title': 'Life\u00b7After Life \u6e14\u592b\u6263\u5927\u8863\u3010\u591a\u8272\u53ef\u9009\u3011',
  384 + 'img': '\/\/img11.static.yhbimg.com\/goodsimg\/2016\/10\/08\/17\/01a6ac4cfb94fc6ca1bf4c8450ab7828c9.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  385 + 'alt': 'Life\u00b7After Life \u6e14\u592b\u6263\u5927\u8863\u3010\u591a\u8272\u53ef\u9009\u3011',
  386 + 'price': '589.00',
  387 + 'marketPrice': '1389.00'
  388 + }, {
  389 + 'id': 599258,
  390 + 'skn': 51404992,
  391 + 'href': '\/\/item.yohobuy.com\/product\/pro_599258_575876\/VEIL KEIOS x GARFIELD Sports Cap: Monday landicixiudiandaojiafei heisewanyanmao GFK-007.html',
  392 + 'title': 'keios under the veil \u84dd\u5e95\u523a\u7ee3\u985b\u5012\u52a0\u83f2 \u9ed1\u8272\u5f2f\u6a90\u5e3d',
  393 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2016\/10\/08\/14\/01816e75629f40c58a138a30aee2a9eca6.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  394 + 'alt': 'keios under the veil \u84dd\u5e95\u523a\u7ee3\u985b\u5012\u52a0\u83f2 \u9ed1\u8272\u5f2f\u6a90\u5e3d',
  395 + 'price': '248.00'
  396 + }, {
  397 + 'id': 494118,
  398 + 'skn': 51296096,
  399 + 'href': '\/\/item.yohobuy.com\/product\/pro_494118_451958\/PHANTACIPH16LTT02TXu.html',
  400 + 'title': '\u3010JAY CHOU\u5730\u8868\u6700\u5f3a\u6f14\u5531\u4f1a\u7ebf\u4e0a\u72ec\u5bb6\u4e13\u5c5e\u3011PHANTACi X LOONEYTUNES X THEINVINCIBLE TEE-White',
  401 + 'img': '\/\/img12.static.yhbimg.com\/goodsimg\/2016\/10\/12\/09\/022e6b74072cdce1c4df430707905fc4c6.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  402 + 'alt': '\u3010JAY CHOU\u5730\u8868\u6700\u5f3a\u6f14\u5531\u4f1a\u7ebf\u4e0a\u72ec\u5bb6\u4e13\u5c5e\u3011PHANTACi X LOONEYTUNES X THEINVINCIBLE TEE-White',
  403 + 'price': '119.00',
  404 + 'marketPrice': '300.00'
  405 + }, {
  406 + 'id': 657894,
  407 + 'skn': 51466614,
  408 + 'href': '\/\/item.yohobuy.com\/product\/pro_657894_644268\/converse JACK PURCELL MODERN 155020Cnan.html',
  409 + 'title': 'converse JACK PURCELL MODERN Man',
  410 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2016\/12\/18\/14\/01cb0aef0bd168ebcb1de93cefc0d2e376.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  411 + 'alt': 'converse JACK PURCELL MODERN Man',
  412 + 'price': '989.00',
  413 + 'marketPrice': '1099.00'
  414 + }, {
  415 + 'id': 646540,
  416 + 'skn': 51454606,
  417 + 'href': '\/\/item.yohobuy.com\/product\/pro_646540_631202\/5cm MEN SWEAT SHIRT 5CXSWX3503W67BKX.html',
  418 + 'title': '5cm X KYE \u540e\u80cc\u5370\u82b1\u8fde\u5e3d\u536b\u8863',
  419 + 'img': '\/\/img11.static.yhbimg.com\/goodsimg\/2016\/12\/08\/10\/0116d5eb256f45a66f082ab54d9ed7926f.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  420 + 'alt': '5cm X KYE \u540e\u80cc\u5370\u82b1\u8fde\u5e3d\u536b\u8863',
  421 + 'price': '1099.00'
  422 + }, {
  423 + 'id': 496860,
  424 + 'skn': 51298904,
  425 + 'href': '\/\/item.yohobuy.com\/product\/pro_496860_454976\/INTOTHERAINBOWDuanXiuTXuITRMA603TE103.html',
  426 + 'title': 'Into The Rainbow \u7f8e\u56fd\u961f\u957f75\u5468\u5e74 \u77ed\u8896T\u6064',
  427 + 'img': '\/\/img10.static.yhbimg.com\/goodsimg\/2016\/07\/18\/16\/01497d761773446050fcc57c414bee4653.jpg?imageMogr2\/thumbnail\/100x100\/extent\/100x100\/background\/d2hpdGU=\/position\/center\/quality\/80',
  428 + 'alt': 'Into The Rainbow \u7f8e\u56fd\u961f\u957f75\u5468\u5e74 \u77ed\u8896T\u6064',
  429 + 'price': '89.00',
  430 + 'marketPrice': '299.00'
  431 + }]
  432 + }
  433 + });
306 })(); 434 })();
307 }; 435 };
308 436
@@ -348,7 +348,7 @@ @@ -348,7 +348,7 @@
348 348
349 <div class="individual-slide"> 349 <div class="individual-slide">
350 <div data-role="together-slide"></div> 350 <div data-role="together-slide"></div>
351 - <div data-role="recommend-slide"></div> 351 + <div data-role="fine-slide"></div>
352 <div data-role="latestWalk-slide"></div> 352 <div data-role="latestWalk-slide"></div>
353 353
354 354
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 {{#if isAdvance}}<span class="incentive">预售</span>{{/if}} 31 {{#if isAdvance}}<span class="incentive">预售</span>{{/if}}
32 </a> 32 </a>
33 <p class="pay-pro-info"> 33 <p class="pay-pro-info">
34 - <a href="{{link}}" target="_blank"><code class="good-mark">7777{{tag}}</code>{{productTitle}}</a> 34 + <a href="{{link}}" target="_blank">{{#if tag}}<code class="good-mark">{{tag}}</code>{{/if}}{{productTitle}}</a>
35 <em class="pay-pro-detail"><span><b title="{{productColor}}">颜色:{{productColor}}</b> 尺码:{{productSize}}<i class="iconfont">&#xe6c7;</i></span></em> 35 <em class="pay-pro-detail"><span><b title="{{productColor}}">颜色:{{productColor}}</b> 尺码:{{productSize}}<i class="iconfont">&#xe6c7;</i></span></em>
36 </p> 36 </p>
37 </div> 37 </div>
@@ -215,6 +215,10 @@ var Cart = { @@ -215,6 +215,10 @@ var Cart = {
215 promotion_id: $item.data('promotionid') ? $item.data('promotionid') : 0 215 promotion_id: $item.data('promotionid') ? $item.data('promotionid') : 0
216 }; 216 };
217 217
  218 + if ($this.hasClass('has-col-btn')) {
  219 + return;
  220 + }
  221 +
218 capi.cartItemDel(item); 222 capi.cartItemDel(item);
219 }, 223 },
220 toFavAll: function() { 224 toFavAll: function() {
@@ -294,52 +294,44 @@ function getProductByPromotionId(promotionId) { @@ -294,52 +294,44 @@ function getProductByPromotionId(promotionId) {
294 294
295 295
296 function getFineProduct(page) { 296 function getFineProduct(page) {
297 - $.ajax({ 297 + return $.ajax({
298 type: 'GET', 298 type: 'GET',
299 dataType: 'json', 299 dataType: 'json',
300 url: '/cart/data/recommendProduct', 300 url: '/cart/data/recommendProduct',
301 data: page 301 data: page
302 }).then(function(d) { 302 }).then(function(d) {
303 303
304 - return d;  
305 -  
306 - /* if (d.code === 200 && d.data.item.length > 0) {  
307 - $obj.html(' ');  
308 - togetherProductStr = togetherProductTemplate(d.data);  
309 - $obj.append($(togetherProductStr));  
310 - $('#orderProduct li:last').addClass('end');  
311 - $('.gift').removeClass('none'); 304 + // 为您优选埋点
  305 + /* if ($obj.hasClass('givePoint')) {
  306 + $.each(d.data.item, function(key, val) {
  307 + PRDID.push(val.id);
  308 + });
312 309
313 - //为您优选埋点  
314 - if ($obj.hasClass('givePoint')) {  
315 - $.each(d.data.item, function(key, val) {  
316 - PRDID.push(val.id);  
317 - }); 310 + window.givePoint({
  311 + 'REC_POSE': 120003,
  312 + 'PRD_ID': PRDID.join(','),
  313 + 'PRD_NUM': d.data.item.length,
  314 + 'ACTION_ID': 0,
  315 + 'page_num': page && page.page ? page.page : 1
  316 + });
318 317
  318 + $('.givePoint ul a').unbind('click').bind('click', function() {
319 window.givePoint({ 319 window.givePoint({
320 'REC_POSE': 120003, 320 'REC_POSE': 120003,
321 - 'PRD_ID': PRDID.join(','),  
322 - 'PRD_NUM': d.data.item.length,  
323 - 'ACTION_ID': 0, 321 + 'PRD_ID': $(this).closest('li').find('.btn_view_s').data('id'),
  322 + 'PRD_NUM': $(this).closest('li').index() + 1,
  323 + 'ACTION_ID': 1,
324 'page_num': page && page.page ? page.page : 1 324 'page_num': page && page.page ? page.page : 1
325 }); 325 });
326 -  
327 - $('.givePoint ul a').unbind('click').bind('click', function() {  
328 - window.givePoint({  
329 - 'REC_POSE': 120003,  
330 - 'PRD_ID': $(this).closest('li').find('.btn_view_s').data('id'),  
331 - 'PRD_NUM': $(this).closest('li').index() + 1,  
332 - 'ACTION_ID': 1,  
333 - 'page_num': page && page.page ? page.page : 1  
334 - });  
335 - return true;  
336 - });  
337 - } 326 + return true;
  327 + });
338 }*/ 328 }*/
  329 +
  330 + return d;
339 }); 331 });
340 } 332 }
341 function getTogetherProduct(page) { 333 function getTogetherProduct(page) {
342 - var PRDID = []; 334 + // var PRDID = [];
343 335
344 return $.ajax({ 336 return $.ajax({
345 type: 'GET', 337 type: 'GET',
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 */ 3 */
4 4
5 var capi = require('./cart-api'); 5 var capi = require('./cart-api');
6 -var togetherTpl = require('hbs/cart/cart-together-item'); 6 +var togetherTpl = require('hbs/cart/cart-together-item.hbs');
7 var $togetherSlide = $('[data-role=together-slide]'); 7 var $togetherSlide = $('[data-role=together-slide]');
8 var $fineSlide = $('[data-role=fine-slide]'); 8 var $fineSlide = $('[data-role=fine-slide]');
9 9
@@ -92,7 +92,10 @@ loadSlideGoods(); @@ -92,7 +92,10 @@ loadSlideGoods();
92 92
93 function loadTogetherProduct(page) { 93 function loadTogetherProduct(page) {
94 capi.getTogetherProduct(page).done(function(togetherInfo) { 94 capi.getTogetherProduct(page).done(function(togetherInfo) {
95 - $togetherSlide.html(togetherTpl(togetherInfo)); 95 +
  96 + if (togetherInfo && togetherInfo.code === 200) {
  97 + $togetherSlide.html(togetherTpl(togetherInfo.data));
  98 + }
96 });/* .fail(function() { 99 });/* .fail(function() {
97 100
98 });*/ 101 });*/
@@ -100,7 +103,9 @@ function loadTogetherProduct(page) { @@ -100,7 +103,9 @@ function loadTogetherProduct(page) {
100 103
101 function loadFineProduct(page) { 104 function loadFineProduct(page) {
102 capi.getFineProduct(page).done(function(fineInfo) { 105 capi.getFineProduct(page).done(function(fineInfo) {
103 - $fineSlide.html(togetherTpl(fineInfo)); 106 + if (fineInfo && fineInfo.code === 200) {
  107 + $fineSlide.html(togetherTpl(fineInfo.data));
  108 + }
104 });/* .fail(function() { 109 });/* .fail(function() {
105 110
106 });*/ 111 });*/
@@ -110,3 +115,27 @@ setTimeout(function() { @@ -110,3 +115,27 @@ setTimeout(function() {
110 loadTogetherProduct(1); 115 loadTogetherProduct(1);
111 loadFineProduct(1); 116 loadFineProduct(1);
112 }, 0); 117 }, 0);
  118 +
  119 +// 凑单商品翻页
  120 +$togetherSlide.on('click', '.pagenext, .pageprev', function() {
  121 + loadTogetherProduct(Math.ceil(Math.random() * 100) + 1);
  122 +});
  123 +
  124 +// 为您优选翻页
  125 +$fineSlide.on('click', '.pagenext, .pageprev', function() {
  126 +
  127 + var pageNum = Number($fineSlide.data('pagenum') || 1);
  128 +
  129 + if ($(this).hasClass('pagenext')) {
  130 + if (pageNum !== 5) {
  131 + pageNum++;
  132 + } else {
  133 + pageNum = 1;
  134 + }
  135 + } else {
  136 + --pageNum > 0 || (pageNum = 1);
  137 + }
  138 +
  139 + $fineSlide.data('pagenum', pageNum);
  140 + loadFineProduct(pageNum);
  141 +});
@@ -57,7 +57,7 @@ function isCheckFav() { @@ -57,7 +57,7 @@ function isCheckFav() {
57 data: { 57 data: {
58 pidList: pidArray.join(',') 58 pidList: pidArray.join(',')
59 } 59 }
60 - }).then(function(result) { 60 + }).done(function(result) {
61 $.each(result.data, function(pid, obj) { 61 $.each(result.data, function(pid, obj) {
62 62
63 if (obj.code !== 200) { 63 if (obj.code !== 200) {
@@ -66,7 +66,6 @@ function isCheckFav() { @@ -66,7 +66,6 @@ function isCheckFav() {
66 66
67 if (obj.data) { 67 if (obj.data) {
68 $sellBox.each(function() { 68 $sellBox.each(function() {
69 -  
70 if (String($(this).data('pid')) === String(pid)) { 69 if (String($(this).data('pid')) === String(pid)) {
71 $(this).find('.cart-col-btn').addClass('has-col-btn').html('已收藏'); 70 $(this).find('.cart-col-btn').addClass('has-col-btn').html('已收藏');
72 return false; 71 return false;