pgoods_cart.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //删除兑换积分礼品购物车
  2. function drop_pcart_item(pcart_id){
  3. var tr = $('#pcart_item_' + pcart_id);
  4. var amount_span = $('#pcart_amount');
  5. var cart_goods_kinds = $('#cart_goods_kinds');
  6. $.getJSON(HOMESITEURL+'/Pointcart/drop.html?pc_id=' + pcart_id, function(result){
  7. window.location.reload(); //刷新
  8. });
  9. }
  10. function pcart_change_quantity(pcart_id, input){
  11. var amount_span = $('#pcart_amount');
  12. var subtotal_span = $('#item_' + pcart_id + '_subtotal');
  13. var quantity_input = $('#input_item_' + pcart_id);
  14. //暂存为局部变量,否则如果用户输入过快有可能造成前后值不一致的问题
  15. var _v = input.value;
  16. $.getJSON(HOMESITEURL+'/Pointcart/update.html?pc_id=' + pcart_id + '&quantity=' + _v, function(result){
  17. if(result.done){
  18. //更新成功
  19. $(input).attr('changed', _v);
  20. amount_span.html(result.amount);
  21. subtotal_span.html(result.subtotal);
  22. quantity_input.val(result.quantity);
  23. }
  24. else{
  25. //更新失败
  26. alert(result.msg);
  27. window.location.reload(); //刷新
  28. }
  29. });
  30. }
  31. function pcart_decrease_quantity(pcart_id){
  32. var item = $('#input_item_' + pcart_id);
  33. var orig = Number(item.val());
  34. if(orig > 1){
  35. item.val(orig - 1);
  36. item.keyup();
  37. }
  38. }
  39. function pcart_add_quantity(pcart_id){
  40. var item = $('#input_item_' + pcart_id);
  41. var orig = Number(item.val());
  42. item.val(orig + 1);
  43. item.keyup();
  44. }