You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
62 lines
1.5 KiB
<?php
|
|
namespace app\appapi\controller\v1;
|
|
|
|
use app\appapi\ApiController;
|
|
use think\facade\Db;
|
|
|
|
class Goods extends ApiController
|
|
{
|
|
public function getGoods(){
|
|
$id = input('id');
|
|
|
|
$res=Db::name('goods')
|
|
->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);
|
|
}
|
|
}
|