Browse Source

添加购物车

master
ZLW-PC\Administrator 7 years ago
parent
commit
a154cac39a
  1. 50
      resources/views/weixin/goods/goodsDetail.blade.php
  2. 3
      routes/web.php

50
resources/views/weixin/goods/goodsDetail.blade.php

@ -99,7 +99,7 @@ var swiper = new Swiper('.swiper-container', {
<div class="cart_list" >
<div class="cart_list_info goods_list_item">
<div class="cart_list_img">
<img src="/uploads/2017/06/201706041951031181.jpg" style="width:100%; height:100%;">
<img src="<?php echo $post['goods_img']; ?>" style="width:100%; height:100%;">
</div>
<div class="cart_goods_info">
<div class="cart_list_name">
@ -126,7 +126,7 @@ var swiper = new Swiper('.swiper-container', {
<input type="hidden" id="id" value="<?php echo $post['id']; ?>">
<input type="hidden" id="goods_number" value="<?php echo $post['goods_number']; ?>">
<div class="registered_btn pop_btn confirmBtn" style="display:none;" onclick="dosubmit()">
<input type="hidden" name="cartType" id="cartType" value="">
<input type="hidden" name="cart_type" id="cart_type" value="">
<span>确定</span>
</div>
</div>
@ -136,16 +136,17 @@ var swiper = new Swiper('.swiper-container', {
<script>
function mastershow(confirm)
{
/*如果已经选择属性,则弹出确定按钮,否则弹出加入购物车和立即购买按钮 */
//如果已经选择属性,则弹出确定按钮,否则弹出加入购物车和立即购买按钮
var selectname = $("#selectname").html();
if(selectname||confirm==1||confirm==2){
$("#cartType").val(confirm);
$("#cart_type").val(confirm);
$(".btnBox").hide();
$(".confirmBtn").show();
}else{
$(".btnBox").show();
$(".confirmBtn").hide();
}
$("#master").show();
}
function masterunshow()
@ -172,7 +173,7 @@ function cart_num_add()
{
//提示
layer.open({
content: '库存不足'
content: '库存不足'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
@ -182,6 +183,45 @@ function cart_num_add()
$('#num').val(num);
}
function dosubmit()
{
var url = '<?php echo env('APP_API_URL').'/cart_add'; ?>';
var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
var cart_type = $("#cart_type").val();
var goods_number = $("#num").val();
var goods_id = $("#id").val();
$.post(url,{access_token:access_token,goods_id:goods_id,goods_number:goods_number},function(res)
{
if(res.code==0)
{
//提示
layer.open({
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
/* if(cart_type == 2)
{
location.href = '<?php echo substr(route('weixin_order_pay',array('id'=>1)),0,strlen(route('weixin_order_pay',array('id'=>1)))-1); ?>' + res.data['id'];
} */
}
else
{
//提示
layer.open({
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
},'json');
$("#master").hide();
}
</script>
<!-- 底部按钮开始 -->

3
routes/web.php

@ -92,6 +92,8 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['w
Route::get('/collect_goods', 'CollectGoodsController@index')->name('weixin_user_collect_goods');
//购物车
Route::get('/cart', 'CartController@index')->name('weixin_cart');
//订单
Route::get('/order_pay/{id}', 'OrderController@orderPay')->name('weixin_order_pay'); //订单支付
//收货地址
Route::get('/user_address', 'AddressController@index')->name('weixin_user_address_list');
Route::get('/user_address_add', 'AddressController@userAddressAdd')->name('weixin_user_address_add');
@ -159,7 +161,6 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web
Route::get('/cart_list', 'CartController@cartList'); //购物车列表
Route::post('/cart_clear', 'CartController@cartClear'); //清空购物车
Route::post('/cart_add', 'CartController@cartAdd'); //添加购物车
Route::post('/cart_update', 'CartController@cartUpdate'); //修改购物车
Route::post('/cart_delete', 'CartController@cartDelete'); //删除购物
//分销

Loading…
Cancel
Save