BookController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace ghs\controllers;
  3. use common\components\book;
  4. use common\components\util;
  5. use Yii;
  6. class BookController extends BaseController
  7. {
  8. public $guestAccess = ['list', 'detail'];
  9. //教程列表 shish 20211206
  10. public function actionList()
  11. {
  12. $list = book::$list;
  13. util::success(['list' => $list]);
  14. }
  15. //手册详情页 shish 20211206
  16. public function actionDetail()
  17. {
  18. $id = Yii::$app->request->get('id');
  19. $data = book::$data;
  20. $bookTitleList = book::$list;
  21. //取出title
  22. $titleData = [];
  23. foreach ($bookTitleList as $bookList) {
  24. foreach ($bookList['list'] as $item) {
  25. $currentId = $item['id'] ?? '';
  26. $title = $item['title'] ?? '';
  27. $titleData[$currentId] = $title;
  28. }
  29. }
  30. $currentTitle = $titleData[$id] ?? '';
  31. $info = $data[$id] ?? [];
  32. array_unshift($info, ['style' => 'title', 'value' => $currentTitle]);
  33. util::success(['list' => $info]);
  34. }
  35. //关闭手册 shish 20211211
  36. public function actionCloseBook()
  37. {
  38. $cacheKey = 'close_book_' . $this->shopAdminId;
  39. Yii::$app->redis->executeCommand('SET', [$cacheKey, 'has']);
  40. util::complete();
  41. }
  42. }