MainController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. $category = CategoryService::getTopThreeCategory($this->mainId);
  21. $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
  22. $sj = $this->sj->attributes;
  23. $data = [
  24. 'ad' => $ad,
  25. 'category' => $categoryList,
  26. 'columnStyle' => rand(1, 2),
  27. 'sj' => $sj
  28. ];
  29. util::success($data);
  30. }
  31. }