From 6389fa8a39fdcd686638ede5b27927dcae0f23ff Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Wed, 15 Aug 2018 17:49:56 +0800 Subject: [PATCH] goods_img --- app/Http/Controllers/Api/GoodsController.php | 2 +- app/Http/Controllers/Home/IndexController.php | 16 ++---- app/Http/Logic/GoodsLogic.php | 1 + resources/views/home/index/goods.blade.php | 53 ++++++++++++++----- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/Api/GoodsController.php b/app/Http/Controllers/Api/GoodsController.php index c7931bf..1646d8b 100644 --- a/app/Http/Controllers/Api/GoodsController.php +++ b/app/Http/Controllers/Api/GoodsController.php @@ -75,7 +75,7 @@ class GoodsController extends CommonController } //排序 - $orderby = ''; + $orderby = ['id','desc']; if($request->input('orderby', null) != null) { switch ($request->input('orderby')) diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index 46c81b6..f81bc41 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -157,19 +157,13 @@ class IndexController extends CommonController { if(empty($id) || !preg_match('/[0-9]+/',$id)){return redirect()->route('page404');} - $post = object_to_array(DB::table('goods')->where(['id'=>$id,'status'=>0])->first(), 1);if(empty($post)){return redirect()->route('page404');}$post['type_name'] = DB::table('goods_type')->where('id', $post['typeid'])->value('name'); - if($post) - { - $data['post'] = $post; - } - else - { - return redirect()->route('page404'); - } + $where['id'] = $id; + $where['status'] = 0; + $data['post'] = logic('Goods')->getOne($where); + if(!$data['post']){return redirect()->route('page404');} - $data['tj_list'] = object_to_array(DB::table('goods')->where(['tuijian'=>1,'status'=>0])->get()); + $data['tj_list'] = DB::table('goods')->where(['tuijian'=>1,'status'=>0])->orderBy('id', 'desc')->get(); - DB::table('goods')->where(array('id'=>$id))->increment('click', 1); return view('home.index.goods', $data); } diff --git a/app/Http/Logic/GoodsLogic.php b/app/Http/Logic/GoodsLogic.php index 66c3fda..50dc05a 100644 --- a/app/Http/Logic/GoodsLogic.php +++ b/app/Http/Logic/GoodsLogic.php @@ -92,6 +92,7 @@ class GoodsLogic extends BaseLogic $res->is_promote_goods = $this->getModel()->bargain_price($res->promote_price,$res->promote_start_date,$res->promote_end_date); //is_promote_goods等于0,说明不是促销商品 $res->goods_detail_url = route('weixin_goods_detail',array('id'=>$res->id)); $res->goods_img_list = model('GoodsImg')->getDb()->where(['goods_id'=>$res->id])->get(); + $res->type_name = model('GoodsType')->getDb()->where(['id'=>$res->typeid])->value('name'); //商品评论数 $where2['comment_type'] = Comment::GOODS_COMMENT_TYPE; diff --git a/resources/views/home/index/goods.blade.php b/resources/views/home/index/goods.blade.php index b7c1f77..64d6941 100644 --- a/resources/views/home/index/goods.blade.php +++ b/resources/views/home/index/goods.blade.php @@ -1,5 +1,5 @@
-