...
|
...
|
@@ -135,18 +135,28 @@ class User extends Api |
|
|
* @ApiSummary (获取二维码)
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiRoute (/api/user/getWxCode)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiParams (name="goods_id", type="inter", required=true, description="商品id")
|
|
|
*
|
|
|
* @ApiReturn ({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1572602867",
|
|
|
"data": {
|
|
|
"code_url": "http://hotel.w.brotop.cnwx_code_img/code_6.jpg"//二维码路径
|
|
|
"code_url": "http://feifangu.w.brotop.cn/wx_code_img/code_6.jpg"//二维码路径
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function getWxCode(){
|
|
|
if($this->request->isGet()){
|
|
|
$goods_id = $this->request->post('goods_id');
|
|
|
$rule = config('verify.goods_detail');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check(['goods_id'=>$goods_id])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
|
|
|
//获取access_token
|
|
|
$config = config('verify.raw');
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$config['app_id'].'&secret='.$config['secret'];
|
...
|
...
|
@@ -160,14 +170,14 @@ class User extends Api |
|
|
//获取二维码链接
|
|
|
$get_code_url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='.$access_token;
|
|
|
$data = [
|
|
|
'scene' => 'share_uid='.$this->uid,
|
|
|
'scene' => 'share_uid='.$this->uid.'&goods_id='.$goods_id,
|
|
|
'width' => 280,
|
|
|
// 'page' => 'pages/lixiangzhong/lixiangzhong',
|
|
|
];
|
|
|
$data = json_encode($data);
|
|
|
$code_res = $this->auth->http_post($get_code_url,$data);
|
|
|
file_put_contents('wx_code_img/code_'.$this->uid.'.jpg',$code_res);
|
|
|
$code_url = config('verify.hotel_url').'/wx_code_img/code_'.$this->uid.'.jpg';
|
|
|
$code_url = config('verify.ffg_host').'/wx_code_img/code_'.$this->uid.'.jpg';
|
|
|
$this->success('成功', ['code_url'=>$code_url]);
|
|
|
}else{
|
|
|
$this->error('请求方式错误');
|
...
|
...
|
|