diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index ba2ce62d..816eea9d 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -644,7 +644,7 @@ class Common extends BaseController public function Qrcode($data) { $siteUrl = systemConfig('site_url'); - $name = md5('orcode' . date('Ymd')) . '.jpg'; + $name = md5('orcode' . date('Ymd')) . '.png'; $attachmentRepository = app()->make(AttachmentRepository::class); $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]); @@ -653,7 +653,12 @@ class Common extends BaseController $imageInfo = null; } if (!$imageInfo) { - $imageInfo = app()->make(QrcodeService::class)->getQRCodePath($data['code'], $name); + $imageInfo = app()->make(QrcodeService::class)->getQRCodePath($data['code'], $name,['code'=>[ + 'r' => 255, + 'g' => 221, + 'b' => 167, + 'a' => 0, + ]]); if (is_string($imageInfo)) throw new ValidateException('二维码生成失败'); $imageInfo['dir'] = tidy_url($imageInfo['dir'], null, $siteUrl); diff --git a/crmeb/services/QrcodeService.php b/crmeb/services/QrcodeService.php index f07ffab7..0fba8528 100644 --- a/crmeb/services/QrcodeService.php +++ b/crmeb/services/QrcodeService.php @@ -29,7 +29,7 @@ class QrcodeService * @param $name * @return array|bool|string */ - public function getQRCodePath($url, $name) + public function getQRCodePath($url, $name,$data) { if (!strlen(trim($url)) || !strlen(trim($name))) return false; try { @@ -42,6 +42,9 @@ class QrcodeService $info = []; $outfile = Config::get('qrcode.cache_dir'); $code = new QrCode($url); + if(isset($data['code'])){ + $code->setForegroundColor($data['code']); + } if ($uploadType === 1) { if (!is_dir('./public/' . $outfile)) mkdir('./public/' . $outfile, 0777, true);