|  | @@ -9,13 +9,14 @@ use addons\unishop\model\Favorite;
 | 
	
		
			
				|  |  |  use addons\unishop\model\Product as productModel;
 | 
	
		
			
				|  |  |  use addons\unishop\model\Coupon;
 | 
	
		
			
				|  |  |  use think\Exception;
 | 
	
		
			
				|  |  | +use think\Db;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 商品
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  class Product extends Base
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -    protected $noNeedLogin = ['detail', 'lists'];
 | 
	
		
			
				|  |  | +    protected $noNeedLogin = ['detail', 'lists','index_sifang'];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * @ApiTitle    (产品详情)
 | 
	
	
		
			
				|  | @@ -49,7 +50,7 @@ class Product extends Base
 | 
	
		
			
				|  |  |      public function detail()
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          $productId = $this->request->get('id');
 | 
	
		
			
				|  |  | -        $productId = \addons\unishop\extend\Hashids::decodeHex($productId);
 | 
	
		
			
				|  |  | +//        $productId = \addons\unishop\extend\Hashids::decodeHex($productId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -134,24 +135,17 @@ class Product extends Base
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public function lists()
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        $page = $this->request->get('page', 1);
 | 
	
		
			
				|  |  | -        $pagesize = $this->request->get('pagesize', 20);
 | 
	
		
			
				|  |  | -        $by = $this->request->get('by', 'weigh');
 | 
	
		
			
				|  |  | -        $desc = $this->request->get('desc', 'desc');
 | 
	
		
			
				|  |  | +        $page = $this->request->request('page', 1);
 | 
	
		
			
				|  |  | +        $pagesize = $this->request->request('listrow', 10);
 | 
	
		
			
				|  |  | +        $by = $this->request->request('by', 'weigh');
 | 
	
		
			
				|  |  | +        $desc = $this->request->request('desc', 'desc');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        $sid = $this->request->get('sid'); // 二级分类Id
 | 
	
		
			
				|  |  | -        $fid = $this->request->get('fid'); // 一级分类Id
 | 
	
		
			
				|  |  | +        $cate_id = $this->request->request('cate_id',0,'intval');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          $productModel = new productModel();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if ($fid && !$sid) {
 | 
	
		
			
				|  |  | -            $categoryModel = new \addons\unishop\model\Category();
 | 
	
		
			
				|  |  | -            $sArr = $categoryModel->where('pid', $fid)->field('id')->select();
 | 
	
		
			
				|  |  | -            $sArr = array_column($sArr, 'id');
 | 
	
		
			
				|  |  | -            array_push($sArr, $fid);
 | 
	
		
			
				|  |  | -            $productModel->where('category_id', 'in', $sArr);
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            $sid && $productModel->where(['category_id' => $sid]);
 | 
	
		
			
				|  |  | +        if($cate_id != 0){
 | 
	
		
			
				|  |  | +            $productModel->where(['cate_id' => $cate_id]);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          $result = $productModel
 | 
	
	
		
			
				|  | @@ -169,6 +163,28 @@ class Product extends Base
 | 
	
		
			
				|  |  |          $this->success('', $result);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    //首页商品四方列表
 | 
	
		
			
				|  |  | +    public function index_sifang(){
 | 
	
		
			
				|  |  | +        //四个标签的商品
 | 
	
		
			
				|  |  | +        $tag1 = Db::name('unishop_product')->field('id,image')->where('find_in_set(:tag_ids,tag_ids)', ['tag_ids' => 1])->where(['switch' => productModel::SWITCH_ON])->limit(2)->order('weigh desc,id desc')->select();
 | 
	
		
			
				|  |  | +        $tag2 = Db::name('unishop_product')->field('id,image')->where('find_in_set(:tag_ids,tag_ids)', ['tag_ids' => 2])->where(['switch' => productModel::SWITCH_ON])->limit(2)->order('weigh desc,id desc')->select();
 | 
	
		
			
				|  |  | +        $tag3 = Db::name('unishop_product')->field('id,image')->where('find_in_set(:tag_ids,tag_ids)', ['tag_ids' => 3])->where(['switch' => productModel::SWITCH_ON])->limit(2)->order('weigh desc,id desc')->select();
 | 
	
		
			
				|  |  | +        $tag4 = Db::name('unishop_product')->field('id,image')->where('find_in_set(:tag_ids,tag_ids)', ['tag_ids' => 4])->where(['switch' => productModel::SWITCH_ON])->limit(2)->order('weigh desc,id desc')->select();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $result = [
 | 
	
		
			
				|  |  | +            'tuijian' => list_domain_image($tag1,['image']),
 | 
	
		
			
				|  |  | +            'remen'   => list_domain_image($tag2,['image']),
 | 
	
		
			
				|  |  | +            'shoufa'  => list_domain_image($tag3,['image']),
 | 
	
		
			
				|  |  | +            'cuxiao'  => list_domain_image($tag4,['image']),
 | 
	
		
			
				|  |  | +        ];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $this->success(1,$result);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * @ApiTitle (收藏/取消)
 | 
	
		
			
				|  |  |       * @ApiSummary (收藏/取消)
 |