...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\api\controller\inspection\Task;
|
|
|
use app\common\controller\Backend;
|
|
|
use think\Db;
|
|
|
|
...
|
...
|
@@ -121,7 +122,8 @@ class Car extends Backend |
|
|
"driver_id"=>$driver["id"],
|
|
|
"route_id"=>$route["id"],
|
|
|
];
|
|
|
$place_image=$index->build(json_encode($data));
|
|
|
$url_data="?start_address={$route["start_address"]}&route_id={$route["id"]}&driver_id={$driver["id"]}&license_plate={$car["license_plate"]}&name={$driver["name"]}&end_address{$route["end_address"]}&price{$route["price"]}";
|
|
|
$place_image=$this->getQRCode($url_data);
|
|
|
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
...
|
...
|
@@ -187,7 +189,8 @@ class Car extends Backend |
|
|
"driver_id"=>$driver["id"],
|
|
|
"route_id"=>$route["id"],
|
|
|
];
|
|
|
$place_image=$index->build(json_encode($data));
|
|
|
$url_data="?start_address={$route["start_address"]}&route_id={$route["id"]}&driver_id={$driver["id"]}&license_plate={$car["license_plate"]}&name={$driver["name"]}&end_address{$route["end_address"]}&price{$route["price"]}";
|
|
|
$place_image=$this->getQRCode($url_data);
|
|
|
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -213,7 +216,6 @@ class Car extends Backend |
|
|
|
|
|
function createMiniProgramQRCode($accessToken, $path, $width = 430) {
|
|
|
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
|
|
|
|
|
|
$data = json_encode([
|
|
|
'path' => $path,
|
|
|
'width' => $width
|
...
|
...
|
@@ -227,9 +229,12 @@ class Car extends Backend |
|
|
];
|
|
|
//POST参数
|
|
|
$result = $this->httpRequest($url,$data,"POST");
|
|
|
$filename= './uploads/store_qrcode/' . time() . '.png';
|
|
|
$code_name=rand().time() . '.png';
|
|
|
$filename= './uploads/store_qrcode/' . $code_name;
|
|
|
$ret = file_put_contents($filename, $result, true);
|
|
|
return $filename;
|
|
|
$task=new Task();
|
|
|
$res=$task->fileUpload($code_name);
|
|
|
return $res['fileurl'];
|
|
|
}
|
|
|
//把请求发送到微信服务器换取二维码
|
|
|
public function httpRequest($url,$data='',$method='GET'){
|
...
|
...
|
@@ -256,23 +261,12 @@ class Car extends Backend |
|
|
curl_close($curl);
|
|
|
return $result;
|
|
|
}
|
|
|
public function test(){
|
|
|
public function getQRCode($url_data){
|
|
|
$accessToken = $this->getAccessToken();
|
|
|
if ($accessToken) {
|
|
|
$path = 'pages/index/index'; // 小程序内的页面路径
|
|
|
$path = 'pages/module/intercityOrder'.$url_data; // 小程序内的页面路径
|
|
|
$qrCodeData = $this->createMiniProgramQRCode($accessToken, $path);
|
|
|
|
|
|
if ($qrCodeData) {
|
|
|
echo '图像文件保存成功!';
|
|
|
// 验证图像文件是否成功保存
|
|
|
} else {
|
|
|
echo '图像文件保存失败!';
|
|
|
}
|
|
|
header('Content-Type: image/png');
|
|
|
} else {
|
|
|
echo "Failed to generate QR code.";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
return $qrCodeData;
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|