From 6e9cc9274829d86e0de387d2be8b9c3068c9db26 Mon Sep 17 00:00:00 2001 From: anyv <anyu@bronet.cn> Date: Wed, 5 Jun 2019 15:27:55 +0800 Subject: [PATCH] 2 --- app/portal/controller/ShopcartController.php | 26 ++++++++++++++++++++++++++ public/themes/simpleboot3/portal/shopcart/shop_cart.html | 21 +++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/app/portal/controller/ShopcartController.php b/app/portal/controller/ShopcartController.php index 4559044..bf0745d 100644 --- a/app/portal/controller/ShopcartController.php +++ b/app/portal/controller/ShopcartController.php @@ -79,7 +79,33 @@ class ShopcartController extends WeChatBaseController{ } + /** + * 商品数量加一 + */ + public function shop_cart_numadd(){ + + $id = $_POST['id']; + $data = Db::name('shopping_cart') -> where('id',$id) -> find(); + if($data['book_num']<200){ + Db::name('shopping_cart') -> where('id',$id) -> setInc('book_num'); + } + return true; + + } + /** + * 商品数量减一 + */ + public function shop_cart_numdec(){ + + $id = $_POST['id']; + $data = Db::name('shopping_cart') -> where('id',$id) -> find(); + if($data['book_num']>1){ + Db::name('shopping_cart') -> where('id',$id) -> setDec('book_num'); + } + return true; + + } diff --git a/public/themes/simpleboot3/portal/shopcart/shop_cart.html b/public/themes/simpleboot3/portal/shopcart/shop_cart.html index 4adeb4d..c000d62 100644 --- a/public/themes/simpleboot3/portal/shopcart/shop_cart.html +++ b/public/themes/simpleboot3/portal/shopcart/shop_cart.html @@ -37,9 +37,9 @@ <div class="order_newsTxt3"> <p class="de_topTxt1_1">¥<span>{$vo.price0}</span>.{$vo.price1}</p> <div class="order_newsNum"> - <div class="order_newsJian">-</div> + <div class="order_newsJian" onclick="jia({$vo.carid})">-</div> <input class="order_newsnum" type="text" readonly="readonly" value="1" /> - <div class="order_newsJia">+</div> + <div class="order_newsJia" onclick="jian({$vo.carid})">+</div> </div> </div> </div> @@ -146,6 +146,23 @@ } + /** + *点击加一 + */ + function jia(id){ + $.post("{:url('Shopcart/shop_cart_numadd')}",{id:id},function(data){ + }); + } + + /** + * 点击减一 + */ + function jian(id){ + $.post("{:url('Shopcart/shop_cart_numdec')}",{id:id},function(data){ + + }); + } + // 计算总计 function calcTotal() { var checkBoxes = $(".sh_cartround img"); -- libgit2 0.24.0