Authored by 毕凯

购物车选择框加载优化

@@ -96,17 +96,21 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -96,17 +96,21 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
96 * @return false or undefined 96 * @return false or undefined
97 * 97 *
98 */ 98 */
99 -function showEditPannelWithSku(html, id, isSelected, isEditNum) {  
100 - if (html.length < 2) { 99 +function showEditPannelWithSku(html, id, isSelected, isEditNum, skn) {
  100 + var $html = $(html);
  101 +
  102 + if (!$html.hasClass('chose-panel')) {
101 tip.show('出错啦!'); 103 tip.show('出错啦!');
102 return false; 104 return false;
103 } 105 }
104 106
  107 + // 记录成功加载的选择框
  108 + previousEditSkn = skn;
  109 +
105 //删掉页面上原有的pannel 110 //删掉页面上原有的pannel
106 chosePanel.remove(); 111 chosePanel.remove();
107 112
108 - $(html).appendTo('#mainCart');  
109 - 113 + $html.appendTo('#mainCart');
110 114
111 chosePanel.init(); 115 chosePanel.init();
112 chosePanel.setEditModeWithSknId(id, isSelected); 116 chosePanel.setEditModeWithSknId(id, isSelected);
@@ -141,9 +145,6 @@ $('.icon-edit').on('touchstart', function(e) { @@ -141,9 +145,6 @@ $('.icon-edit').on('touchstart', function(e) {
141 return; 145 return;
142 } 146 }
143 147
144 - previousEditSkn = skn;  
145 -  
146 -  
147 $checkBox = $this.closest('.info').siblings('.checkbox'); 148 $checkBox = $this.closest('.info').siblings('.checkbox');
148 $tag = $this.closest('.deps').siblings('.few-tag'); 149 $tag = $this.closest('.deps').siblings('.few-tag');
149 150
@@ -157,7 +158,6 @@ $('.icon-edit').on('touchstart', function(e) { @@ -157,7 +158,6 @@ $('.icon-edit').on('touchstart', function(e) {
157 158
158 loading.showLoadingMask(); 159 loading.showLoadingMask();
159 160
160 -  
161 $.ajax({ 161 $.ajax({
162 url: '/cart/index/goodinfo', 162 url: '/cart/index/goodinfo',
163 data: { 163 data: {
@@ -165,7 +165,7 @@ $('.icon-edit').on('touchstart', function(e) { @@ -165,7 +165,7 @@ $('.icon-edit').on('touchstart', function(e) {
165 buy_num: count 165 buy_num: count
166 }, 166 },
167 success: function(res) { 167 success: function(res) {
168 - showEditPannelWithSku(res, id, $checkBox.hasClass('icon-cb-checked'), canEditNum); 168 + showEditPannelWithSku(res, id, $checkBox.hasClass('icon-cb-checked'), canEditNum, skn);
169 }, 169 },
170 error: function() { 170 error: function() {
171 tip.show('网络异常'); 171 tip.show('网络异常');