diff --git a/app/Http/Controllers/Api/CartController.php b/app/Http/Controllers/Api/CartController.php index 43c869e..4da8d48 100644 --- a/app/Http/Controllers/Api/CartController.php +++ b/app/Http/Controllers/Api/CartController.php @@ -75,4 +75,19 @@ class CartController extends CommonController return ReturnData::create(ReturnData::SUCCESS,$res); } + + //购物车结算商品列表 + public function cartCheckoutGoodsList(Request $request) + { + //参数 + $data['ids'] = $request->input('ids',''); + $data['user_id'] = Token::$uid; + + if($data['ids']=='') + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + return Cart::cartCheckoutGoodsList($data); + } } \ No newline at end of file diff --git a/app/Http/Controllers/Api/UserAddressController.php b/app/Http/Controllers/Api/UserAddressController.php index 9459a93..af8177b 100644 --- a/app/Http/Controllers/Api/UserAddressController.php +++ b/app/Http/Controllers/Api/UserAddressController.php @@ -84,13 +84,7 @@ class UserAddressController extends CommonController return ReturnData::create(ReturnData::PARAMS_ERROR); } - $res = UserAddress::add($data); - if(!$res) - { - return ReturnData::create(ReturnData::SYSTEM_FAIL); - } - - return ReturnData::create(ReturnData::SUCCESS,$res); + return UserAddress::add($data); } //修改收货地址 diff --git a/app/Http/Controllers/Weixin/CartController.php b/app/Http/Controllers/Weixin/CartController.php index 2f28d0b..a22f33c 100644 --- a/app/Http/Controllers/Weixin/CartController.php +++ b/app/Http/Controllers/Weixin/CartController.php @@ -35,4 +35,17 @@ class CartController extends CommonController return view('weixin.cart.index', $data); } + //购物车结算 + public function cartCheckout($ids) + { + $postdata = array( + 'ids' => $ids, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/cart_checkout_goods_list"; + $res = curl_request($url,$postdata,'GET'); + $data['list'] = $res['data']['list']; + + return view('weixin.cart.cartCheckout', $data); + } } \ No newline at end of file diff --git a/app/Http/Model/Cart.php b/app/Http/Model/Cart.php index 9352a5f..f426c46 100644 --- a/app/Http/Model/Cart.php +++ b/app/Http/Model/Cart.php @@ -188,4 +188,38 @@ class Cart extends BaseModel { return self::where('user_id',$user_id)->sum('goods_number'); } + + //购物车结算商品列表 + public static function cartCheckoutGoodsList(array $param) + { + extract($param); + + $cartIds = explode("_",$ids); + + // 获取购物车列表 + $cartList = self::where(array('user_id'=>$user_id))->whereIn('id', $cartIds)->get(); + + if(!empty($cartList)) + { + $resultList = array(); + $checkArr = array(); + + foreach($cartList as $k=>$v) + { + $goods = Goods::where(array('id'=>$v['goods_id']))->first(); + + $cartList[$k]->is_promote = 0; + if(Goods::bargain_price($goods->price,$goods->promote_start_date,$goods->promote_end_date) > 0){$cartList[$k]->is_promote = 1;} + + $cartList[$k]->final_price = Goods::get_final_price($v['goods_id']); //商品最终价格 + $cartList[$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v['goods_id'])); + $cartList[$k]->title = $goods->title; + $cartList[$k]->litpic = $goods->litpic; + } + } + + $res['list'] = $cartList; + + return ReturnData::create(ReturnData::SUCCESS,$res); + } } \ No newline at end of file diff --git a/app/Http/Model/UserAddress.php b/app/Http/Model/UserAddress.php index ee3effd..8a969c8 100644 --- a/app/Http/Model/UserAddress.php +++ b/app/Http/Model/UserAddress.php @@ -1,5 +1,6 @@ count() >= 3) + { + return ReturnData::create(ReturnData::PARAMS_ERROR,null,'最多10个收货地址'); + } + $model = new UserAddress; $model->user_id = $user_id; $model->name = $name; @@ -119,10 +125,10 @@ class UserAddress extends BaseModel self::setDefault($model->id,$user_id); } - return $model->toArray(); + return ReturnData::create(ReturnData::SUCCESS,$model); } - return false; + return ReturnData::create(ReturnData::SYSTEM_FAIL); } public static function modify(array $param) diff --git a/resources/views/weixin/address/userAddressAdd.blade.php b/resources/views/weixin/address/userAddressAdd.blade.php index fba6aa3..fcbc718 100644 --- a/resources/views/weixin/address/userAddressAdd.blade.php +++ b/resources/views/weixin/address/userAddressAdd.blade.php @@ -260,8 +260,7 @@ function adr_dosubmit() ,time: 2 //2秒后自动关闭 }); - var url = "http://www.baidu.com"; - location.href = url; + location.href = ""; } },'json'); } diff --git a/resources/views/weixin/cart/cartCheckout.blade.php b/resources/views/weixin/cart/cartCheckout.blade.php new file mode 100644 index 0000000..9e2bf71 --- /dev/null +++ b/resources/views/weixin/cart/cartCheckout.blade.php @@ -0,0 +1,266 @@ +
+购物车暂无商品
+ 去逛逛 +