作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

1

@@ -61,7 +61,10 @@ class Cart extends Api @@ -61,7 +61,10 @@ class Cart extends Api
61 public function add() 61 public function add()
62 { 62 {
63 $post = $this->request->post(); 63 $post = $this->request->post();
64 - halt($post); 64 + // 对象转json字符串
  65 + if(!empty($post['goods_style']) && is_array($post['goods_style'])){
  66 + $post['body_info'] = json_encode($post['goods_style']);
  67 + }
65 if(!$cart_id = $this->model->add($this->user,$post)){ 68 if(!$cart_id = $this->model->add($this->user,$post)){
66 $this->error($this->model->getError() ?: '加入购物车失败'); 69 $this->error($this->model->getError() ?: '加入购物车失败');
67 } 70 }
@@ -41,6 +41,7 @@ class UserSize extends Model @@ -41,6 +41,7 @@ class UserSize extends Model
41 if($data['isdefault'] == '1'){ 41 if($data['isdefault'] == '1'){
42 $this->where('user_id',$user['id'])->update(['isdefault'=>'0']); 42 $this->where('user_id',$user['id'])->update(['isdefault'=>'0']);
43 } 43 }
  44 + // 对象转json字符串
44 if(!empty($data['body_info']) && is_array($data['body_info'])){ 45 if(!empty($data['body_info']) && is_array($data['body_info'])){
45 $data['body_info'] = json_encode($data['body_info']); 46 $data['body_info'] = json_encode($data['body_info']);
46 } 47 }
@@ -62,6 +63,7 @@ class UserSize extends Model @@ -62,6 +63,7 @@ class UserSize extends Model
62 if($data['isdefault'] == '1'){ 63 if($data['isdefault'] == '1'){
63 $this->where('user_id',$this['user_id'])->update(['isdefault'=>'0']); 64 $this->where('user_id',$this['user_id'])->update(['isdefault'=>'0']);
64 } 65 }
  66 + // 对象转json字符串
65 if(!empty($data['body_info']) && is_array($data['body_info'])){ 67 if(!empty($data['body_info']) && is_array($data['body_info'])){
66 $data['body_info'] = json_encode($data['body_info']); 68 $data['body_info'] = json_encode($data['body_info']);
67 } 69 }