From f7202fcf6359202ca816d089256e72b83c53a599 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9E=97=E4=B8=80=E5=B3=B0?= <1feng.0595@gmail.com>
Date: Tue, 31 Oct 2017 00:36:52 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E8=B4=AD=E4=B9=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Http/Controllers/Api/CartController.php | 8 +------
app/Http/Model/Cart.php | 13 ++++++----
resources/views/weixin/cart/index.blade.php | 24 ++++++++++++++++++-
.../views/weixin/goods/goodsDetail.blade.php | 11 +++++----
routes/web.php | 1 +
5 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/app/Http/Controllers/Api/CartController.php b/app/Http/Controllers/Api/CartController.php
index 6e86eb2..43c869e 100644
--- a/app/Http/Controllers/Api/CartController.php
+++ b/app/Http/Controllers/Api/CartController.php
@@ -42,13 +42,7 @@ class CartController extends CommonController
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
- $res = Cart::cartAdd($data);
- if($res !== true)
- {
- return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
- }
-
- return ReturnData::create(ReturnData::SUCCESS);
+ return Cart::cartAdd($data);
}
//删除购物车
diff --git a/app/Http/Model/Cart.php b/app/Http/Model/Cart.php
index e596bec..9352a5f 100644
--- a/app/Http/Model/Cart.php
+++ b/app/Http/Model/Cart.php
@@ -1,5 +1,6 @@
$user_id])->count() >= 20)
{
- return '购物车商品最多20件';
+ return ReturnData::create(ReturnData::PARAMS_ERROR,null,'购物车商品最多20件');
}
//查看是否已经有购物车插入记录
@@ -151,6 +152,8 @@ class Cart extends BaseModel
);
self::where(array('id'=>$cart->id))->update($updateArr);
+
+ $cart_id = $cart->id;
}
else
{
@@ -162,10 +165,10 @@ class Cart extends BaseModel
'add_time' => time(),
);
- self::insertGetId($cartInsert);
+ $cart_id = self::insertGetId($cartInsert);
}
- return true;
+ return ReturnData::create(ReturnData::SUCCESS,$cart_id,'购物车添加成功');
}
/**
diff --git a/resources/views/weixin/cart/index.blade.php b/resources/views/weixin/cart/index.blade.php
index 9720568..2b1ccdb 100644
--- a/resources/views/weixin/cart/index.blade.php
+++ b/resources/views/weixin/cart/index.blade.php
@@ -31,7 +31,7 @@
-
+
@@ -117,6 +117,28 @@