<?php namespace app\api\controller; use app\models\page\PageModel; use app\Request; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; /** * 公共类 * Class PublicController * @package app\api\controller */ class PublicController { /** * @param Request $request * @return mixed * @throws DataNotFoundException * @throws ModelNotFoundException * @throws DbException */ public function index() { $site_name = sys_config('site_name', '', 1); $banner = sys_data('home_banner', 0, 1) ?: [];//TODO 首页轮播图 $menus = sys_data('home_menus', 0, 1) ?: [];//TODO 首页导航 $pics = sys_data('home_pics', 0, 1) ?: [];//TODO 首页展示图 return app('json')->successful(compact('site_name', 'banner', 'menus', 'pics')); } public function page($unique) { $info = PageModel::where('is_del', 0)->where('unique', $unique)->find()->toArray(); return app('json')->successful($info); } public function group_data($name) { $data = sys_data($name, 0, 1) ?: []; return app('json')->successful($data); } /** * 获取分享配置 * @param Request $request * @return mixed */ public function share(Request $request) { $mer_id = $request->mer_id(); $data['img'] = sys_config('wechat_share_img', '', $mer_id); if (strstr($data['img'], 'http') === false) $data['img'] = sys_config('site_url', '', $mer_id) . $data['img']; $data['img'] = str_replace('\\', '/', $data['img']); $data['title'] = sys_config('wechat_share_title', '', $mer_id); $data['synopsis'] = sys_config('wechat_share_synopsis', '', $mer_id); return app('json')->successful(compact('data')); } }