正在显示
4 个修改的文件
包含
47 行增加
和
5 行删除
@@ -81,6 +81,27 @@ class ShopcartController extends WeChatBaseController{ | @@ -81,6 +81,27 @@ class ShopcartController extends WeChatBaseController{ | ||
81 | } | 81 | } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | + * 商品数量修改 | ||
85 | + */ | ||
86 | + public function shop_cart_numchange(){ | ||
87 | + | ||
88 | + $id = $this->request->param('id',0,'intval'); | ||
89 | + $num = $this->request->param('num',0,'intval'); | ||
90 | + $data = Db::name('shopping_cart') -> where('id',$id) -> find(); | ||
91 | + if($data['book_num'] != $num){ | ||
92 | + if($num > 999){ | ||
93 | + $this->error('商品数量不能大于999'); | ||
94 | + } | ||
95 | + $res = Db::name('shopping_cart') -> where('id',$id) -> update(['book_num'=>$num]); | ||
96 | + if(!$res) { | ||
97 | + $this->error('购物车更新失败'); | ||
98 | + } | ||
99 | + } | ||
100 | + $this->success('修改成功'); | ||
101 | + | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
84 | * 商品数量加一 | 105 | * 商品数量加一 |
85 | */ | 106 | */ |
86 | public function shop_cart_numadd(){ | 107 | public function shop_cart_numadd(){ |
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | <p class="de_topTxt1_1">¥<span>{$vo.price0}.{$vo.price1}</span></p> | 40 | <p class="de_topTxt1_1">¥<span>{$vo.price0}.{$vo.price1}</span></p> |
41 | <div class="order_newsNum"> | 41 | <div class="order_newsNum"> |
42 | <div class="order_newsJian" onclick="jian({$vo.carid})">-</div> | 42 | <div class="order_newsJian" onclick="jian({$vo.carid})">-</div> |
43 | - <input class="order_newsnum" type="text" readonly="readonly" value="{$vo.book_num}" /> | 43 | + <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);"/> |
44 | <div class="order_newsJia" onclick="jia({$vo.carid})">+</div> | 44 | <div class="order_newsJia" onclick="jia({$vo.carid})">+</div> |
45 | </div> | 45 | </div> |
46 | </div> | 46 | </div> |
@@ -222,6 +222,21 @@ | @@ -222,6 +222,21 @@ | ||
222 | $(".zoji span").html(totalPrice.toFixed(2)); | 222 | $(".zoji span").html(totalPrice.toFixed(2)); |
223 | } | 223 | } |
224 | $(function() { | 224 | $(function() { |
225 | + // 输入框修改数量 | ||
226 | + $('.order_newsnum').change(function () { | ||
227 | + var id = $(this).data('id'); | ||
228 | + var num = $(this).val(); | ||
229 | + if(num > 999) { | ||
230 | + alert('商品数量不能大于999'); | ||
231 | + } | ||
232 | + $.post("{:url('Shopcart/shop_cart_numchange')}",{id:id,num:num},function(data){ | ||
233 | + if(data.code == 1) { | ||
234 | + calcTotal(); | ||
235 | + } else { | ||
236 | + alert(data.msg); | ||
237 | + } | ||
238 | + }); | ||
239 | + }); | ||
225 | $(".order_newsNum div").on("click", function(evt) { | 240 | $(".order_newsNum div").on("click", function(evt) { |
226 | if ($(this).text() == "-") { | 241 | if ($(this).text() == "-") { |
227 | var count = parseInt($(this).next().val()); | 242 | var count = parseInt($(this).next().val()); |
@@ -208,10 +208,10 @@ class WeChatBaseController extends BaseController | @@ -208,10 +208,10 @@ class WeChatBaseController extends BaseController | ||
208 | $user = Db::name('user')->where('id',6)->find(); | 208 | $user = Db::name('user')->where('id',6)->find(); |
209 | cmf_update_current_user($user); | 209 | cmf_update_current_user($user); |
210 | } | 210 | } |
211 | - else if(cmf_get_current_user_id()==484){ | ||
212 | - $user = Db::name('user')->where('id',49)->find(); | ||
213 | - cmf_update_current_user($user); | ||
214 | - } | 211 | +// else if(cmf_get_current_user_id()==484){ |
212 | +// $user = Db::name('user')->where('id',49)->find(); | ||
213 | +// cmf_update_current_user($user); | ||
214 | +// } | ||
215 | // if(cmf_get_current_user_id()==484){ | 215 | // if(cmf_get_current_user_id()==484){ |
216 | // $user = Db::name('user')->where('id',6)->find(); | 216 | // $user = Db::name('user')->where('id',6)->find(); |
217 | // cmf_update_current_user($user); | 217 | // cmf_update_current_user($user); |
@@ -506,7 +506,13 @@ class Request | @@ -506,7 +506,13 @@ class Request | ||
506 | } elseif (!$this->method) { | 506 | } elseif (!$this->method) { |
507 | if (isset($_POST[Config::get('var_method')])) { | 507 | if (isset($_POST[Config::get('var_method')])) { |
508 | $this->method = strtoupper($_POST[Config::get('var_method')]); | 508 | $this->method = strtoupper($_POST[Config::get('var_method')]); |
509 | + if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) { | ||
510 | + $this->method = $method; | ||
509 | $this->{$this->method}($_POST); | 511 | $this->{$this->method}($_POST); |
512 | + } else { | ||
513 | + $this->method = 'POST'; | ||
514 | + } | ||
515 | + unset($_POST[Config::get('var_method')]); | ||
510 | } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { | 516 | } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { |
511 | $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); | 517 | $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); |
512 | } else { | 518 | } else { |
-
请 注册 或 登录 后发表评论