CategorySettingController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\goods\classes\CategorySettingClass;
  4. use common\components\util;
  5. use Yii;
  6. /**
  7. * 商城客户端:分类页配置(xhCategorySetting)
  8. */
  9. class CategorySettingController extends BaseController
  10. {
  11. /** 分类页配置允许未登录读取,便于访客浏览分类菜单 */
  12. public $guestAccess = ['detail'];
  13. /**
  14. * 读取当前门店分类页配置(花材展示名、置顶、广告等)
  15. * GET /category-setting/detail
  16. * 未登录也可读:只要带 account 解析出 mainId/shopId 即可(getOrInit 只读不写库)
  17. */
  18. public function actionDetail()
  19. {
  20. // 无店铺上下文时返回默认空配置,避免游客误报登录
  21. if (empty($this->mainId) || empty($this->shopId)) {
  22. util::success([
  23. 'id' => 0,
  24. 'mainId' => intval($this->mainId),
  25. 'shopId' => intval($this->shopId),
  26. 'itemCateName' => '',
  27. 'isItemCateTop' => 0,
  28. 'isItemCateShow' => 0,
  29. 'advertisement' => '',
  30. ]);
  31. }
  32. $info = CategorySettingClass::getOrInit($this->mainId, $this->shopId);
  33. util::success($info);
  34. }
  35. }