ArticleController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace mobile\controllers;
  3. use common\services\xhCategoryService;
  4. use common\services\xhArticleCategoryService;
  5. use common\services\xhArticleService;
  6. use Yii;
  7. use yii\web\Controller;
  8. use yii\filters\AccessControl;
  9. use yii\helpers\Json;
  10. use common\components\weixinUtil;
  11. use common\components\stringUtil;
  12. use common\components\configDict;
  13. use common\components\util;
  14. class ArticleController extends MobileendController
  15. {
  16. public $withoutLogin = ['article','article-list'];
  17. public function actionArticleList()
  18. {
  19. $this->layout = 'goodsMain';
  20. $get = Yii::$app->request->get();
  21. $id = isset($get['id']) ? $get['id'] : 0;
  22. $category = xhCategoryService::getById($id);
  23. $categoryName = $category['categoryName'];
  24. $merchantId = $category['merchantId'];
  25. $relation = xhArticleCategoryService::getAllByCondition(['merchantId' =>$merchantId,'cId' => $id]);
  26. $this->webTitle = $categoryName;//标题
  27. return $this->render('articleList',['category' => $category,'relation' => $relation]);
  28. }
  29. public function actionArticleDetail()
  30. {
  31. $this->layout = 'goodsMain';
  32. $get = Yii::$app->request->get();
  33. $id = isset($get['id']) ? $get['id'] : 0;
  34. $article = xhArticleService::getById($id);
  35. if(isset($get['cId'])){
  36. $category = xhCategoryService::getById($get['cId']);
  37. $categoryName = $category['categoryName'];
  38. $this->webTitle = $categoryName;
  39. }
  40. $this->webTitle = $article['title'];
  41. return $this->render('articleDetail',array('article' => $article));
  42. }
  43. }