Authored by zzzzzzz

收藏人数随着状态动态变化

@@ -272,6 +272,7 @@ var $collect = $('.fav-container'); @@ -272,6 +272,7 @@ var $collect = $('.fav-container');
272 $collect.on('touchstart', function() { 272 $collect.on('touchstart', function() {
273 var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok'; 273 var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
274 var self = $(this); 274 var self = $(this);
  275 + var num = parseInt(self.parent().find('.faved-num').html());
275 276
276 $.ajax({ 277 $.ajax({
277 method: 'get', 278 method: 'get',
@@ -291,10 +292,14 @@ $collect.on('touchstart', function() { @@ -291,10 +292,14 @@ $collect.on('touchstart', function() {
291 if (self.hasClass('fav-yes')) { 292 if (self.hasClass('fav-yes')) {
292 self.hide(); 293 self.hide();
293 self.prev().show(); 294 self.prev().show();
  295 + num--;
  296 + self.parent().find('.faved-num').html(num + '人已收藏');
294 tip.show('取消收藏成功!'); 297 tip.show('取消收藏成功!');
295 } else { 298 } else {
296 self.hide(); 299 self.hide();
297 self.next().show(); 300 self.next().show();
  301 + num++;
  302 + self.parent().find('.faved-num').html(num + '人已收藏');
298 tip.show('收藏成功!'); 303 tip.show('收藏成功!');
299 } 304 }
300 } 305 }