You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.9 KiB
92 lines
2.9 KiB
<?php
|
|
namespace App\Http\Controllers\Weixin;
|
|
|
|
use App\Http\Controllers\Weixin\CommonController;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CartController extends CommonController
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
//商品列表
|
|
public function index(Request $request)
|
|
{
|
|
//购物车列表
|
|
$postdata = array(
|
|
'access_token' => $_SESSION['weixin_user_info']['access_token']
|
|
);
|
|
$url = env('APP_API_URL')."/cart_list";
|
|
$res = curl_request($url,$postdata,'GET');
|
|
$data['list'] = $res['data']['list'];
|
|
|
|
//猜你喜欢商品列表
|
|
$postdata = array(
|
|
'limit' => 4,
|
|
'orderby'=> 1,
|
|
'offset' => 0
|
|
);
|
|
$url = env('APP_API_URL')."/goods_list";
|
|
$res = curl_request($url,$postdata,'GET');
|
|
$data['like_goods_list'] = $res['data']['list'];
|
|
|
|
return view('weixin.cart.index', $data);
|
|
}
|
|
|
|
//购物车结算
|
|
public function cartCheckout($ids)
|
|
{
|
|
//支付方式列表
|
|
$postdata = array(
|
|
'status' => 1,
|
|
'access_token' => $_SESSION['weixin_user_info']['access_token']
|
|
);
|
|
$url = env('APP_API_URL')."/payment_list";
|
|
$res = curl_request($url,$postdata,'GET');
|
|
$data['payment_list'] = $res['data']['list'];
|
|
|
|
//用户默认收货地址
|
|
$postdata = array(
|
|
'access_token' => $_SESSION['weixin_user_info']['access_token']
|
|
);
|
|
$url = env('APP_API_URL')."/user_default_address";
|
|
$res = curl_request($url,$postdata,'GET');
|
|
$data['user_default_address'] = $res['data'];
|
|
|
|
//收货地址列表
|
|
$postdata = array(
|
|
'limit' => 100,
|
|
'access_token' => $_SESSION['weixin_user_info']['access_token']
|
|
);
|
|
$url = env('APP_API_URL')."/user_address_list";
|
|
$res = curl_request($url,$postdata,'GET');
|
|
$data['address_list'] = $res['data']['list'];
|
|
$data['cartids'] = $ids;
|
|
|
|
//获取会员信息
|
|
$postdata = array(
|
|
'access_token' => $_SESSION['weixin_user_info']['access_token']
|
|
);
|
|
$url = env('APP_API_URL')."/user_info";
|
|
$res = curl_request($url,$postdata,'GET');
|
|
$data['user_info'] = $res['data'];
|
|
|
|
//购物车结算商品列表
|
|
$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['checkout_goods'] = $res['data'];
|
|
|
|
//判断余额是否足够
|
|
$is_balance_enough = 1; //足够
|
|
if($data['checkout_goods']['total_price']>$data['user_info']['money']){$is_balance_enough = 0;}
|
|
$data['is_balance_enough'] = $is_balance_enough;
|
|
|
|
return view('weixin.cart.cartCheckout', $data);
|
|
}
|
|
}
|