php实现自定义中间logo的微信小程序码这里写自定义目录标题
小程序码生成的时候是默认使用小程序后台设置的小程序icon图片的,但是在有些场景我们可能要替换成我们自己想要的icon。
下面先放代码:
public function makeNewQrCodeAction()
{
//获取用户头像并转string
$avatarUrl = $this->_req->getQuery('avatarUrl', "");
// if (!$avatarUrl) {
// response::err_lack_param();
//}
if (!$avatarUrl) {
$avatarUrl = file_get_content(APP_PATH . "/public/imgs/default.png"); //这边如果微信用户 没有设置头像,给一个默认的头像,不然得到的二维码是空白图。
}
$avatar_file = file_get_contents($avatarUrl);
$logo = $this->changeAvatar($avatar_file);
//获取小程序码
$data['scene'] = $this->_req->getQuery('code', 1);
$data['width'] = (int)$this->_req->getQuery('width', 280);
$data['auto_color'] = $this->_req->getQuery('auto_color');
$data['line_color'] = $this->_req-&g