From 838b8003f153ab5095d47273e7b4e93a05261f20 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, 19 Dec 2017 23:59:04 +0800 Subject: [PATCH] page --- app/Http/Controllers/Home/IndexController.php | 16 ++++++++++---- resources/views/home/common/footer.blade.php | 2 +- resources/views/home/common/header.blade.php | 21 ++++++++----------- resources/views/home/index/detail.blade.php | 8 +++++++ resources/views/home/index/goods.blade.php | 21 ++++++++++++++++--- .../views/home/index/goodslist.blade.php | 7 ++++--- resources/views/home/index/index.blade.php | 7 +++---- resources/views/home/index/page.blade.php | 8 +++++++ 8 files changed, 63 insertions(+), 27 deletions(-) create mode 100644 resources/views/home/index/detail.blade.php create mode 100644 resources/views/home/index/page.blade.php diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index 2758e52..c61f01c 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -30,6 +30,11 @@ class IndexController extends CommonController { $cat = $request->input('id', ''); $page = $request->input('page', ''); + + //推荐 + $tuijian = $request->input('tuijian', ''); + if($tuijian){$where['tuijian'] = $tuijian;} + $pagenow = $page; $post = ''; @@ -56,10 +61,10 @@ class IndexController extends CommonController $data['counts'] = $counts; $start = $page*$pagesize; - $posts = $goods->get(); + $posts = object_to_array($goods->skip($start)->take($pagesize)->get()); $data['posts'] = $posts; //获取列表 - $data['pagenav'] = '';if($nextpage<=$pages && $nextpage>0){$data['pagenav'] = $this->listpageurl('http://'.$_SERVER['HTTP_HOST'],$_SERVER['QUERY_STRING'],$nextpage);} + $data['pagenav'] = '';if($nextpage<=$pages && $nextpage>0){$data['pagenav'] = $this->listpageurl(route('home_goodslist'),$_SERVER['QUERY_STRING'],$nextpage);} $data['goods_type_list'] = object_to_array(DB::table('goods_type')->where(['pid'=>0,'status'=>1])->select('id','name')->take(30)->orderBy('listorder','asc')->get()); $data['id'] = $cat; @@ -92,8 +97,11 @@ class IndexController extends CommonController $res = ''; foreach(explode("&",$query_string) as $row) { - $canshu = explode("=",$row); - $res[$canshu[0]] = $canshu[1]; + if($row) + { + $canshu = explode("=",$row); + $res[$canshu[0]] = $canshu[1]; + } } if(isset($res['page'])) diff --git a/resources/views/home/common/footer.blade.php b/resources/views/home/common/footer.blade.php index 0e72ab2..96d09a0 100644 --- a/resources/views/home/common/footer.blade.php +++ b/resources/views/home/common/footer.blade.php @@ -1 +1 @@ -
\ No newline at end of file + \ No newline at end of file diff --git a/resources/views/home/common/header.blade.php b/resources/views/home/common/header.blade.php index 6ed7c25..8bead4f 100644 --- a/resources/views/home/common/header.blade.php +++ b/resources/views/home/common/header.blade.php @@ -2,12 +2,12 @@