|
@@ -180,7 +180,7 @@ class Product extends Auth{
|
|
$fontPath = public_path().'/fonts/msyh14.ttf';// 指定字体文件路径
|
|
$fontPath = public_path().'/fonts/msyh14.ttf';// 指定字体文件路径
|
|
// 生成小程序二维码
|
|
// 生成小程序二维码
|
|
$qrcode = Mini::getUnlimit($scene,['page'=>'pages/product/index','width'=>280,'is_hyaline'=>true]);
|
|
$qrcode = Mini::getUnlimit($scene,['page'=>'pages/product/index','width'=>280,'is_hyaline'=>true]);
|
|
- // 错误提示
|
|
|
|
|
|
+ // 错误提示
|
|
if( isset($qrcode['error']) ) return $qrcode;
|
|
if( isset($qrcode['error']) ) return $qrcode;
|
|
// 加载图片
|
|
// 加载图片
|
|
$qrcode = Image::make($qrcode)->resize(250,250);
|
|
$qrcode = Image::make($qrcode)->resize(250,250);
|
|
@@ -195,13 +195,35 @@ class Product extends Auth{
|
|
$font->color('#333333');
|
|
$font->color('#333333');
|
|
$font->align('left');
|
|
$font->align('left');
|
|
});
|
|
});
|
|
- // 给图片写入文字
|
|
|
|
- $image->text($oldData['name'], 120,1380,function (Font $font) use ($fontPath) {
|
|
|
|
- $font->file($fontPath); // 字体文件地址
|
|
|
|
- $font->size(48); // 字体大小
|
|
|
|
- $font->color('#333333');
|
|
|
|
- $font->align('left');
|
|
|
|
- });
|
|
|
|
|
|
+ if( mb_strlen($oldData['name']) > 44 ) {
|
|
|
|
+ // 显示截取后的文字
|
|
|
|
+ $oldData['name'] = mb_substr($oldData['name'],0,22).PHP_EOL.mb_substr($oldData['name'],22,22).PHP_EOL.mb_substr($oldData['name'],44,8);
|
|
|
|
+ // 给图片写入文字
|
|
|
|
+ $image->text($oldData['name'], 80,1480,function (Font $font) use ($fontPath) {
|
|
|
|
+ $font->file($fontPath); // 字体文件地址
|
|
|
|
+ $font->size(48); // 字体大小
|
|
|
|
+ $font->color('#333333');
|
|
|
|
+ $font->align('left');
|
|
|
|
+ });
|
|
|
|
+ }else if( mb_strlen($oldData['name']) > 22 ) {
|
|
|
|
+ // 显示截取后的文字
|
|
|
|
+ $oldData['name'] = mb_substr($oldData['name'],0,22).PHP_EOL.mb_substr($oldData['name'],22,22);
|
|
|
|
+ // 给图片写入文字
|
|
|
|
+ $image->text($oldData['name'], 80,1450,function (Font $font) use ($fontPath) {
|
|
|
|
+ $font->file($fontPath); // 字体文件地址
|
|
|
|
+ $font->size(48); // 字体大小
|
|
|
|
+ $font->color('#333333');
|
|
|
|
+ $font->align('left');
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ // 给图片写入文字
|
|
|
|
+ $image->text($oldData['name'], 120,1380,function (Font $font) use ($fontPath) {
|
|
|
|
+ $font->file($fontPath); // 字体文件地址
|
|
|
|
+ $font->size(48); // 字体大小
|
|
|
|
+ $font->color('#333333');
|
|
|
|
+ $font->align('left');
|
|
|
|
+ });
|
|
|
|
+ }
|
|
// 转码成字符串
|
|
// 转码成字符串
|
|
$image = $image->encode('jpg', 90)->__toString();
|
|
$image = $image->encode('jpg', 90)->__toString();
|
|
// 转base64
|
|
// 转base64
|