| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 保存小程序码到文件 |
| | | */ |
| | | protected function saveBranchQrcodeToDir($app_id, $page, $savePath, $branch_id) |
| | | { |
| | | // 小程序配置信息 |
| | | $app = AppWx::getApp($app_id); |
| | | // 小程序码参数 |
| | | $scene = "branch_id:{$branch_id}"; |
| | | // 文件名称 |
| | | $fileName = 'qrcode_' . md5($app_id . $scene . $page) . '.png'; |
| | | // 请求api获取小程序码 |
| | | $response = $app->app_code->getUnlimit($scene, [ |
| | | 'page' => $page, |
| | | 'width' => 430 |
| | | ]); |
| | | // 保存小程序码到文件 |
| | | if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { |
| | | $response->saveAs($savePath, $fileName); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 保存二维码码到文件 |
| | | */ |
| | | protected function saveBranchMpQrcodeToDir($page, $savePath, $branch_id, $app_id) |
| | | { |
| | | $qrcode = new QrCode(base_url() . $page . '?app_id=' . $app_id . '&branch_id=' . $branch_id); |
| | | $scene = "branch_id:{$branch_id}"; |
| | | // 文件名称 |
| | | $fileName = 'qrcode_' . md5($app_id . $scene) . '.png'; |
| | | // 保存二维码到文件 |
| | | $path = "{$savePath}{$fileName}"; |
| | | $qrcode->writeFile($path); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 保存二维码码到文件 |
| | | */ |
| | | protected function saveBranchActivityQrcodeToDir($app_id, $page, $savePath, $scene) |
| | | { |
| | | // 小程序配置信息 |
| | | $app = AppWx::getApp($app_id); |
| | | // 文件名称 |
| | | $fileName = 'qrcode_' . md5($app_id . $scene . $page) . '.png'; |
| | | // 请求api获取小程序码 |
| | | $response = $app->app_code->getUnlimit($scene, [ |
| | | 'page' => $page, |
| | | 'width' => 430 |
| | | ]); |
| | | // 保存小程序码到文件 |
| | | if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { |
| | | $response->saveAs($savePath, $fileName); |
| | | } |
| | | |
| | | return $savePath . $fileName; |
| | | } |
| | | |
| | | /** |
| | | * 保存二维码码到文件 |
| | | */ |
| | | protected function saveBranchActivityVerifyMpQrcodeToDir($page, $savePath, $activity_id, $app_id) |
| | | { |
| | | $qrcode = new QrCode(base_url() . $page . '?app_id=' . $app_id . '&activity_id=' . $activity_id. '&user_verify=1'); |
| | | $scene = "activity_id:{$activity_id}"; |
| | | // 文件名称 |
| | | $fileName = 'qrcode_' . md5($app_id . $scene) . '.png'; |
| | | // 保存二维码到文件 |
| | | $path = "{$savePath}{$fileName}"; |
| | | $qrcode->writeFile($path); |
| | | return $savePath .'/'. $fileName;; |
| | | } |
| | | |
| | | } |