| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace ghs\controllers;
- use common\components\book;
- use common\components\util;
- use Yii;
- class BookController extends BaseController
- {
- public $guestAccess = ['list', 'detail'];
- //教程列表 shish 20211206
- public function actionList()
- {
- $list = book::$list;
- util::success(['list' => $list]);
- }
- //手册详情页 shish 20211206
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $data = book::$data;
- $bookTitleList = book::$list;
- //取出title
- $titleData = [];
- foreach ($bookTitleList as $bookList) {
- foreach ($bookList['list'] as $item) {
- $currentId = $item['id'] ?? '';
- $title = $item['title'] ?? '';
- $titleData[$currentId] = $title;
- }
- }
- $currentTitle = $titleData[$id] ?? '';
- $info = $data[$id] ?? [];
- array_unshift($info, ['style' => 'title', 'value' => $currentTitle]);
- //组合出视频完整链接
- $apiHost = Yii::$app->params['ghsHost'];
- foreach ($info as $key => $val) {
- if (isset($val['style']) && $val['style'] == 'video') {
- $info[$key]['value'] = $apiHost . $val['value'];
- }
- }
- util::success(['list' => $info]);
- }
- //关闭手册 shish 20211211
- public function actionCloseBook()
- {
- $cacheKey = 'close_book_' . $this->shopAdminId;
- Yii::$app->redis->executeCommand('SET', [$cacheKey, 'has']);
- util::complete();
- }
- }
|