Authored by 刘传洋

m

@@ -20,8 +20,7 @@ @@ -20,8 +20,7 @@
20 <div class="size-row {{#unless active}} hide{{/unless}}"> 20 <div class="size-row {{#unless active}} hide{{/unless}}">
21 <div class="choose-size-detail"> 21 <div class="choose-size-detail">
22 {{#each sizes}} 22 {{#each sizes}}
23 - <div class="dt {{#if sizeActive}}active{{/if}}"  
24 - {{#unless num}}class="disable"{{/unless}} 23 + <div class="dt {{#if sizeActive}}active{{/if}} {{#unless num}}disabled{{/unless}}"
25 data-sku="{{sku}}" 24 data-sku="{{sku}}"
26 data-num="{{num}}" 25 data-num="{{num}}"
27 data-name="{{name}}">{{name}}</div> 26 data-name="{{name}}">{{name}}</div>
@@ -2,17 +2,18 @@ @@ -2,17 +2,18 @@
2 * Created by yoho on 2017-01-05. 2 * Created by yoho on 2017-01-05.
3 */ 3 */
4 4
5 -var $ = require('yoho-jquery');  
6 -var dialog = require('../common/dialog');  
7 -var Alert = dialog.Alert;  
8 -var $payWapper = $('.pay-wapper'), 5 +var $ = require('yoho-jquery'),
  6 + capi = require('./cart-api'),
  7 + dialog = require('../common/dialog'),
  8 + Alert = dialog.Alert,
  9 + $payWapper = $('.pay-wapper'),
9 selColorWinTpl = require('hbs/cart/select-color-panel.hbs'), 10 selColorWinTpl = require('hbs/cart/select-color-panel.hbs'),
10 - capi = require('./cart-api'); 11 + ColorPanelAction;
11 12
12 -  
13 -$(document).bind("click",function(e){ 13 +$(document).bind('click', function(e) {
14 var target = $(e.target); 14 var target = $(e.target);
15 - if(target.closest('.pay-pro-detail').length === 0 && target.closest('.goods-choose-box').length === 0){ 15 +
  16 + if (target.closest('.pay-pro-detail').length === 0 && target.closest('.goods-choose-box').length === 0) {
16 $('.goods-choose-box').hide(); 17 $('.goods-choose-box').hide();
17 e.stopPropagation(); 18 e.stopPropagation();
18 } 19 }
@@ -20,11 +21,10 @@ $(document).bind("click",function(e){ @@ -20,11 +21,10 @@ $(document).bind("click",function(e){
20 21
21 function renderAndShowSelWin($item, pinfo) { 22 function renderAndShowSelWin($item, pinfo) {
22 $item.find('.goods-choose-box').remove(); 23 $item.find('.goods-choose-box').remove();
23 - var $selWin = $(selColorWinTpl(pinfo)).appendTo($item);  
24 - $selWin.show(); 24 + $(selColorWinTpl(pinfo)).appendTo($item).show();
25 } 25 }
26 26
27 -var ColorPanelAction = { 27 +ColorPanelAction = {
28 showColorSizePanel: function() { 28 showColorSizePanel: function() {
29 29
30 var $this = $(this); 30 var $this = $(this);
@@ -71,7 +71,7 @@ var ColorPanelAction = { @@ -71,7 +71,7 @@ var ColorPanelAction = {
71 71
72 var $this = $(this); 72 var $this = $(this);
73 var $item = $this.closest('li[data-role="pitem"]'); 73 var $item = $this.closest('li[data-role="pitem"]');
74 - var pid = $item.data('pid'); 74 + // var pid = $item.data('pid');
75 var oldSku = $item.data('id'); 75 var oldSku = $item.data('id');
76 var $size = $this.closest('.goods-choose-box').find('.choose-size .dt.active'); 76 var $size = $this.closest('.goods-choose-box').find('.choose-size .dt.active');
77 var newSku = $size.data('sku'); 77 var newSku = $size.data('sku');
@@ -106,7 +106,9 @@ var ColorPanelAction = { @@ -106,7 +106,9 @@ var ColorPanelAction = {
106 var $srows = $this.closest('.goods-info').find('.choose-size .size-row'); 106 var $srows = $this.closest('.goods-info').find('.choose-size .size-row');
107 var $bigImgs = $this.closest('.goods-choose-box').find('.goods-info-bigImg .bigImg'); 107 var $bigImgs = $this.closest('.goods-choose-box').find('.goods-info-bigImg .bigImg');
108 108
109 - if ($this.hasClass('active')) return; 109 + if ($this.hasClass('active') || $this.hasClass('disabled')) {
  110 + return;
  111 + }
110 112
111 $this.siblings('.dt').removeClass('active'); 113 $this.siblings('.dt').removeClass('active');
112 $this.addClass('active'); 114 $this.addClass('active');
@@ -122,6 +124,9 @@ var ColorPanelAction = { @@ -122,6 +124,9 @@ var ColorPanelAction = {
122 124
123 var $this = $(this); 125 var $this = $(this);
124 126
  127 + if ($this.hasClass('disabled')) {
  128 + return;
  129 + }
125 $this.siblings('.dt').removeClass('active'); 130 $this.siblings('.dt').removeClass('active');
126 $this.addClass('active'); 131 $this.addClass('active');
127 } 132 }
@@ -131,7 +136,5 @@ var ColorPanelAction = { @@ -131,7 +136,5 @@ var ColorPanelAction = {
131 $payWapper.on('click', 'li[data-role="pitem"] .pay-pro-detail', ColorPanelAction.showColorSizePanel); 136 $payWapper.on('click', 'li[data-role="pitem"] .pay-pro-detail', ColorPanelAction.showColorSizePanel);
132 $payWapper.on('click', 'li[data-role="pitem"] .button-cancel', ColorPanelAction.hideColorSizePanel); 137 $payWapper.on('click', 'li[data-role="pitem"] .button-cancel', ColorPanelAction.hideColorSizePanel);
133 $payWapper.on('click', 'li[data-role="pitem"] .button-sure', ColorPanelAction.editColorOrSize); 138 $payWapper.on('click', 'li[data-role="pitem"] .button-sure', ColorPanelAction.editColorOrSize);
134 -$payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-color .dt', ColorPanelAction.selectColor);  
135 -$payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-size .dt', ColorPanelAction.selectSize);  
136 -  
137 - 139 +$payWapper.on('click', 'li[data-role="pitem"] .goods-choose-box .choose-color .dt', ColorPanelAction.selectColor);
  140 +$payWapper.on('click', 'li[data-role="pitem"] .goods-choose-box .choose-size .dt', ColorPanelAction.selectSize);