['except' => ['login', 'index', 'about', 'cate', 'product', 'detail_product', 'register']], ]; /** * @api {post} /Content/index 01 首页api * @apiGroup Content * @apiVersion 1.0.0 * @apiDescription 首页接口,返回 广告列表(最新6条),产品数据(最大4条) * @apiSuccessExample {json} 成功示例 * {"code":1,"msg":"","time":1660034733,"data":{"ad":[{"id":1,"create_time":1580378718,"update_time":1580378718,"sort":1,"status":1,"type_id":1,"name":"banner_1 ","image":"\/uploads\/20181225\/b671c6f234a72c2e6560c63ddd9dc0ff.jpg","thumb":"\/uploads\/20181225\/b671c6f234a72c2e6560c63ddd9dc0ff.jpg","url":"","description":"banner_1"},{"id":2,"create_time":1580378773,"update_time":1583585682,"sort":2,"status":1,"type_id":1,"name":"banner_2","image":"\/uploads\/20181225\/25670f5712b4acfb61c5d2a1bce79225.jpg","thumb":"\/uploads\/20181225\/25670f5712b4acfb61c5d2a1bce79225.jpg","url":"","description":"banner_2"}],"yinshidapeng":[{"id":1,"create_time":1581076523,"update_time":1581076523,"sort":50,"status":1,"cate_id":9,"title":"一本书","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/065928f94ebe13ab1fbdc09cdd28a18b.jpg","images":"","download":"","tags":"书本","hits":0,"keywords":"","description":"","template":"","url":"","view_auth":0},{"id":2,"create_time":1581076563,"update_time":1581076563,"sort":50,"status":1,"cate_id":9,"title":"一支笔","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/f05f564a79e650d566251152fa4fa75e.jpg","images":"","download":"","tags":"笔","hits":0,"keywords":"","description":"","template":"","url":"","view_auth":0},{"id":5,"create_time":1581076652,"update_time":1581076652,"sort":50,"status":1,"cate_id":9,"title":"笔记本","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/d42552c77b14805f6d48e00b7a38f2e8.jpg","images":"","download":"","tags":"","hits":0,"keywords":"","description":"","template":"","url":"","view_auth":0},{"id":7,"create_time":1581076718,"update_time":1581076718,"sort":50,"status":1,"cate_id":9,"title":"铅笔盒","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/c89c7634f5bcd3b60884da427bc0b384.jpg","images":"","download":"","tags":"","hits":0,"keywords":"","description":"","template":"","url":"","view_auth":0}],"shijingpianchang":[{"id":4,"create_time":1581076620,"update_time":1660025639,"sort":50,"status":1,"cate_id":10,"title":"背包","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/8852280b4dc3365af4855c779e4239c6.jpg","images":"[]","download":"","tags":"","hits":0,"keywords":"","description":"","template":"","url":"","view_auth":0},{"id":6,"create_time":1581076690,"update_time":1660025634,"sort":50,"status":1,"cate_id":10,"title":"一支笔","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/d42552c77b14805f6d48e00b7a38f2e8.jpg","images":"[]","download":"","tags":"笔","hits":0,"keywords":"","description":"","template":"","url":"","view_auth":0}],"peitaosheshi":[{"id":3,"create_time":1581076594,"update_time":1660025645,"sort":50,"status":1,"cate_id":14,"title":"一支铅笔","author":"管理员","source":"本站","content":"","summary":"","image":"\/uploads\/20181224\/d5e07bd3fdd9f3cbb0bdc798ccdba178.jpg","images":"[]","download":"","tags":"笔","hits":2,"keywords":"","description":"","template":"","url":"","view_auth":0}]}} * @apiErrorExample {json} 失败示例 * {"code":0,"msg":"数据异常,请稍后操作","time":1563525638,"data":[]} */ public function index() { //广告 $_data['ad'] = Db::name('ad')->where('status', 1)->order('sort DESC,create_time DESC')->limit(6)->select(); //三个产品分类 $field = 'id,create_time,sort,status,cate_id,title,author,source,image'; $_data['yinshidapeng'] = Db::name('product')->where('cate_id', 9) ->field($field)->order('sort DESC,create_time DESC')->limit(4)->select(); $_data['shijingpianchang'] = Db::name('product')->where('cate_id', 10) ->field($field)->order('sort DESC,create_time DESC')->limit(4)->select(); $_data['peitaosheshi'] = Db::name('product')->where('cate_id', 14) ->field($field)->order('sort DESC,create_time DESC')->limit(4)->select(); $_data['kepianxinshang'] = Db::name('product')->where('cate_id', 15) ->field($field)->order('sort DESC,create_time DESC')->limit(4)->select(); return $this->result($_data, 1, ''); } /** * @api {get} /Content/about 02 关于我们 * @apiGroup Content * @apiVersion 1.0.0 * @apiDescription 关于我们内容详情接口,返回实体内容 * @apiSuccessExample {json} 成功示例 * {"code":1,"msg":"","time":1660034052,"data":{"content":"

ThinkPHP是一个免费开源的,快速、简单的面向对象的轻量级PHP开发框架,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简代码的同时,更注重易用性。遵循Apache2<\/code>开源许可协议发布,意味着你可以免费使用ThinkPHP,甚至允许把你基于ThinkPHP开发的应用开源或商业产品发布\/销售。<\/p>\n\n

ThinkPHP6.0<\/code>基于精简核心和统一用法两大原则在5.1<\/code>的基础上对底层架构做了进一步的优化改进,并更加规范化。由于引入了一些新特性,ThinkPHP6.0<\/code>运行环境要求PHP7.1+<\/code>,不支持5.1<\/code>的无缝升级(官方给出了升级指导用于项目的升级参考)。<\/p>\n"}} * @apiErrorExample {json} 失败示例 * {"code":0,"msg":"数据异常,请稍后操作","time":1563525638,"data":[]} */ public function about() { //联系我们 $_data = Db::name('page')->where('id', 1)->field('content')->find(); $_data['content'] = strip_tags($_data['content']); // $_data['map'] = Db::name('page')->where('id', 1)->field('content')->find(); $_system = Db::name('system')->where('id', 1)->find(); $_data['address'] = $_system['address']; $_data['tel'] = $_system['tel']; $_data['contact_phone'] = $_system['mobile_phone']; $_data['phone'] = strip_tags(Db::name('debris')->where('name', 'contuct')->find()['content']); $_data['map'] = strip_tags(Db::name('debris')->where('name', 'map')->find()['content']); return $this->result($_data, 1, ''); } /** * @api {get} /Content/cate 03 获取产品栏目 * @apiGroup Content * @apiVersion 1.0.0 * @apiDescription 产品栏目列表接口 * @apiSuccessExample {json} 成功示例 * {"code":1,"msg":"","time":1660034279,"data":[{"id":9,"sort":41,"status":1,"cate_name":"影视大棚","en_name":"","parent_id":8},{"id":10,"sort":42,"status":1,"cate_name":"实景片场","en_name":"","parent_id":8},{"id":14,"sort":50,"status":1,"cate_name":"配套设施","en_name":"","parent_id":8}]} * @apiErrorExample {json} 失败示例 * {"code":0,"msg":"数据异常,请稍后操作","time":1563525638,"data":[]} */ public function cate() { //获取产品栏目 $_data = Db::name('cate')->where('parent_id', 8) ->where('status', 1) ->field('id,sort,status,cate_name,en_name,parent_id') ->select(); return $this->result($_data, 1, ''); } /** * @api {get} /Content/product/cate_id/{cate_id}/page/{page}/limit/{limit} 04 产品列表 * @apiGroup Content * @apiVersion 1.0.0 * @apiDescription 产品列表接口,返回某个栏目下所有的产品列表,可分页 * @apiParam (请求参数:) {int} cate_id 栏目id 必填 * @apiParam (请求参数:) {int} page 当前页数 * @apiParam (请求参数:) {int} limit 每页数量 默认10 * @apiSuccessExample {json} 成功示例 * {"code":1,"msg":"","time":1660034442,"data":[{"id":1,"image":"\/uploads\/20181224\/065928f94ebe13ab1fbdc09cdd28a18b.jpg","cate_id":9,"title":"一本书"},{"id":2,"image":"\/uploads\/20181224\/f05f564a79e650d566251152fa4fa75e.jpg","cate_id":9,"title":"一支笔"}]} * @apiErrorExample {json} 失败示例 * {"code":0,"msg":"数据异常,请稍后操作","time":1563525638,"data":[]} */ public function product(int $cate_id, int $page = 1, int $limit = 2) { //获取所有产品栏目内容 $_db = Db::name('product'); $_data = $_db->where('cate_id', $cate_id)->field('id,image,cate_id,title') ->where('status', 1) ->page($page, $limit)->select(); return $this->result($_data, 1, ''); } /** * @api {get} /Content/detail_product/id/{id} 05 产品详情 * @apiGroup Content * @apiVersion 1.0.0 * @apiDescription 产品详情以及相关推荐接口,返回产品详情以及相关推荐数据 * @apiParam (请求参数:) {int} id 产品id 必填 * @apiSuccessExample {json} 成功示例 * {"code":1,"msg":"","time":1660034541,"data":{"detail":{"id":8,"title":"钢笔","create_time":1581076758,"source":"本站","cate_id":9,"content":"","summary":""},"postion":[{"id":8,"title":"钢笔","image":"\/uploads\/20181224\/f05f564a79e650d566251152fa4fa75e.jpg"},{"id":7,"title":"铅笔盒","image":"\/uploads\/20181224\/c89c7634f5bcd3b60884da427bc0b384.jpg"},{"id":6,"title":"一支笔","image":"\/uploads\/20181224\/d42552c77b14805f6d48e00b7a38f2e8.jpg"},{"id":5,"title":"笔记本","image":"\/uploads\/20181224\/d42552c77b14805f6d48e00b7a38f2e8.jpg"}]}} * @apiErrorExample {json} 失败示例 * {"code":0,"msg":"数据异常,请稍后操作","time":1563525638,"data":[]} */ public function detail_product(int $id) { $_db = Db::name('product'); $_data['detail'] = $_db->field('id,title,create_time,source,cate_id,image,images,content,summary') ->where('status', 1) ->find($id); // $_data['detail']['content'] = strip_tags($_data['detail']['content'], ''); //替换img 标签 // $_data['detail']['content'] = $this->replace_img_alt($_data['detail']['content']); //$_data['detail']['content'] = str_ireplace('where('id', $_data['detail']['cate_id'])->find(); $_data['detail']['source'] = $_cate['cate_name']; $_data['postion']= Db::name('product')->field('id,title,image')->limit(4) ->order('sort DESC,create_time DESC')->select(); return $this->result($_data, 1, ''); } private function replace_img_alt($str = '') { if (empty($str)) { return $str; } $str = htmlspecialchars_decode($str); preg_match_all('//i', $str, $result, PREG_SET_ORDER); $pattern = '/(]+>)/is'; $replacement = "\$1$3"; $resultCount = count($result); for ($i = 0; $i < $resultCount; $i++) { if (strpos($result[$i][1], '.swf') === false) { $img[] = $result[$i][1]; //$imgStr = ""; $imgStr = preg_replace($pattern, $replacement, $result[$i][0]); $str = str_replace($result[$i][0], $imgStr, $str); } } return $str; } }