Authored by yyq

尺码选择

... ... @@ -149,6 +149,7 @@ const setProductData = base => {
group = {
name: value.colorName,
title: `${data.name} ${value.colorName}`,
color: value.colorName,
total: 0
};
... ... @@ -196,7 +197,8 @@ const setProductData = base => {
// 默认选中该sku商品
if (group.total > 0 && !chooseSkuFlag) {
group.focus = true; // 选中sku商品
data.colorName = group.name;
group.cur = true; // 选中sku商品
chooseSkuFlag = true;
}
... ...
... ... @@ -10,8 +10,8 @@
<div class="thumbs left clearfix">
<div class="thumb-list">
{{# colors}}
<div class="thumb-wrap{{#unless focus}} hide{{/unless}}">
{{#if focus}}
<div class="thumb-wrap{{#unless cur}} hide{{/unless}}">
{{#if cur}}
{{# thumbs}}
<img class="thumb" src="{{image . 75 100}}" data-shower="{{image . 482 643}}">
{{/ thumbs}}
... ... @@ -40,24 +40,24 @@
<div class="option-content">
<p class="choose-color">
<label class="title">Color:</label>
<span class="color">蓝色</span>
<span class="color">{{colorName}}</span>
</p>
<div class="color-list clearfix">
{{# colors}}
<div class="color-item" data-color="{{color}}" data-color="{{total}}" >
<div class="color-item" data-color="{{color}}" data-total="{{total}}" >
{{> round-color}}
</div>
{{/ colors}}
</div>
<p class="choose-size">
<label class="title">Size:</label>
<span class="size">M</span>
<span class="size"></span>
</p>
<div class="sizes">
{{# colors}}
<ul class="size-list {{#unless focus}}hide{{/unless}} clearfix">
<ul class="size-list{{#unless cur}} hide{{/unless}} clearfix">
{{# sizes}}
<li {{#unless num}}class="disable"{{/unless}} data-title="{{title}}" data-sku="{{sku}}" data-num="{{num}}">{{name}}</li>
<li {{#unless num}}class="disable"{{/unless}} title="{{title}}" data-sku="{{sku}}" data-num="{{num}}" data-name="{{name}}">{{name}}</li>
{{/ sizes}}
</ul>
{{/ colors}}
... ...
/**
* 退换货申请
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/7/15
*/
var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload');
var $colorText = $('.choose-color .color'),
$sizeText = $('.choose-size .size'),
$colorList = $('.color-list'),
$sizeList = $('.size-list'),
$sizeItem = $('.size-list').children();
lazyload($('img.lazy'));
$colorList.on('click', '.round-color', function() {
var $this = $(this),
data = $this.parent().data();
if (!$this.hasClass('cur')) {
$colorList.removeClass('cur');
$colorText.text(data.color ? data.color : '');
$this.addClass('cur');
}
});
$sizeList.on('click', 'li', function() {
var $this = $(this),
data = $this.data();
if (!$this.hasClass('disable') && +data.num) {
$sizeItem.removeClass('cur');
$sizeText.text(data.name ? data.name : '');
$this.addClass('cur');
}
});
\ No newline at end of file
... ...