正在显示
3 个修改的文件
包含
18 行增加
和
5 行删除
@@ -85,7 +85,7 @@ class Cart extends Api | @@ -85,7 +85,7 @@ class Cart extends Api | ||
85 | $post['goods_style'] = json_encode($post['goods_style']); | 85 | $post['goods_style'] = json_encode($post['goods_style']); |
86 | } | 86 | } |
87 | if(!$cart_id = $this->model->add($this->user,$post)){ | 87 | if(!$cart_id = $this->model->add($this->user,$post)){ |
88 | - $this->error($this->model->getError() ?: '加入购物车失败'); | 88 | + $this->error($this->model->getError() ?: '加入购物车失败',null,$this->model->getCode()); |
89 | } | 89 | } |
90 | $this->success(__('加入购物车成功'),[ | 90 | $this->success(__('加入购物车成功'),[ |
91 | 'cart_id' => $cart_id, | 91 | 'cart_id' => $cart_id, |
@@ -191,6 +191,7 @@ class Cart extends Api | @@ -191,6 +191,7 @@ class Cart extends Api | ||
191 | }) | 191 | }) |
192 | */ | 192 | */ |
193 | public function editGoodsNum($cart_id,$goods_num){ | 193 | public function editGoodsNum($cart_id,$goods_num){ |
194 | + halt($cart_id); | ||
194 | $cart = $this->model->get($cart_id); | 195 | $cart = $this->model->get($cart_id); |
195 | empty($cart) && $this->error(__('购物车信息不存在')); | 196 | empty($cart) && $this->error(__('购物车信息不存在')); |
196 | $goods_num < 1 && $this->error(__('商品数量不能小于1')); | 197 | $goods_num < 1 && $this->error(__('商品数量不能小于1')); |
@@ -247,9 +247,8 @@ class Index extends Api | @@ -247,9 +247,8 @@ class Index extends Api | ||
247 | } | 247 | } |
248 | } | 248 | } |
249 | $goods['appraise'] = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],1,1); | 249 | $goods['appraise'] = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],1,1); |
250 | - $ismember = $this->user['mobile'] ? '1' : '0'; | ||
251 | // 返回结果 | 250 | // 返回结果 |
252 | - $this->success(__('成功'),compact('goods','ismember')); | 251 | + $this->success(__('成功'),compact('goods')); |
253 | } | 252 | } |
254 | 253 | ||
255 | /** | 254 | /** |
@@ -22,6 +22,9 @@ class Cart extends Model | @@ -22,6 +22,9 @@ class Cart extends Model | ||
22 | // 错误提示 | 22 | // 错误提示 |
23 | public $error = ''; | 23 | public $error = ''; |
24 | 24 | ||
25 | + // 状态码 | ||
26 | + public $code = 0; | ||
27 | + | ||
25 | /** | 28 | /** |
26 | * 商品 | 29 | * 商品 |
27 | */ | 30 | */ |
@@ -91,7 +94,7 @@ class Cart extends Model | @@ -91,7 +94,7 @@ class Cart extends Model | ||
91 | return false; | 94 | return false; |
92 | } | 95 | } |
93 | if(empty($user['mobile'])){ | 96 | if(empty($user['mobile'])){ |
94 | - $this->setError(__('抱歉,该商品只有会员才能购买')); | 97 | + $this->setError(__('抱歉,该商品只有会员才能购买'),2); |
95 | return false; | 98 | return false; |
96 | } | 99 | } |
97 | // 定制品 | 100 | // 定制品 |
@@ -369,9 +372,10 @@ class Cart extends Model | @@ -369,9 +372,10 @@ class Cart extends Model | ||
369 | * 设置错误信息 | 372 | * 设置错误信息 |
370 | * @param $error | 373 | * @param $error |
371 | */ | 374 | */ |
372 | - private function setError($error) | 375 | + private function setError($error,$code=0) |
373 | { | 376 | { |
374 | empty($this->error) && $this->error = $error; | 377 | empty($this->error) && $this->error = $error; |
378 | + $this->code = $code; | ||
375 | } | 379 | } |
376 | 380 | ||
377 | /** | 381 | /** |
@@ -391,4 +395,13 @@ class Cart extends Model | @@ -391,4 +395,13 @@ class Cart extends Model | ||
391 | { | 395 | { |
392 | return $this->error; | 396 | return $this->error; |
393 | } | 397 | } |
398 | + | ||
399 | + /** | ||
400 | + * 获取状态码 | ||
401 | + * @return string | ||
402 | + */ | ||
403 | + public function getCode() | ||
404 | + { | ||
405 | + return $this->code; | ||
406 | + } | ||
394 | } | 407 | } |
-
请 注册 或 登录 后发表评论