cart.htm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ##tlayout("www/layout.htm"){
  2. <section class="container" style="min-height: 600px;">
  3. ##if(cart_list!=null && cart_list.~size!=0){
  4. <table class="table shop-cart">
  5. <thead>
  6. <tr>
  7. <th>商品</th>
  8. <th width="100px;">水源</th>
  9. <th width="100px;">单价</th>
  10. <th width="200px;">数量/箱(1箱=24瓶)</th>
  11. <th width="100px;">小计</th>
  12. <th width="100px;">操作</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. ##for(_item in cart_list){
  17. <tr>
  18. <td>
  19. <div class="product">
  20. <div class="pro-img pull-left">
  21. <a href="${_item.diy_img_url!}" target="_blank">
  22. <img src="${_item.diy_img_url!}" />
  23. </a>
  24. </div>
  25. <div class="pro-title" style="font-weight: bold;margin-right: 0px;">${_item.diy_title!}</div>
  26. <div class="pro-title" style="font-size: 12px;margin-right: 0px;">${_item.diy_remark!}</div>
  27. <div class="pro-title" style="font-size: 12px;margin-right: 0px;">${_item.bottle_title!}&nbsp;|&nbsp;${_item.bottle_type_title!}</div>
  28. </div>
  29. </td>
  30. <td class="sub">
  31. <select class="select_border" onchange="changeType(${_item.cart_id!}, this)">
  32. ##for(_type in _item.type_list!){
  33. ##if(_type.id==_item.bottle_type_id){
  34. <option value="${_type.id!}" selected="selected">${_type.title!}|${_type.price!}元</option>
  35. ##}else{
  36. <option value="${_type.id!}">${_type.title!}|${_type.price!}元</option>
  37. ##}
  38. ##}
  39. </select>
  40. </td>
  41. <td>¥${_item.bottle_price!}</td>
  42. <td>
  43. <div class="count">
  44. <span class="click-btn" onclick="changeStep(${_item.cart_id!}, 0)">-</span>
  45. <input class="num" type="text" name="number_${_item.cart_id!}" value="${_item.cart_number!}" onchange="changeNumber(${_item.cart_id!})" />
  46. <span class="click-btn" onclick="changeStep(${_item.cart_id!}, 1)">+</span>
  47. </div>
  48. </td>
  49. <td class="sub">¥${_item.bottle_price * _item.cart_number}</td>
  50. <td class="del"><a href="javascript:deleteCart(${_item.cart_id!})" class="red">删除</a></td>
  51. </tr>
  52. ##}
  53. <tr>
  54. <th colspan="6" style="color: red;">注意:数量单位为箱,1箱=24瓶</th>
  55. </tr>
  56. </tbody>
  57. </table>
  58. <div class="total clearfix">
  59. <a href="/shop/ordersMsg" class="btn btn-lg btn-lightblue pull-right">去结算</a>
  60. <div class="pull-right count">小计:<span>¥${subtotal!}</span></div>
  61. </div>
  62. ##}else{
  63. <div class="kong">
  64. <img src="/www/image/cart_kong_icon.png" class="kong_img" />
  65. <p>购物车为空</p>
  66. <div class="kong_btn_area">
  67. <a href="/" class="btn">继续购物</a>
  68. </div>
  69. </div>
  70. ##}
  71. </section>
  72. <script>
  73. function deleteCart(id){
  74. $.post("/shop/deleteCart",{id:id},function(data){
  75. alert(data.msg);
  76. if(data.success){
  77. location.reload();
  78. }
  79. });
  80. }
  81. function changeStep(id, status){
  82. if(status==1){
  83. $("input[name='number_" + id + "']").val($("input[name='number_" + id + "']").val() * 1 + 1);
  84. }else{
  85. if($("input[name='number_" + id + "']").val() * 1 > 1){
  86. $("input[name='number_" + id + "']").val($("input[name='number_" + id + "']").val() * 1 - 1);
  87. }
  88. }
  89. changeNumber(id);
  90. }
  91. function changeNumber(id){
  92. $.post("/shop/changeNumber",{id:id, number:$("input[name='number_" + id + "']").val()},function(data){
  93. if(data.success){
  94. location.reload();
  95. }else{
  96. alert(data.msg);
  97. }
  98. });
  99. }
  100. function changeType(id, object){
  101. $.post("/shop/changeType",{id:id, btid:$(object).val()},function(data){
  102. if(data.success){
  103. location.reload();
  104. }else{
  105. alert(data.msg);
  106. }
  107. });
  108. }
  109. </script>
  110. ##}