Authored by 陈峰

改版套餐详情页支持多套餐

@@ -14,6 +14,9 @@ const bundleModel = require(`${mRoot}/bundle`); @@ -14,6 +14,9 @@ const bundleModel = require(`${mRoot}/bundle`);
14 */ 14 */
15 exports.detail = (req, res, next) => { 15 exports.detail = (req, res, next) => {
16 bundleModel.detail(req.query).then(result => { 16 bundleModel.detail(req.query).then(result => {
  17 + if (result.bundleDatas.length <= 3) {
  18 + result.any = true;
  19 + }
17 res.render('bundle/detail', Object.assign({ 20 res.render('bundle/detail', Object.assign({
18 module: 'product', 21 module: 'product',
19 page: 'bundle', 22 page: 'bundle',
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 const utils = '../../../utils'; 5 const utils = '../../../utils';
6 const _ = require('lodash'); 6 const _ = require('lodash');
7 const api = global.yoho.API; 7 const api = global.yoho.API;
  8 +const helpers = global.yoho.helpers;
8 const productProcess = require(`${utils}/product-process`); 9 const productProcess = require(`${utils}/product-process`);
9 10
10 /** 11 /**
@@ -35,6 +36,13 @@ const detail = (params) => { @@ -35,6 +36,13 @@ const detail = (params) => {
35 return getBundleBySkn(params.skn).then(result => { 36 return getBundleBySkn(params.skn).then(result => {
36 if (_.has(result, `data[${bundleIndex}]`)) { 37 if (_.has(result, `data[${bundleIndex}]`)) {
37 return { 38 return {
  39 + bundleDatas: _.map(result.data, (bundle, index) => {
  40 + return {
  41 + selected: index === bundleIndex,
  42 + title: _.get(bundle, 'bundleInfo.bundleName') || '优惠套装',
  43 + href: helpers.urlFormat('/product/bundle/detail', {skn: params.skn, index: ++index}),
  44 + };
  45 + }),
38 bundleInfo: _.get(result, `data[${bundleIndex}].bundleInfo`, {}), 46 bundleInfo: _.get(result, `data[${bundleIndex}].bundleInfo`, {}),
39 productList: productProcess.processProductList(_.get(result, `data[${bundleIndex}].productList`, [])) 47 productList: productProcess.processProductList(_.get(result, `data[${bundleIndex}].productList`, []))
40 }; 48 };
1 <div class="yoho-page bundle-body"> 1 <div class="yoho-page bundle-body">
  2 + <div class="bundle-tabs{{#if any}} any{{/if}}">
  3 + <div class="swiper-wrapper">
  4 + {{# bundleDatas}}
  5 + <div class="swiper-slide{{#if selected}} selected{{/if}}" data-index="{{@index}}" data-href="{{href}}">
  6 + <div class="line"></div>
  7 + <div class="title">
  8 + <span>{{title}}</span>
  9 + </div>
  10 + </div>
  11 + {{/ bundleDatas}}
  12 + </div>
  13 + </div>
2 {{# productList}} 14 {{# productList}}
3 <div class="bundle-detail-goods"> 15 <div class="bundle-detail-goods">
4 <div class="goods-img"><a href="{{url}}"><img src="{{image default_images 155 206}}" alt=""></a></div> 16 <div class="goods-img"><a href="{{url}}"><img src="{{image default_images 155 206}}" alt=""></a></div>
@@ -741,7 +741,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -741,7 +741,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
741 }); 741 });
742 confirming = false; 742 confirming = false;
743 hide(); 743 hide();
744 - return; 744 + return false;
745 } 745 }
746 746
747 // 针对是否处于编辑模式设置不同的url和需要post的数据 747 // 针对是否处于编辑模式设置不同的url和需要post的数据
@@ -4,7 +4,8 @@ @@ -4,7 +4,8 @@
4 require('product/bundle/detail.page.css'); 4 require('product/bundle/detail.page.css');
5 5
6 let $ = require('yoho-jquery'), 6 let $ = require('yoho-jquery'),
7 - tip = require('plugin/tip'); 7 + tip = require('plugin/tip'),
  8 + Swiper = require('yoho-swiper');
8 9
9 require('common'); 10 require('common');
10 let share = require('common/share'); 11 let share = require('common/share');
@@ -28,6 +29,13 @@ $(function() { @@ -28,6 +29,13 @@ $(function() {
28 link: window.location.href, 29 link: window.location.href,
29 desc: '超高性价比,开启省钱大作战!' 30 desc: '超高性价比,开启省钱大作战!'
30 }); 31 });
  32 + if ($('.bundle-tabs').find('.swiper-slide').length > 3) {
  33 + new Swiper('.bundle-tabs', {
  34 + freeMode: true,
  35 + slidesPerView: 'auto',
  36 + lazyLoading: true
  37 + });
  38 + }
31 }); 39 });
32 40
33 /** 41 /**
@@ -69,6 +77,17 @@ $('.goods-img').on('touchend', function() { @@ -69,6 +77,17 @@ $('.goods-img').on('touchend', function() {
69 77
70 }); 78 });
71 79
  80 +$('.bundle-tabs').on('click', '.swiper-slide', (e) => {
  81 + let $tab = $(e.currentTarget);
  82 +
  83 + if ($tab.hasClass('selected')) {
  84 + return;
  85 + }
  86 + let href = $tab.data('href');
  87 +
  88 + window.location.href = href;
  89 +});
  90 +
72 /** 91 /**
73 * 立即购买 92 * 立即购买
74 */ 93 */
@@ -3,6 +3,69 @@ @@ -3,6 +3,69 @@
3 min-height: 1000px; 3 min-height: 1000px;
4 } 4 }
5 5
  6 +.bundle-tabs {
  7 + padding-left: 23px;
  8 + padding-right: 23px;
  9 + height: 76px;
  10 + border-bottom: solid 1PX #ddd;
  11 + overflow: hidden;
  12 + background-color: #fff;
  13 +
  14 + &.any {
  15 + padding: 0;
  16 +
  17 + .swiper-slide {
  18 + width: auto;
  19 + flex: 1;
  20 + }
  21 + }
  22 +
  23 + .swiper-slide {
  24 + width: 168px;
  25 + text-align: center;
  26 + position: relative;
  27 + display: flex;
  28 +
  29 + &:first-child {
  30 + .line {
  31 + display: none;
  32 + }
  33 + }
  34 +
  35 + &.selected {
  36 + span {
  37 + color: #454545;
  38 + border-bottom: solid 2PX #454545;
  39 + }
  40 + }
  41 +
  42 + .line {
  43 + width: 1px;
  44 + height: 28px;
  45 + margin-top: 24px;
  46 + float: left;
  47 + border-left: solid 1PX #ddd;
  48 + }
  49 +
  50 + .title {
  51 + width: 100%;
  52 + flex: 1;
  53 +
  54 + span {
  55 + display: inline-block;
  56 + min-width: 103px;
  57 + max-width: 100%;
  58 + color: #b2b2b2;
  59 + line-height: 76px;
  60 + height: 76px;
  61 + font-size: 28px;
  62 + text-overflow: ellipsis;
  63 + overflow: hidden;
  64 + white-space: nowrap;
  65 + }
  66 + }
  67 + }
  68 +}
6 .bundle-detail-goods { 69 .bundle-detail-goods {
7 width: 100%; 70 width: 100%;
8 height: 248px; 71 height: 248px;
  1 +
  2 +@import "layout/swiper";
1 @import "detail"; 3 @import "detail";
2 @import "cart/chose-panel"; 4 @import "cart/chose-panel";