作者 李忠强

更新

... ... @@ -17,7 +17,7 @@ use think\Db;
*/
class Classification extends Api
{
protected $noNeedLogin = ['sort'];
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
... ... @@ -96,13 +96,17 @@ class Classification extends Api
->field('goods_id,goods_name,image')
->paginate(10,false,['page'=>$page])
->each(function ($item,$key){
if ($this->auth->isLogin()){
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
}else{
$item['cart_number'] = 0;
}
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id',$item['goods_id'])
->find();
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
});
... ... @@ -111,13 +115,17 @@ class Classification extends Api
->field('goods_id,goods_name,image')
->paginate(10,false,['page'=>$page])
->each(function ($item,$key){
if ($this->auth->isLogin()){
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
}else{
$item['cart_number'] = 0;
}
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id',$item['goods_id'])
->find();
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
});
... ...