<?php

declare (strict_types = 1);
namespace library\utils;


use dh2y\qrcode\QRcode;
use think\facade\Config;

class QRcodeComm{
    
    private $QrTool=null;

    public function __construct($config = [])
    {
        $this->QrTool = new QRcode();
    }
    /**
     * 生成二维码
     * @param type $data
     * @param type $outfile
     */
    public function getPngErcode($data){
        $config= Config::get('qrcode');
        $code_path =$this->QrTool
                    ->png($data)//生成二维码
//                    ->logo('static/image/avatar-m.jpg')//生成logo二维码
//                    ->background(180,500)//给二维码加上背景
//                    ->text($role,20,['center',740],'#ff4351')//添加文字水印
//                    ->text($nick_name,20,['center',780],'#000000')
                    ->getPath();//获取二维码生成的地址
        return $code_path;
    }
}