## 接口情況
作者: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'];
}
~~~
- 手機是否使用驗證接口
- 返回碼所代表的含義
- 發送手機驗證碼接口
- 用戶注冊接口
- 獲取商品所有分類
- 獲取商品列表
- 用戶登陸接口
- 獲取商品詳細信息
- 獲取產品圖文詳情
- 獲取商品評論列表
- 獲取推薦商品
- 獲取找回密碼短信
- 重置密碼
- 獲取每日特惠商品
- 獲取輪播圖
- 用戶中心首頁
- 獲取用戶收藏商品
- 刪除用戶收藏商品
- 獲取所有訂單(所有訂單、代付款訂單、待收貨訂單、退換貨訂單)
- 加入購物車
- 獲取購物車商品
- 刪除購物車商品
- 購物車商品移入收藏夾
- 添加收貨地址
- 獲取用戶收貨地址
- 添加用戶收藏
- 提交訂單
- 填寫訂單
- 退出登錄
- 確認支付成功(正在驗證支付狀態)
- 驗證自動登陸
- 獲取訂單詳情
- 設置默認收貨地址
- 刪除收貨地址
- 修改收貨地址