作者 何书鹏
1 个管道 的构建 通过 耗费 2 秒

修改接收参数方法

... ... @@ -89,9 +89,9 @@ class Category extends Api
*/
public function goods()
{
$rows = $this->request->request('rows',null);// 每页条数
$page = $this->request->request('page',1);// 页码
$category_id = $this->request->request('category_id');
$rows = $this->request->param('rows',null);// 每页条数
$page = $this->request->param('page',1);// 页码
$category_id = $this->request->param('category_id');
$category = $this->model->get($category_id);
empty($category) && $this->error(__('分类信息不存在'));
$has_parent = $this->model->where('pid','>','0')->where('id',$category['pid'])->find();
... ...
... ... @@ -107,9 +107,9 @@ class Index extends Api
*/
public function searchGoodsList()
{
$rows = $this->request->request('rows',null);// 每页条数
$page = $this->request->request('page',1);// 页码
$keywords = $this->request->request('keywords','');
$rows = $this->request->param('rows',null);// 每页条数
$page = $this->request->param('page',1);// 页码
$keywords = $this->request->param('keywords','');
$list = Goods::getList(['goods_name'=>['like','%'.$keywords.'%']],$page,$rows);
$this->success(__('成功'),compact('list'));
}
... ... @@ -155,9 +155,9 @@ class Index extends Api
*/
public function goodsList()
{
$rows = $this->request->request('rows',null);// 每页条数
$page = $this->request->request('page',1);// 页码
$category_id = $this->request->request('category_id');// 分类id
$rows = $this->request->param('rows',null);// 每页条数
$page = $this->request->param('page',1);// 页码
$category_id = $this->request->param('category_id');// 分类id
empty($category_id) && $this->error(__('参数不合法!'));
$three_category_id_arr = Category::where('pid',$category_id)->column('id');
$where = "FIND_IN_SET('{$category_id}', category_ids)";
... ... @@ -185,8 +185,8 @@ class Index extends Api
*/
public function memberGoodsList()
{
$rows = $this->request->request('rows',null);// 每页条数
$page = $this->request->request('page',1);// 页码
$rows = $this->request->param('rows',null);// 每页条数
$page = $this->request->param('page',1);// 页码
$list = Goods::getList(['ismember'=>'1'],$page,$rows);
// 返回结果
$this->success(__('成功'),compact('list'));
... ... @@ -207,8 +207,8 @@ class Index extends Api
*/
public function hotGoodsList()
{
$rows = $this->request->request('rows',null);// 每页条数
$page = $this->request->request('page',1);// 页码
$rows = $this->request->param('rows',null);// 每页条数
$page = $this->request->param('page',1);// 页码
$list = Goods::getList(['ishot'=>'1'],$page,$rows);
// 返回结果
$this->success(__('成功'),compact('list'));
... ... @@ -229,7 +229,7 @@ class Index extends Api
public function goodsInfo()
{
// 商品id
$goods_id = $this->request->request('goods_id');
$goods_id = $this->request->param('goods_id');
$goods = Goods::get($goods_id);
empty($goods) && $this->error(__('商品不存在'));
$goods['issale'] == '0' && $this->error(__('商品已下架'));
... ... @@ -268,9 +268,9 @@ class Index extends Api
public function appraiseList()
{
// 商品id
$rows = $this->request->request('rows',null);
$page = $this->request->request('page',1);
$goods_id = $this->request->request('goods_id');
$rows = $this->request->param('rows',null);
$page = $this->request->param('page',1);
$goods_id = $this->request->param('goods_id');
$list = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],$page,$rows);
// 返回结果
$this->success(__('成功'),compact('list'));
... ... @@ -290,7 +290,7 @@ class Index extends Api
*/
public function styleList()
{
$goods_id = $this->request->request('goods_id');
$goods_id = $this->request->param('goods_id');
$goods = Goods::get($goods_id);
empty($goods) && $this->error(__('商品信息不存在'));
$goods_style = GoodsStyle::get(['goods_id'=>$goods_id]);
... ... @@ -313,7 +313,7 @@ class Index extends Api
*/
public function specData()
{
$goods_id = $this->request->request('goods_id');
$goods_id = $this->request->param('goods_id');
$goods = Goods::get($goods_id);
empty($goods) && $this->error(__('商品信息不存在'));
$spec_data = $goods['spec_type'] == '2' ? $goods->getManySpecData($goods['spec_rel'], $goods['spec']) : null;
... ... @@ -335,8 +335,8 @@ class Index extends Api
*/
public function getGoodsSku()
{
$goods_id = $this->request->request('goods_id');
$spec_sku_id = $this->request->request('spec_sku_id');
$goods_id = $this->request->param('goods_id');
$spec_sku_id = $this->request->param('spec_sku_id');
$goods = Goods::get($goods_id,['spec_rel.spec']);
empty($goods) && $this->error(__('商品信息不存在'));
empty($spec_sku_id) && $this->error(__('请选择规格'));
... ...
... ... @@ -23,8 +23,8 @@ class Sms extends Api
*/
public function send()
{
$mobile = $this->request->request("mobile");
$event = $this->request->request("event");
$mobile = $this->request->param("mobile");
$event = $this->request->param("event");
$event = $event ? $event : 'changemobile';
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('手机号不正确'));
... ... @@ -106,30 +106,4 @@ class Sms extends Api
return false;
}
}
/**
* post提交数据
*/
protected function httpPost($url, $date) { // 模拟提交数据函数
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($date)); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
curl_setopt($curl, CURLOPT_HEADER, true); //开启header
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8'
)); //类型为json
$result = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
echo 'Error POST' . curl_error($curl);
}
curl_close($curl); // 关键CURL会话
return $result; // 返回数据
}
}
... ...
... ... @@ -178,8 +178,8 @@ class User extends Api
})
*/
public function scoreLog(){
$rows = $this->request->request('rows',null);// 每页条数
$page = $this->request->request('page',1);// 页码
$rows = $this->request->param('rows',null);// 每页条数
$page = $this->request->param('page',1);// 页码
$list = $this->model->scoreLog($this->user['id'],$page,$rows);
$this->success(__('成功'),array_merge([
'score' => $this->user['score']
... ... @@ -200,7 +200,7 @@ class User extends Api
})
*/
public function couponList(){
$status = $this->request->request('status');
$status = $this->request->param('status');
$list = \app\common\model\UserCoupon::couponList($this->user, $status);
$this->success(__('成功'),compact('list'));
}
... ... @@ -268,7 +268,7 @@ class User extends Api
*/
public function addressDetail()
{
$user_address_id = $this->request->request('user_address_id');
$user_address_id = $this->request->param('user_address_id');
$detail = UserAddress::detail($this->user['id'],$user_address_id);
$this->success(__('成功'),compact('detail'));
}
... ... @@ -323,7 +323,7 @@ class User extends Api
*/
public function addressDelete()
{
$user_address_id = $this->request->request('user_address_id');
$user_address_id = $this->request->param('user_address_id');
$model = UserAddress::detail($this->user['id'], $user_address_id);
if ($model->remove($this->user)) {
$this->success(__('删除成功'));
... ... @@ -346,7 +346,7 @@ class User extends Api
*/
public function addressDefault()
{
$user_address_id = $this->request->request('user_address_id');
$user_address_id = $this->request->param('user_address_id');
$model = UserAddress::detail($this->user['id'], $user_address_id);
if ($model->setDefault()) {
$this->success(__('设置成功'));
... ... @@ -386,7 +386,7 @@ class User extends Api
*/
public function bodyInfo()
{
$gender = $this->request->request('gender','1');
$gender = $this->request->param('gender','1');
$list = \app\common\model\Style::styleList($gender);
$this->success(__('成功'),compact('list'));
}
... ... @@ -480,7 +480,7 @@ class User extends Api
*/
public function sizeDetail()
{
$user_size_id = $this->request->request('user_size_id');
$user_size_id = $this->request->param('user_size_id');
$detail = UserSize::detail($this->user['id'],$user_size_id);
$this->success(__('成功'),compact('detail'));
}
... ... @@ -545,7 +545,7 @@ class User extends Api
*/
public function sizeDelete()
{
$user_size_id = $this->request->request('user_size_id');
$user_size_id = $this->request->param('user_size_id');
$model = UserSize::detail($this->user['id'], $user_size_id);
if ($model->remove($this->user)) {
$this->success(__('删除成功'));
... ... @@ -568,7 +568,7 @@ class User extends Api
*/
public function sizeDefault()
{
$user_size_id = $this->request->request('user_size_id');
$user_size_id = $this->request->param('user_size_id');
$model = UserSize::detail($this->user['id'], $user_size_id);
if ($model->setDefault()) {
$this->success(__('设置成功'));
... ...