QRcodeComm.php 917 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare (strict_types = 1);
  3. namespace library\utils;
  4. use dh2y\qrcode\QRcode;
  5. use think\facade\Config;
  6. class QRcodeComm{
  7. private $QrTool=null;
  8. public function __construct($config = [])
  9. {
  10. $this->QrTool = new QRcode();
  11. }
  12. /**
  13. * 生成二维码
  14. * @param type $data
  15. * @param type $outfile
  16. */
  17. public function getPngErcode($data){
  18. $config= Config::get('qrcode');
  19. $code_path =$this->QrTool
  20. ->png($data)//生成二维码
  21. // ->logo('static/image/avatar-m.jpg')//生成logo二维码
  22. // ->background(180,500)//给二维码加上背景
  23. // ->text($role,20,['center',740],'#ff4351')//添加文字水印
  24. // ->text($nick_name,20,['center',780],'#000000')
  25. ->getPath();//获取二维码生成的地址
  26. return $code_path;
  27. }
  28. }