|
@@ -2,6 +2,7 @@ |
|
@@ -2,6 +2,7 @@ |
2
|
|
2
|
|
3
|
namespace app\admin\controller;
|
3
|
namespace app\admin\controller;
|
4
|
|
4
|
|
|
|
5
|
+use app\api\controller\inspection\Task;
|
5
|
use app\common\controller\Backend;
|
6
|
use app\common\controller\Backend;
|
6
|
use think\Db;
|
7
|
use think\Db;
|
7
|
|
8
|
|
|
@@ -121,7 +122,8 @@ class Car extends Backend |
|
@@ -121,7 +122,8 @@ class Car extends Backend |
121
|
"driver_id"=>$driver["id"],
|
122
|
"driver_id"=>$driver["id"],
|
122
|
"route_id"=>$route["id"],
|
123
|
"route_id"=>$route["id"],
|
123
|
];
|
124
|
];
|
124
|
- $place_image=$index->build(json_encode($data));
|
125
|
+ $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"]}";
|
|
|
126
|
+ $place_image=$this->getQRCode($url_data);
|
125
|
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
|
127
|
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
|
126
|
Db::commit();
|
128
|
Db::commit();
|
127
|
} catch (ValidateException|PDOException|Exception $e) {
|
129
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
@@ -187,7 +189,8 @@ class Car extends Backend |
|
@@ -187,7 +189,8 @@ class Car extends Backend |
187
|
"driver_id"=>$driver["id"],
|
189
|
"driver_id"=>$driver["id"],
|
188
|
"route_id"=>$route["id"],
|
190
|
"route_id"=>$route["id"],
|
189
|
];
|
191
|
];
|
190
|
- $place_image=$index->build(json_encode($data));
|
192
|
+ $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"]}";
|
|
|
193
|
+ $place_image=$this->getQRCode($url_data);
|
191
|
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
|
194
|
$result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image['fileurl']]);
|
192
|
}
|
195
|
}
|
193
|
|
196
|
|
|
@@ -213,7 +216,6 @@ class Car extends Backend |
|
@@ -213,7 +216,6 @@ class Car extends Backend |
213
|
|
216
|
|
214
|
function createMiniProgramQRCode($accessToken, $path, $width = 430) {
|
217
|
function createMiniProgramQRCode($accessToken, $path, $width = 430) {
|
215
|
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
|
218
|
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
|
216
|
-
|
|
|
217
|
$data = json_encode([
|
219
|
$data = json_encode([
|
218
|
'path' => $path,
|
220
|
'path' => $path,
|
219
|
'width' => $width
|
221
|
'width' => $width
|
|
@@ -227,9 +229,12 @@ class Car extends Backend |
|
@@ -227,9 +229,12 @@ class Car extends Backend |
227
|
];
|
229
|
];
|
228
|
//POST参数
|
230
|
//POST参数
|
229
|
$result = $this->httpRequest($url,$data,"POST");
|
231
|
$result = $this->httpRequest($url,$data,"POST");
|
230
|
- $filename= './uploads/store_qrcode/' . time() . '.png';
|
232
|
+ $code_name=rand().time() . '.png';
|
|
|
233
|
+ $filename= './uploads/store_qrcode/' . $code_name;
|
231
|
$ret = file_put_contents($filename, $result, true);
|
234
|
$ret = file_put_contents($filename, $result, true);
|
232
|
- return $filename;
|
235
|
+ $task=new Task();
|
|
|
236
|
+ $res=$task->fileUpload($code_name);
|
|
|
237
|
+ return $res['fileurl'];
|
233
|
}
|
238
|
}
|
234
|
//把请求发送到微信服务器换取二维码
|
239
|
//把请求发送到微信服务器换取二维码
|
235
|
public function httpRequest($url,$data='',$method='GET'){
|
240
|
public function httpRequest($url,$data='',$method='GET'){
|
|
@@ -256,23 +261,12 @@ class Car extends Backend |
|
@@ -256,23 +261,12 @@ class Car extends Backend |
256
|
curl_close($curl);
|
261
|
curl_close($curl);
|
257
|
return $result;
|
262
|
return $result;
|
258
|
}
|
263
|
}
|
259
|
- public function test(){
|
264
|
+ public function getQRCode($url_data){
|
260
|
$accessToken = $this->getAccessToken();
|
265
|
$accessToken = $this->getAccessToken();
|
261
|
if ($accessToken) {
|
266
|
if ($accessToken) {
|
262
|
- $path = 'pages/index/index'; // 小程序内的页面路径
|
267
|
+ $path = 'pages/module/intercityOrder'.$url_data; // 小程序内的页面路径
|
263
|
$qrCodeData = $this->createMiniProgramQRCode($accessToken, $path);
|
268
|
$qrCodeData = $this->createMiniProgramQRCode($accessToken, $path);
|
264
|
-
|
|
|
265
|
- if ($qrCodeData) {
|
|
|
266
|
- echo '图像文件保存成功!';
|
|
|
267
|
-// 验证图像文件是否成功保存
|
|
|
268
|
- } else {
|
|
|
269
|
- echo '图像文件保存失败!';
|
|
|
270
|
- }
|
|
|
271
|
- header('Content-Type: image/png');
|
|
|
272
|
- } else {
|
|
|
273
|
- echo "Failed to generate QR code.";
|
|
|
274
|
- }
|
|
|
275
|
- }
|
|
|
276
|
-
|
|
|
277
|
-
|
269
|
+ return $qrCodeData;
|
|
|
270
|
+}
|
|
|
271
|
+}
|
278
|
} |
272
|
} |