wang hou sheng 8 months ago
parent 70b8c8c871
commit 375d476255
  1. 2
      app/api/controller/User.php
  2. 16
      app/common/service/qrcode/InviteUser.php
  3. BIN
      app/common/service/qrcode/resource/invite_user.png

@ -316,7 +316,7 @@ class User extends Controller
public function InviteUserPoster(): Json public function InviteUserPoster(): Json
{ {
$userInfo = UserService::getCurrentLoginUser(true); $userInfo = UserService::getCurrentLoginUser(true);
$type = intval($this->request->post('type'), 1); $type = intval($this->request->post('type', 1));
// 生成二维码 // 生成二维码
$Qrcode = new InviteUser($userInfo, 'MP-WEIXIN', $type); $Qrcode = new InviteUser($userInfo, 'MP-WEIXIN', $type);
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]); return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]);

@ -48,9 +48,9 @@ class InviteUser extends BaseQRcode
public function getImage(): string public function getImage(): string
{ {
// 判断海报图文件存在则直接返回url // 判断海报图文件存在则直接返回url
if (file_exists($this->getPosterPath())) { // if (file_exists($this->getPosterPath())) {
return $this->getPosterUrl(); // return $this->getPosterUrl();
} // }
// 商城ID // 商城ID
$storeId = $this->userInfo['store_id']; $storeId = $this->userInfo['store_id'];
$backdrop = __DIR__ . '/resource/invite_user.png'; $backdrop = __DIR__ . '/resource/invite_user.png';
@ -63,8 +63,12 @@ class InviteUser extends BaseQRcode
// 下载小程序码 // 下载小程序码
$page = 'pages/login/index'; $page = 'pages/login/index';
$qrcode = $this->getQrcode($storeId, $scene, $page, $this->channel); $qrcode = $this->getQrcode($storeId, $scene, $page, $this->channel);
//获取图片名称
$arr = explode('/', $qrcode);
$name = end($arr);
return base_url() . 'temp/' . $this->userInfo['store_id'] . '/' . $name . '?t=' . time();
// 拼接海报图 // 拼接海报图
return $this->savePoster($backdrop, $qrcode); //return $this->savePoster($backdrop, $qrcode);
} }
/** /**
@ -83,9 +87,9 @@ class InviteUser extends BaseQRcode
// 打开小程序码 // 打开小程序码
$editor->open($qrcodeImage, $qrcode); $editor->open($qrcodeImage, $qrcode);
// 重设小程序码宽高 // 重设小程序码宽高
$editor->resizeExact($qrcodeImage, 140, 140); $editor->resizeExact($qrcodeImage, 110, 110);
// 小程序码添加到背景图 // 小程序码添加到背景图
$editor->blend($backdropImage, $qrcodeImage, 'normal', 1.0, 'top-left', 520, 700); $editor->blend($backdropImage, $qrcodeImage, 'normal', 1.0, 'top-left', 175, 555);
// 保存图片 // 保存图片
$editor->save($backdropImage, $this->getPosterPath()); $editor->save($backdropImage, $this->getPosterPath());
return $this->getPosterUrl(); return $this->getPosterUrl();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 KiB

After

Width:  |  Height:  |  Size: 185 KiB

Loading…
Cancel
Save