request->param('keyword'); if ($keyword && !is_numeric($keyword)) { $page = PageModel::getByDiyname($keyword); } else { $id = $keyword ? $keyword : $this->request->param('id', ''); $page = PageModel::get($id); } // if (!$page || $page['status'] != 'normal') { // $this->error('未找到指定的单页'); // } $page->setInc('views'); $image = $page->getData('image'); $fields = explode(',', 'id,title,content,image,description,status,createtime'); $page = array_intersect_key($page->toArray(), array_flip($fields)); $page['content'] = \addons\shop\library\Service::formatTplToUniapp($page['content']); $page['image'] = $image ? cdnurl($image, true) : $image; $this->success('获取成功', $page); } //单页列表 public function lists() { $type = $this->request->param('type'); $list = PageModel::field('id,title,description,status,createtime') ->where('status', 'normal')->where('type', $type)->order('createtime desc')->paginate(15); $this->success('获取成功', $list); } }