MainController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace mall\controllers;
  3. use bizMall\ad\services\AdService;
  4. use bizMall\goods\services\CategoryService;
  5. use bizMall\goods\services\GoodsCategoryService;
  6. use common\components\util;
  7. class MainController extends BaseController
  8. {
  9. //首页 ssh 2019.12.2
  10. public function actionIndex()
  11. {
  12. $where = ['mainId' => $this->mainId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
  13. $adRespond = AdService::getAdList($where);
  14. $ad = [];
  15. if (isset($adRespond['list']) && !empty($adRespond['list'])) {
  16. foreach ($adRespond['list'] as $single) {
  17. $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
  18. }
  19. }
  20. $shop = $this->shop;
  21. $category = CategoryService::getTopThreeCategory($this->mainId);
  22. $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category, $shop) : [];
  23. $sj = isset($this->sj) ? $this->sj->attributes : [];
  24. $data = [
  25. 'ad' => $ad,
  26. 'category' => $categoryList,
  27. 'columnStyle' => rand(1, 2),
  28. 'sj' => $sj
  29. ];
  30. util::success($data);
  31. }
  32. }