## 接口情况
作者:ncgis
时间:20150421
作用:获取每日特惠商品
提交方法:GET
提交参数
~~~
limit:每页数量默认10[可选]
page:当前页 默认1 [可选]
~~~
所在文件:product
接口地址:http://test.lingsq.com/index.php/api?method=lingsqapi.api.product.getChannelProduct
正式地址:http://www.lingsq.com/index.php/api?method=lingsqapi.api.product.getChannelProduct
返回数据样式:
~~~
{"data":{"item":[{"id":"1","goods_id":"392","price":"13.500","d_order":"1","is_active":"true","name":"\u5fb7\u8299\u9ed1\u5de7\u514b\u529b84g","imageurl":"http:\/\/test.lingsq.com\/public\/images\/store76\/e5\/de\/5d\/50def4bd43ab5f4b8484261f26d91b7e.jpg?1428719794#h"},{"id":"2","goods_id":"390","price":"5.800","d_order":"2","is_active":"true","name":"\u5fb7\u8299\u9187\u9999\u6469\u5361\u53ca\u70e4\u5df4\u65e6\u672843g","imageurl":"http:\/\/test.lingsq.com\/public\/images\/store76\/9d\/12\/24\/94e8c8ab8fb0dc899f262db2d60a968f.jpg?1428656345#h"}],"total":1,"page":1},"errNo":1,"errMsg":"ok","res":""}
~~~
参数解释
~~~
total:总页数
page:当前页
id:推荐id值
goods_id:商品id
price:价格
d_order:后台排序字段
is_active:是否激活
name:商品名称
imageurl:图片
~~~
## 实现代码
~~~
public function getChannelProduct()
{
$time=time();
$type_id=empty($_GET["type_id"])?1:$_GET["type_id"];
$page=empty($_GET["page"])?1:intval($_GET["page"]);
$pagelimit=empty($_GET["pagelimit"])?10:intval($_GET["pagelimit"]);
$mdl_channel = app::get('cellphone')->model('channel');
$sql=' select a.id,a.goods_id,b.price,a.d_order,a.is_active,b.name,b.image_default_id from sdb_cellphone_channel as a left join sdb_b2c_goods as b on a.goods_id=b.goods_id where a.type_id="'.$type_id.'" and a.start_time<="'.$time.'" and end_time>= "'.$time.'" and a.is_active="true" order by a.d_order asc limit '.($page-1)*$pagelimit.','.$pagelimit;
$data = $mdl_channel->db->select($sql);
if($data)
{
foreach($data as &$val)
{
$val['imageurl'] = base_storager::image_path($val['image_default_id'],'s');
unset($val['image_default_id']);
}
}
$count_sql='select count(a.goods_id) as _count from sdb_cellphone_channel as a left join sdb_b2c_goods as b on a.goods_id=b.goods_id where a.type_id="'.$type_id.'" and a.start_time<="'.$time.'" and end_time>= "'.$time.'" and a.is_active="true" order by a.d_order asc ';
$count=$mdl_channel->db->selectrow($count_sql);
$g_count=$count['_count'];
$total=ceil($g_count/ $pagelimit);
$back["item"]=$data;
$back["total"]=$total;
$back["page"]=$page;
$pdata['data']["data"]=$back;
$pdata['data']['errNo'] = 1;
$pdata['data']['errMsg'] = $this->errMsg($pdata['data']['errNo']);
return $pdata['data'];
}
~~~
- 手机是否使用验证接口
- 返回码所代表的含义
- 发送手机验证码接口
- 用户注册接口
- 获取商品所有分类
- 获取商品列表
- 用户登陆接口
- 获取商品详细信息
- 获取产品图文详情
- 获取商品评论列表
- 获取推荐商品
- 获取找回密码短信
- 重置密码
- 获取每日特惠商品
- 获取轮播图
- 用户中心首页
- 获取用户收藏商品
- 删除用户收藏商品
- 获取所有订单(所有订单、代付款订单、待收货订单、退换货订单)
- 加入购物车
- 获取购物车商品
- 删除购物车商品
- 购物车商品移入收藏夹
- 添加收货地址
- 获取用户收货地址
- 添加用户收藏
- 提交订单
- 填写订单
- 退出登录
- 确认支付成功(正在验证支付状态)
- 验证自动登陆
- 获取订单详情
- 设置默认收货地址
- 删除收货地址
- 修改收货地址