MainController.php 935 B

1234567891011121314151617181920212223242526272829303132
  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 Yii;
  7. use yii\web\Controller;
  8. use common\components\util;
  9. class MainController extends BaseController
  10. {
  11. //首页 shish 2019.12.2
  12. public function actionIndex()
  13. {
  14. $where = ['merchantId' => $this->sjId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
  15. $adRespond = AdService::getAdList($where);
  16. $ad = [];
  17. if (isset($adRespond['list']) && !empty($adRespond['list'])) {
  18. foreach ($adRespond['list'] as $single) {
  19. $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
  20. }
  21. }
  22. $category = CategoryService::getTopThreeCategory($this->sjId);
  23. $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
  24. $data = ['ad' => $ad, 'category' => $categoryList, 'columnStyle' => rand(1, 2)];
  25. util::success($data);
  26. }
  27. }