diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php index 89b5224..be8ef8c 100644 --- a/app/Http/Controllers/Api/ArticleController.php +++ b/app/Http/Controllers/Api/ArticleController.php @@ -54,6 +54,8 @@ class ArticleController extends CommonController $res->pubdate = date('Y-m-d H:i',$res->pubdate); $res->addtime = date('Y-m-d H:i',$res->addtime); + \DB::table('article')->where(array('id'=>$data['id']))->increment('click', 1); + return ReturnData::create(ReturnData::SUCCESS,$res); } } \ No newline at end of file diff --git a/app/Http/Controllers/Api/GoodsController.php b/app/Http/Controllers/Api/GoodsController.php index e877c2a..601deda 100644 --- a/app/Http/Controllers/Api/GoodsController.php +++ b/app/Http/Controllers/Api/GoodsController.php @@ -18,10 +18,14 @@ class GoodsController extends CommonController { //参数 $data['id'] = $request->input('id',''); + $user_id = $request->input('user_id',''); if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);} $res = Goods::goodsDetail($data); + if($user_id){$res->is_collect = \DB::table('collect_goods')->where(array('user_id'=>$user_id,'goods_id'=>$data['id']))->count();} + \DB::table('goods')->where(array('id'=>$data['id']))->increment('click', 1); + return ReturnData::create(ReturnData::SUCCESS,$res); } diff --git a/app/Http/Controllers/Weixin/CartController.php b/app/Http/Controllers/Weixin/CartController.php index 9c1d0f4..2f28d0b 100644 --- a/app/Http/Controllers/Weixin/CartController.php +++ b/app/Http/Controllers/Weixin/CartController.php @@ -14,23 +14,23 @@ class CartController extends CommonController //商品列表 public function index(Request $request) { - if($request->input('typeid', '') != ''){$data['typeid'] = $request->input('typeid');} - if($request->input('tuijian', '') != ''){$data['tuijian'] = $request->input('tuijian');} - if($request->input('keyword', '') != ''){$data['keyword'] = $request->input('keyword');} - if($request->input('status', '') != ''){$data['status'] = $request->input('status');} - if($request->input('is_promote', '') != ''){$data['is_promote'] = $request->input('is_promote');} - if($request->input('orderby', '') != ''){$data['orderby'] = $request->input('orderby');} - if($request->input('max_price', '') != ''){$data['max_price'] = $request->input('max_price');}else{$data['max_price'] = 99999;} - if($request->input('min_price', '') != ''){$data['min_price'] = $request->input('min_price');}else{$data['min_price'] = 0;} + //购物车列表 + $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' => 10, + 'limit' => 4, + 'orderby'=> 1, 'offset' => 0 ); $url = env('APP_API_URL')."/goods_list"; - $goods_list = curl_request($url,$postdata,'GET'); - $data['goods_list'] = $goods_list['data']['list']; + $res = curl_request($url,$postdata,'GET'); + $data['like_goods_list'] = $res['data']['list']; return view('weixin.cart.index', $data); } diff --git a/app/Http/Controllers/Weixin/GoodsController.php b/app/Http/Controllers/Weixin/GoodsController.php index 347192f..489aaf6 100644 --- a/app/Http/Controllers/Weixin/GoodsController.php +++ b/app/Http/Controllers/Weixin/GoodsController.php @@ -15,16 +15,26 @@ class GoodsController extends CommonController //商品详情 public function goodsDetail($id) { - //商品列表 $postdata = array( 'id' => $id ); + if(isset($_SESSION['weixin_user_info'])){$postdata['user_id']=$_SESSION['weixin_user_info']['id'];} $url = env('APP_API_URL')."/goods_detail"; $res = curl_request($url,$postdata,'GET'); $data['post'] = $res['data']; - if(!$data['post']){$this->error_jump(ReturnCode::NO_FOUND,route('weixin'),3);} + //添加浏览记录 + if(isset($_SESSION['weixin_user_info'])) + { + $postdata = array( + 'goods_id' => $id, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/user_goods_history_add"; + curl_request($url,$postdata,'POST'); + } + return view('weixin.goods.goodsDetail', $data); } diff --git a/app/Http/Model/Cart.php b/app/Http/Model/Cart.php index 062c717..e596bec 100644 --- a/app/Http/Model/Cart.php +++ b/app/Http/Model/Cart.php @@ -26,31 +26,40 @@ class Cart extends BaseModel { extract($param); //参数:limit,offset - $goods = self::join('goods', 'goods.id', '=', 'cart.goods_id') + $model = self::join('goods', 'goods.id', '=', 'cart.goods_id') ->where('cart.user_id', $user_id) ->where('goods.status', Goods::STATUS) - ->select('cart.*','goods.id as goods_id','goods.title','goods.sn','goods.price as goods_price','goods.market_price','goods.litpic as goods_thumb_img','goods.goods_number as stock','goods.promote_start_date','goods.promote_price','goods.promote_end_date') - ->get(); + ->select('cart.*','goods.id as goods_id','goods.title','goods.sn','goods.price as goods_price','goods.market_price','goods.litpic','goods.goods_number as stock','goods.promote_start_date','goods.promote_price','goods.promote_end_date'); + + $res['count'] = $model->count(); + $res['list'] = array(); - if($goods) + if($res['count']>0) { - foreach ($goods as $k => $v) + $res['list'] = $model->get(); + + foreach ($res['list'] as $k => $v) { - $goods[$k]->is_promote = 0; - if(Goods::bargain_price($v->goods_price,$v->promote_start_date,$v->promote_end_date) > 0){$goods[$k]->is_promote = 1;} + $res['list'][$k]->is_promote = 0; + if(Goods::bargain_price($v->goods_price,$v->promote_start_date,$v->promote_end_date) > 0){$res['list'][$k]->is_promote = 1;} //订货数量大于0 if ($v->goods_number > 0) { - $goods[$k]->final_price = Goods::get_final_price($v->goods_id); //商品最终价格 - + $res['list'][$k]->final_price = Goods::get_final_price($v->goods_id); //商品最终价格 + $res['list'][$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v->goods_id)); + //更新购物车中的商品数量 //self::where('id', $v->id)->update(array('price' => $goods_price)); } } } + else + { + return false; + } - return $goods; + return $res; } public static function getOne($where) @@ -83,7 +92,8 @@ class Cart extends BaseModel //删除一条记录 public static function remove($id,$user_id) { - if (self::whereIn('id', explode(',', $id))->where('user_id',$user_id)->delete() === false) + if(!is_array($id)){$id = explode(',', $id);} + if (self::whereIn('id', $id)->where('user_id',$user_id)->delete() === false) { return false; } diff --git a/app/Http/Model/UserGoodsHistory.php b/app/Http/Model/UserGoodsHistory.php index 36f6004..968efca 100644 --- a/app/Http/Model/UserGoodsHistory.php +++ b/app/Http/Model/UserGoodsHistory.php @@ -66,6 +66,8 @@ class UserGoodsHistory extends BaseModel public static function add(array $data) { + if(self::where($data)->first()){return false;} + if (!self::where($data)->first()) { $data['add_time'] = time(); diff --git a/public/css/weixin/style.css b/public/css/weixin/style.css index 2e33840..75e0ed2 100644 --- a/public/css/weixin/style.css +++ b/public/css/weixin/style.css @@ -292,29 +292,10 @@ margin:5px 0 .banner_headline .tit{border-top:1px dashed #dedede;text-align:center;margin:25px 0;} .banner_headline .tit h4{color:#666666;background-color:#f1f1f1;font-size:18px;font-weight:normal;position:relative;top:-12px;display:inline;padding:0 20px;} -.radio .che span { - margin-left: .21333rem; - vertical-align: sub -} - -.radio .check_t i { - background-position: -.768rem 0 -} +.radio .check_t i {background-position: -30px 0} -.radio i { - width:22px; - height:22px; - display: block; - float: left; - background-image: url("../../images/weixin/check.png"); - background-repeat: no-repeat; - background-size: cover; - background-position: 0 -} -.signup-find span,.radio span { - font-size:24px; - cursor: pointer -} +.radio i {width:22px;height:22px;display: block;float: left;background-image: url("../../images/weixin/check.png");background-repeat: no-repeat;background-size: cover;background-position: 0} +.signup-find span,.radio span {font-size:24px;cursor: pointer} .sc_list { padding:10px; @@ -886,7 +867,7 @@ color: #666; border-left: 3px solid #FF0036;border-bottom: 1px solid #f4f4f4;} .goods-content .module-content{padding:10px;} -.bottom_tool_black{ width:100%; display:block; position:fixed; bottom:0;background-color:#fff;border-top:1px solid #f1f1f1;} +.bottom_tool_black{ width:100%; display:block; position:fixed; bottom:0;background-color:#fff;border-top:1px solid #f1f1f1;z-index:2;} .bottom_tool_white { width:40%; float:left;} .bottom_tool_white li { width:50%; float:left; text-align:center; position:relative;} .bottom_tool_white ul li img{ margin:0 auto; display:block; margin-top:2px; width:32px; height:32px;} diff --git a/resources/views/weixin/cart/index.blade.php b/resources/views/weixin/cart/index.blade.php index 9dc4333..9720568 100644 --- a/resources/views/weixin/cart/index.blade.php +++ b/resources/views/weixin/cart/index.blade.php @@ -24,93 +24,49 @@
-
+ $v){ ?> +
-

重庆电信手机卡电话卡语音卡选靓号3G4G卡内部5折卡低资费(飞)

+

- +
-

合约套餐:乐享4G套餐59元

+

- 54.28 +

- - - - - - + -
-
-
-
- - -
-
-
- - - - - - -
- -
-
-
- -

重庆电信手机卡电话卡语音卡选靓号3G4G卡内部5折卡低资费(飞)

- - -
- -

合约套餐:乐享4G套餐59元

-
-

- - 54.28 -

- -
- - - - - - + + - + + +
+ +
@@ -124,25 +80,20 @@ 去结算
-

总计:919.08

+

总计:0

-
+

购物车暂无商品

- 去逛逛 + 去逛逛


@@ -155,15 +106,139 @@
+ +

+ + \ No newline at end of file diff --git a/resources/views/weixin/goods/goodsDetail.blade.php b/resources/views/weixin/goods/goodsDetail.blade.php index a79eba0..b6624b3 100644 --- a/resources/views/weixin/goods/goodsDetail.blade.php +++ b/resources/views/weixin/goods/goodsDetail.blade.php @@ -58,11 +58,11 @@ var swiper = new Swiper('.swiper-container', {
- 收藏

+ 收藏

- ¥ +
门店有售 @@ -222,6 +222,31 @@ function dosubmit() $("#master").hide(); } + +function collect_goods() +{ + var url = '=1){echo env('APP_API_URL').'/collect_goods_delete';}else{echo env('APP_API_URL').'/collect_goods_add';} ?>'; + var access_token = ''; + var goods_id = $("#id").val(); + + $.post(url,{access_token:access_token,goods_id:goods_id},function(res) + { + if(res.code==0) + { + window.location.reload(); + } + else + { + + } + + layer.open({ + content: res.msg + ,skin: 'msg' + ,time: 2 //2秒后自动关闭 + }); + },'json'); +} diff --git a/resources/views/weixin/index/index.blade.php b/resources/views/weixin/index/index.blade.php index 01f93d3..393ef51 100644 --- a/resources/views/weixin/index/index.blade.php +++ b/resources/views/weixin/index/index.blade.php @@ -108,11 +108,11 @@ var swiper = new Swiper('.swiper-nav', { 我的订单 我的订单 - + 购物车 购物车 - + 个人中心 个人中心 diff --git a/routes/web.php b/routes/web.php index 45bb6eb..9ac32a2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -145,6 +145,7 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web Route::get('/user_goods_history_list', 'UserGoodsHistoryController@userGoodsHistoryList'); //我的足迹列表 Route::post('/user_goods_history_delete', 'UserGoodsHistoryController@userGoodsHistoryDelete'); //我的足迹删除一条 Route::post('/user_goods_history_clear', 'UserGoodsHistoryController@userGoodsHistoryClear'); //我的足迹清空 + Route::post('/user_goods_history_add', 'UserGoodsHistoryController@userGoodsHistoryAdd'); //我的足迹添加 //商品评价 Route::get('/goods_comment_list', 'CommentController@goodsCommentList'); //商品评价列表