where('goods_id',$id) ->find(); if(!$res){ return $this->Error('錯誤請求'); } $res['goods_img'] = getUrl().'/'.$res['goods_img']; $res['original_img'] = getUrl().'/'.$res['original_img']; // 商品圖片 $goods_gallery=Db::name('goods_gallery') ->where('goods_id',$id) ->select(); foreach($goods_gallery as $key => $val){ $res['goods_gallery'][$key]['img_url'] = getUrl()."/".$val['img_url']; } //更新產品點擊數 Db::name('goods')->where('goods_id',$id)->inc('click_count')->update(); // return $this->Success($ads); return $this->Success($res); } public function getGoodsByCate(){ $cat_id = input('cat_id'); $result = Db::name('goods') ->where('cat_id',$cat_id) ->where('goods_id','>',1) ->select() ->toArray(); foreach($result as $key => $val){ $result[$key]['goods_thumb'] = getUrl().'/'.$val['goods_thumb']; } return $this->Success($result); } public function getCategory(){ $result = Db::name('category') ->where('is_show',1) ->select(); return $this->Success($result); } }