forthMenu(); // 实例化默认模型 $this->thisDefaultModel = new Article(); } /** * Common: 文章列表 * Author: wu-hui * Time: 2022/10/18 15:28 * @return array|mixed * @throws \think\db\exception\DbException */ public function index(){ if (request()->isAjax()) { $params = input(''); // 缓存名称 $cacheTag = CaChe::tag($params); $list = CaChe::get('article_list',$cacheTag); if($list){ // 存在缓存时的处理 $list = json_decode($list,TRUE); }else{ $list = $this->thisDefaultModel->getList(); // 记录缓存 CaChe::set('article_list',json_encode($list,JSON_UNESCAPED_UNICODE),$cacheTag); } return $list; } return $this->fetch('article/index'); } /** * Common: 添加编辑文章信息 * Author: wu-hui * Time: 2022/10/14 15:44 * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function editInfo(){ if(request()->isAjax()) return parent::editInfo(); parent::editInfo(); // 获取分类 $field = ['category_id', 'category_name']; $categoryList = (new ArticleCategory()) ->field($field) ->where('site_id',$this->site_id) ->order('create_time','DESC') ->select(); if($categoryList) $categoryList = $categoryList->toArray(); $this->assign('category_list',$categoryList ?? []); return $this->fetch('article/edit'); } /** * Common: 装修 —— 文章选择器 * Author: wu-hui * Time: 2022/10/17 15:18 * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function selectInfo(){ if (request()->isAjax()) { // 获取已选择列表 return parent::index(); } else { //已经选择的商品sku数据 $ids = (string)trim(input('ids')); $this->assign('ids', $ids); // 获取已选择列表 if(strlen($ids) > 0){ $result = parent::index();; $this->assign('article_list', $result['data']['list']); }else{ $this->assign('article_list', []); } return $this->fetch("article/select"); } } /** * Common: 文章基本设置 * Author: wu-hui * Time: 2022/10/21 14:18 * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function set(){ $key = 'ARTICLE_SETTING'; $configModel = new Config(); if (request()->isAjax()) { // 参数获取 $info = input('info',[]); $params = [ 'site_id' => $this->site_id, 'app_module' => 'shop', 'config_key' => $key, 'value' => json_encode($info,JSON_UNESCAPED_UNICODE), 'config_desc' => '文章基本设置', 'is_use' => 1, ]; return $configModel->setConfigInfo($params); } else { $info = $configModel->getConfigInfo($key); $this->assign('info',$info); return $this->fetch('article/set'); } } }