作者 郭盛
1 个管道 的构建 通过 耗费 6 秒

项目授权码

... ... @@ -228,7 +228,7 @@ class Common extends Api
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); // Post提交的数据包
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, false); // 开启header
//curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);//请求头部
... ... @@ -238,4 +238,20 @@ class Common extends Api
return $result;
}
public function shou($farm_id,$project_id,$page){
//获取二维码链接
$get_code_url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='.$this->get_access_token();
$data = [
'scene' => 'farm_id='.$farm_id.'&project_id='.$project_id,
'width' => 280,
// 'page' => $page,
];
$data = json_encode($data);
$code_res = $this->http_post($get_code_url,$data);
file_put_contents('upload/project'.$project_id.'.jpg',$code_res);
$code_url = 'http://trace.w.brotop.cn/upload/project'.$project_id.'.jpg';
return $code_url;
}
}
\ No newline at end of file
... ...
... ... @@ -206,11 +206,17 @@ class Project extends Api
$param['image'] = str_replace($http,'',$param['image']);
$param['createtime'] = time();
$data = Db::name('project')->insertGetId($param);
//项目二维码
$common = new Common();
$url = 'pages/ShopDetail/ShopDetail?id='.$data;
$thumbnail = $common->imgcode($data,$url);
Db::name('project')->where('id',$data)->update(['thumbnail'=>$thumbnail]);
//授权二维码
$farm_id = $param['farm_id'];
$project_id = $data;
$page = 'pages/UserAdmin/UserAdmin';
$pic = $common->shou($farm_id,$project_id,$page);
Db::name('project')->where('id',$data)->update(['thumbnail'=>$thumbnail,'pic'=>$pic]);
//修改农场项目数
$project_num = Db::name('farm')->where('id',$param['farm_id'])->field('id,project_num')->find();
$project_num = $project_num['project_num'] + 1;
... ... @@ -1228,4 +1234,30 @@ class Project extends Api
}
/**
* @ApiTitle (项目授权码)
* @ApiSummary (项目授权码)
* @ApiMethod (POST)
* @ApiRoute (/api/project/shou)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="id", type="int", required=false, description="项目id")
*
* @ApiReturn({
"code": 1,
"msg": "SUCCESS",
"time": "1553839125",
"data": {
"id"://项目id
"pic"://项目授权码
}
})
*/
public function shou()
{
$id = $this->request->param('id');
$data = Db::name('project')->where('id',$id)->field('id,pic')->find();
$this->success('success',$data);
}
}
\ No newline at end of file
... ...
此 diff 太大无法显示。