diff --git a/app/portal/controller/ShopcartController.php b/app/portal/controller/ShopcartController.php index 5986446..d47cfac 100644 --- a/app/portal/controller/ShopcartController.php +++ b/app/portal/controller/ShopcartController.php @@ -81,6 +81,27 @@ class ShopcartController extends WeChatBaseController{ } /** + * 商品数量修改 + */ + public function shop_cart_numchange(){ + + $id = $this->request->param('id',0,'intval'); + $num = $this->request->param('num',0,'intval'); + $data = Db::name('shopping_cart') -> where('id',$id) -> find(); + if($data['book_num'] != $num){ + if($num > 999){ + $this->error('商品数量不能大于999'); + } + $res = Db::name('shopping_cart') -> where('id',$id) -> update(['book_num'=>$num]); + if(!$res) { + $this->error('购物车更新失败'); + } + } + $this->success('修改成功'); + + } + + /** * 商品数量加一 */ public function shop_cart_numadd(){ diff --git a/public/themes/simpleboot3/portal/shopcart/shop_cart.html b/public/themes/simpleboot3/portal/shopcart/shop_cart.html index 0c7e26e..ab91715 100755 --- a/public/themes/simpleboot3/portal/shopcart/shop_cart.html +++ b/public/themes/simpleboot3/portal/shopcart/shop_cart.html @@ -40,7 +40,7 @@ <p class="de_topTxt1_1">¥<span>{$vo.price0}.{$vo.price1}</span></p> <div class="order_newsNum"> <div class="order_newsJian" onclick="jian({$vo.carid})">-</div> - <input class="order_newsnum" type="text" readonly="readonly" value="{$vo.book_num}" /> + <input class="order_newsnum" type="text" value="{$vo.book_num}" data-id="{$vo.carid}" oninput="var v=this.value||'';v=v.replace(/[^\d]/g,'');if(v.length==1 && v==0){v=''};this.value=v.substr(0,3);"/> <div class="order_newsJia" onclick="jia({$vo.carid})">+</div> </div> </div> @@ -222,6 +222,21 @@ $(".zoji span").html(totalPrice.toFixed(2)); } $(function() { + // 输入框修改数量 + $('.order_newsnum').change(function () { + var id = $(this).data('id'); + var num = $(this).val(); + if(num > 999) { + alert('商品数量不能大于999'); + } + $.post("{:url('Shopcart/shop_cart_numchange')}",{id:id,num:num},function(data){ + if(data.code == 1) { + calcTotal(); + } else { + alert(data.msg); + } + }); + }); $(".order_newsNum div").on("click", function(evt) { if ($(this).text() == "-") { var count = parseInt($(this).next().val()); diff --git a/simplewind/cmf/controller/WeChatBaseController.php b/simplewind/cmf/controller/WeChatBaseController.php index c239a0f..aaa0e78 100644 --- a/simplewind/cmf/controller/WeChatBaseController.php +++ b/simplewind/cmf/controller/WeChatBaseController.php @@ -208,10 +208,10 @@ class WeChatBaseController extends BaseController $user = Db::name('user')->where('id',6)->find(); cmf_update_current_user($user); } - else if(cmf_get_current_user_id()==484){ - $user = Db::name('user')->where('id',49)->find(); - cmf_update_current_user($user); - } +// else if(cmf_get_current_user_id()==484){ +// $user = Db::name('user')->where('id',49)->find(); +// cmf_update_current_user($user); +// } // if(cmf_get_current_user_id()==484){ // $user = Db::name('user')->where('id',6)->find(); // cmf_update_current_user($user); diff --git a/simplewind/thinkphp/library/think/Request.php b/simplewind/thinkphp/library/think/Request.php index 5f05b91..df21739 100644 --- a/simplewind/thinkphp/library/think/Request.php +++ b/simplewind/thinkphp/library/think/Request.php @@ -506,7 +506,13 @@ class Request } elseif (!$this->method) { if (isset($_POST[Config::get('var_method')])) { $this->method = strtoupper($_POST[Config::get('var_method')]); - $this->{$this->method}($_POST); + if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) { + $this->method = $method; + $this->{$this->method}($_POST); + } else { + $this->method = 'POST'; + } + unset($_POST[Config::get('var_method')]); } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); } else {