💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 接口情况 作者:ncgis 时间:20150425 作用:获取首页轮播图 提交参数: `version:版本参数[可选]` 所在文件:product 接口地址:http://test.lingsq.com/index.php/api?method=lingsqapi.api.product.getBanner 正式地址:http://www.lingsq.com/index.php/api?method=lingsqapi.api.product.getBanner 返回数据格式 ~~~ { "data": { "version": "1432706002", "item": [ { "type": "goods", "associate_id": "391", "imageurl": "http://test.lingsq.com/public/images/public/d2/f7/60/cb3d9ccbd0e64a74fb4534d3f36d367b.jpg?1407562163#w" } ] }, "errNo": 1, "errMsg": "ok", "res": "" } { "data": { "version": "1432706010" }, "errNo": 1, "errMsg": "ok", "res": "" } ~~~ 参数说明 ~~~ type:类型 goods activity 文章 imageurl:轮播图地址 associate_id:关联项目的id ~~~ ## 实现代码 ~~~ public function getBanner() { $version=$_GET["version"]; $banner=app::get('cellphone')->model('banner'); $sql="select max(lasttime) as maxlasttime from sdb_cellphone_banner"; $maxlasttime=$banner->db->select($sql); if(empty($version)) { $data["data"]["version"]= $maxlasttime["0"]["maxlasttime"]; $flag=true; } else { if($version<$maxlasttime["0"]["maxlasttime"]) { $data["data"]["version"]= $maxlasttime["0"]["maxlasttime"]; $flag=true; } else { $data["data"]["version"]=$version; $flag=false; } } if($flag) { $filter["is_active"]="true"; $focusImg = $banner->getList('associate_id,associate_type,image_id',$filter); foreach ($focusImg as $v) { $data["data"]["item"] []= array( "type" => $v['associate_type'], 'associate_id' => $v['associate_id'], 'imageurl' => base_storager::image_path($v['image_id'], 's')); } } $data['errNo'] = 1; $data['errMsg'] = $this->errMsg($data['errNo']); return $data; } ~~~ 修改文件 `app/cellphone/dbschema/banner.php 95行` `app/cellphone/view/admin/banner/add.html 61行` `app/cellphone/controller/admin/bannr.php 19 65 145行`