Ver código fonte

二维码带图片

undefined
v-Brocloni 4 anos atrás
pai
commit
59920633fd
2 arquivos alterados com 12 adições e 1 exclusões
  1. +12
    -1
      addons/unishop/controller/Order.php
  2. BIN
      addons/unishop/library/phpqrcode/logo.png

+ 12
- 1
addons/unishop/controller/Order.php Ver arquivo

@@ -706,7 +706,18 @@ class Order extends Base
//生成二维码图片
\QRcode::png($value, $QRFile, $errorCorrectionLevel, $matrixPointSize, 2);
$QR = imagecreatefromstring(file_get_contents($QRFile));

//二维码
$logoUrl = imagecreatefromstring(file_get_contents(ROOT_PATH . '/addons/unishop/library/phpqrcode/logo.png'));
$QR_width = imagesx($QR);//二维码图片宽度
$logo_width = imagesx($logoUrl);//logo图片宽度
$logo_height = imagesy($logoUrl);//logo图片高度
$logo_qr_width = $QR_width / 5;
$scale = $logo_width / $logo_qr_width;
$logo_qr_height = $logo_height / $scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
//重新组合图片并调整大小
imagecopyresampled($QR, $logoUrl, $from_width, $from_width, 0, 0, $logo_qr_width,
$logo_qr_height, $logo_width, $logo_height);
//输出图片
Header("Content-type: image/png");
ImagePng($QR);


BIN
addons/unishop/library/phpqrcode/logo.png Ver arquivo

Antes Depois
Largura: 80  |  Altura: 79  |  Tamanho: 7.2 KiB

Carregando…
Cancelar
Salvar