You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
9.4 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/>
  2. <title>购物车</title><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
  3. <link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet">
  4. <script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script>
  5. <script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script>
  6. <meta name="keywords" content="关键词"><meta name="description" content="描述"></head><body>
  7. <div class="classreturn loginsignup">
  8. <div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div>
  9. <div class="ds-in-bl tit center"><span>购物车</span></div>
  10. <div class="ds-in-bl nav_menu"><a href="javascript:void(0);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/class1.png" alt="菜单"></a></div>
  11. </div>
  12. @include('weixin.common.headerNav')
  13. <?php if($list){ ?>
  14. <div class="cart_list">
  15. <!--商品列表-s-->
  16. <?php foreach($list as $k=>$v){ ?>
  17. <div class="sc_list" id="cart_list_<?php echo $v['id']; ?>">
  18. <div class="radio-img">
  19. <div class="radio fl ">
  20. <!--商品勾选按钮-->
  21. <span onclick="checkGoods(this)" class="che">
  22. <i>
  23. <input name="checkItem" type="checkbox" style="display:none;" data-goods-id="<?php echo $v['goods_id']; ?>" data-cart-id="<?php echo $v['id']; ?>">
  24. </i>
  25. </span>
  26. </div>
  27. <div class="shopimg fl">
  28. <a href="<?php echo $v['goods_detail_url']; ?>">
  29. <img src="<?php echo $v['litpic']; ?>">
  30. </a>
  31. </div>
  32. </div>
  33. <div class="deleshow">
  34. <div class="deletes">
  35. <!--商品名-->
  36. <p class="tit"><?php echo $v['title']; ?></p>
  37. <!--删除按钮-->
  38. <a href="javascript:void(0);" class="delescj deleteGoods" data-cart-id="<?php echo $v['id']; ?>"><img src="<?php echo env('APP_URL'); ?>/images/weixin/dele.png"></a>
  39. </div>
  40. <!--商品属性,规格-->
  41. <p class="weight"></p>
  42. <div class="prices">
  43. <p class="sc_pri fl">
  44. <!--商品单价-->
  45. <span></span><span id="goods_price<?php echo $v['goods_id']; ?>"><?php echo $v['final_price']; ?></span>
  46. </p>
  47. <!--加减数量-->
  48. <div class="plus fr get_mp">
  49. <span class="mp_minous" onClick="change_goods_number(1,<?php echo $v['goods_id']; ?>)">-</span>
  50. <span class="mp_mp"><input name="goods_number<?php echo $v['goods_id']; ?>" type="text" id="goods_number<?php echo $v['goods_id']; ?>" value="<?php echo $v['goods_number']; ?>" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" autocomplete="off" value="1" onblur="change_goods_number(2,<?php echo $v['goods_id']; ?>)" class="input-num"></span>
  51. <span class="mp_plus" onClick="change_goods_number(3,<?php echo $v['goods_id']; ?>)">+</span>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <!--商品列表-e-->
  57. <?php } ?>
  58. <!--提交栏-s-->
  59. <div class="foohi foohiext">
  60. <div class="payit ma-to-20 payallb">
  61. <div class="radio fl">
  62. <span class="che alltoggle checkFull" onclick="checkGoods(this)">
  63. <i></i>
  64. </span>
  65. <span class="all">全选</span>
  66. </div>
  67. <div class="fr">
  68. <a href="javascript:void(0);" onclick="cart_submit();">去结算</a>
  69. </div>
  70. <div class="youbia">
  71. <p><span class="pmo">总计:</span><span></span><span id="total_fee">0</span></p>
  72. </div>
  73. </div>
  74. </div>
  75. <!--提交栏-e-->
  76. </div>
  77. <?php }else{ ?>
  78. <!--购物车没有商品-start-->
  79. <div class="cart_list">
  80. <div class="nonenothing">
  81. <img src="<?php echo env('APP_URL'); ?>/images/weixin/nothing.png">
  82. <p>购物车暂无商品</p>
  83. <a href="<?php echo route('weixin'); ?>">去逛逛</a>
  84. </div>
  85. </div>
  86. <br><br>
  87. <!--猜你喜欢-start-->
  88. <div class="floor">
  89. <div class="banner_headline">
  90. <div class="tit">
  91. <h4>猜你喜欢</h4>
  92. </div>
  93. </div>
  94. <div class="likeshop">
  95. <ul class="goods_list">
  96. <?php if($like_goods_list){foreach($like_goods_list as $k=>$v){ ?>
  97. <li><a href="<?php echo $v['goods_detail_url']; ?>"><img alt="<?php echo $v['title']; ?>" src="<?php echo $v['litpic']; ?>"><div class="goods_info"><p class="goods_tit"><?php echo $v['title']; ?></p><div class="goods_price">¥<b><?php echo $v['price']; ?></b></div></div></a></li>
  98. <?php }} ?>
  99. </ul>
  100. </div>
  101. </div>
  102. <!--购物车没有商品-end-->
  103. @include('weixin.common.footer')
  104. <?php } ?>
  105. <script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>
  106. <script>
  107. function cart_submit()
  108. {
  109. var cart_goods_ids = '';
  110. $('[name="checkItem"][checked]').each(function(){
  111. var goods_id = $(this).attr('data-cart-id');
  112. if(cart_goods_ids){cart_goods_ids = cart_goods_ids+'_'+goods_id;}else{cart_goods_ids = cart_goods_ids+goods_id;}
  113. });
  114. if(cart_goods_ids == '')
  115. {
  116. layer.open({
  117. content: '请选择商品'
  118. ,skin: 'msg'
  119. ,time: 2 //2秒后自动关闭
  120. });
  121. return false;
  122. }
  123. location.href = '<?php echo substr(route('weixin_cart_checkout',array('ids'=>1)), 0, -1); ?>' + cart_goods_ids;
  124. }
  125. function change_goods_number(type, id)
  126. {
  127. var goods_number = document.getElementById('goods_number'+id).value;
  128. if(type != 2)
  129. {
  130. var goods_number = document.getElementById('goods_number'+id).value;
  131. document.getElementById('goods_number'+id).value = goods_number;
  132. }
  133. if(type == 1){goods_number--;}
  134. if(type == 3){goods_number++;}
  135. if(goods_number <= 0){goods_number=1;}
  136. if(!/^[0-9]*$/.test(goods_number)){goods_number = document.getElementById('goods_number'+id).value;}
  137. document.getElementById('goods_number'+id).value = goods_number;
  138. var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
  139. var url = '<?php echo env('APP_API_URL').'/cart_add'; ?>';
  140. $.post(url,{access_token:access_token,goods_id:id,goods_number:goods_number},function(res)
  141. {
  142. if (res.code == 0)
  143. {
  144. changeCartTotalPrice();
  145. }
  146. else if (res.msg != '')
  147. {
  148. //提示
  149. layer.open({
  150. content: '姓名不能为空'
  151. ,skin: 'msg'
  152. ,time: 2 //2秒后自动关闭
  153. });
  154. var goods_number = document.getElementById('goods_number'+id).value;
  155. document.getElementById('goods_number'+id).value = goods_number;
  156. }
  157. }, 'json');
  158. }
  159. //删除购物车商品
  160. $(function () {
  161. //删除购物车商品事件
  162. $(document).on("click", '.deleteGoods', function (e) {
  163. var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
  164. var cart_ids = new Array();
  165. cart_ids.push($(this).attr('data-cart-id'));
  166. layer.open({
  167. content: '确定要删除此商品吗'
  168. ,btn: ['确定', '取消']
  169. ,yes: function(index){
  170. layer.close(index);
  171. $.ajax({
  172. type : "POST",
  173. url:"<?php echo env('APP_API_URL').'/cart_delete'; ?>",
  174. dataType:'json',
  175. data: {access_token:access_token,id:cart_ids},
  176. success: function(res){
  177. layer.open({
  178. content: res.msg
  179. ,skin: 'msg'
  180. ,time: 2 //2秒后自动关闭
  181. });
  182. window.location.reload();
  183. }
  184. });
  185. }
  186. });
  187. })
  188. });
  189. //勾选商品
  190. function checkGoods(obj)
  191. {
  192. if($(obj).hasClass('check_t'))
  193. {
  194. //改变颜色
  195. $(obj).removeClass('check_t');
  196. //取消选中
  197. $(obj).find('input').attr('checked',false);
  198. }
  199. else
  200. {
  201. //改变颜色
  202. $(obj).addClass('check_t');
  203. //勾选选中
  204. $(obj).find('input').attr('checked',true);
  205. }
  206. //选中全选多选框
  207. if($(obj).hasClass('checkFull'))
  208. {
  209. if($(obj).hasClass('check_t'))
  210. {
  211. $(".che").each(function(i,o){
  212. $(this).addClass('check_t');
  213. $(this).find('input').attr('checked',true);
  214. });
  215. }
  216. else
  217. {
  218. $(".che").each(function(i,o){
  219. $(this).removeClass('check_t');
  220. $(this).find('input').attr('checked',false);
  221. });
  222. }
  223. }
  224. changeCartTotalPrice();
  225. }
  226. //修改选中商品总价
  227. function changeCartTotalPrice()
  228. {
  229. var total_price = 0;
  230. $('[name="checkItem"][checked]').each(function(){
  231. var goods_id = $(this).attr('data-goods-id');
  232. total_price = total_price + $('#goods_number'+goods_id).val() * $('#goods_price'+goods_id).text();
  233. });
  234. $('#total_fee').text(total_price.toFixed(2));
  235. }
  236. </script>
  237. </body></html>