更新若干功能
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\business\CatalogueModel;
|
||||
use App\Models\business\CategoryModel;
|
||||
use App\Models\business\ImageModel;
|
||||
use App\Service\business\PriceService;
|
||||
use App\Service\common\MediaUrlService;
|
||||
|
||||
/**
|
||||
* 小程序商品列表与详情
|
||||
@@ -16,6 +17,8 @@ use App\Service\business\PriceService;
|
||||
*/
|
||||
class WxProductService extends BaseWxService
|
||||
{
|
||||
protected bool $needLogin = false;
|
||||
|
||||
/**
|
||||
* 商品列表:分类点到二级时按父分类下的所有子分类查
|
||||
*/
|
||||
@@ -76,12 +79,15 @@ class WxProductService extends BaseWxService
|
||||
$this->utils->errorThrow('商品不存在');
|
||||
}
|
||||
$info = $info->toArray();
|
||||
$media = MediaUrlService::getInstance();
|
||||
$info['cover'] = $media->toPublic($info['cover'] ?? '');
|
||||
$info['video'] = $media->toPublic($info['video'] ?? '');
|
||||
|
||||
// 渲染图作为详情轮播
|
||||
$info['carousel'] = [];
|
||||
foreach ($info['images'] ?? [] as $image) {
|
||||
if ((int) $image['type'] === ImageModel::TYPE_RENDER) {
|
||||
$info['carousel'][] = $image['url'];
|
||||
$info['carousel'][] = $media->toPublic($image['url'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +95,9 @@ class WxProductService extends BaseWxService
|
||||
$applied = PriceService::getInstance()->applyToRows($info['price_sheet'] ?? [], $showPrice, $this->priceMultiplier());
|
||||
$info['price_sheet'] = $applied['rows'];
|
||||
$info['is_show_price'] = $applied['is_show_price'];
|
||||
$info['favorited'] = $this->userId > 0
|
||||
? WxFavoriteService::getInstance()->isFavorited((int) $id)
|
||||
: false;
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user