Authored by yyq

购物车问题修复

@@ -153,14 +153,24 @@ function loadCartDetail(key) { @@ -153,14 +153,24 @@ function loadCartDetail(key) {
153 }; 153 };
154 154
155 $.getJSON('http://www.yohobuy.com/common/shoppingCart/?callback=?', param, function(jsonData) { 155 $.getJSON('http://www.yohobuy.com/common/shoppingCart/?callback=?', param, function(jsonData) {
156 - var totalGoods, data; 156 + var totalGoods = [],
  157 + infoArr = [
  158 + 'main_goods',
  159 + 'advance_goods',
  160 + 'outlet_goods',
  161 + 'gift_goods',
  162 + 'need_pay_gifts'
  163 + ],
  164 + data;
157 165
158 if (jsonData.code === 200) { 166 if (jsonData.code === 200) {
159 data = jsonData.data; 167 data = jsonData.data;
160 - totalGoods = $.merge(data.main_goods, data.advance_goods);  
161 - totalGoods = $.merge(totalGoods, data.outlet_goods);  
162 - totalGoods = $.merge(totalGoods, data.gift_goods);  
163 - totalGoods = $.merge(totalGoods, data.need_pay_gifts); 168 + $.each(infoArr, function(k, v) {
  169 + if (data[v]) {
  170 + totalGoods = $.merge(totalGoods, data[v]);
  171 + }
  172 + });
  173 +
164 if (totalGoods && totalGoods.length) { 174 if (totalGoods && totalGoods.length) {
165 data.totalGoods = totalGoods; 175 data.totalGoods = totalGoods;
166 $miniCart.html(cartFn({ 176 $miniCart.html(cartFn({