* Date: 2019/6/29 * Time: 14:27 */ namespace mini\controllers; use biz\goods\services\CategoryRelateService; use biz\goods\services\CategoryService; use biz\goods\services\GoodsCategoryService; use biz\goods\services\GoodsUsageService; use biz\goods\services\UsageRelationService; use common\components\util; use Yii; class CategoryController extends BaseController { //取商家分类和第一个分类的商品 shish 2019.7.3 public function actionGetCategoryList() { $menuList = CategoryRelateService::getShowList(); $firstGoodsList = []; $id = 0; if (!empty($menuList)) { $first = reset($menuList); $id = $first['id']; $type = $first['type']; if ($type == 'category') { $goodsList = GoodsCategoryService::getGoodsList($id); } elseif ($type == 'usage') { $goodsList = GoodsUsageService::getGoodsData($id); } else { util::fail('菜单类型不存在'); } $firstGoodsList = $goodsList; } $data = ['categoryList' => $menuList, 'firstGoodsList' => $firstGoodsList, 'categoryId' => $id]; util::sendJson($data); } //取分类下的商品 shish 2019.7.9 public function actionGetList() { $id = Yii::$app->request->get('id', 0); $type = Yii::$app->request->get('type', 'category'); if ($type == 'category') { $data = GoodsCategoryService::getCategoryAndList($id); $data['category']['categoryName'] = $data['category']['showName']; } elseif ($type == 'usage') { $data = GoodsUsageService::getGoodsList($id); $data['category'] = $data['info']; $data['category']['categoryName'] = $data['info']['showName']; } else { util::fail('无效类型'); } $data['vipShow'] = 1; util::sendJson($data); } }