Kaynağa Gözat

内容海报调整

wzq 5 yıl önce
ebeveyn
işleme
f1f80cde36
2 değiştirilmiş dosya ile 28 ekleme ve 23 silme
  1. 28 23
      app/Repositories/PosterRepository.php
  2. BIN
      public/image/post/main.png

+ 28 - 23
app/Repositories/PosterRepository.php

@@ -37,14 +37,17 @@ class PosterRepository
             return jsonError('获取内容信息失败');
         }
 
-        // 设置头像
-        if(!$userInfo['avatar']){
-            $userInfo['avatar'] = 'https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83ep3asJn8emiat1MnPdviaPNroWY3f65y5ezkTAk2qtibv7ea9Ht9R2ahxr9bicY1DIj5vN5FibpDOwXegg/132';
-        }
+        // 彩虹豆数
+        $bean = 500;
+        $beanWidth = 540;
+        if(strlen($bean) == 4) $beanWidth = 532;
+        $main->text($bean, $beanWidth, 1214, function ($font) {
+            $font->file(public_path('font/PingFang Bold.ttf'));
+            $font->size(28);
+            $font->color('#FFFFFF');
+            $font->align('left');
+        });
 
-        if(!$userInfo['username']){
-            $userInfo['username'] = '';
-        }
         //内容图片
         $postImg = ImageManagerStatic::make($postDetail['img'].'!poster_app')->fit(750, 962);
         $main->insert($postImg, 'left-top', 0, 0);
@@ -99,12 +102,15 @@ class PosterRepository
         });
 
         // 用户名称
-        $main->text($userInfo['username'], 155, 470, function ($font) {
-            $font->file(public_path('font/PingFang Regular.ttf'));
-            $font->size(24);
-            $font->color('#FFFFFF');
-            $font->align('left');
-        });
+        if($userInfo['username']){
+            $main->text($userInfo['username'], 155, 470, function ($font) {
+                $font->file(public_path('font/PingFang Regular.ttf'));
+                $font->size(24);
+                $font->color('#FFFFFF');
+                $font->align('left');
+            });
+        }
+
         // 用户头像
         if($userInfo['avatar']){
             $avatar = Image::make($userInfo['avatar'])->resize(42,42);
@@ -149,10 +155,6 @@ class PosterRepository
     {
         $main = ImageManagerStatic::make($mainImg);
 
-        if(!$userInfo['username']){
-            $userInfo['username'] = '';
-        }
-
         // 彩虹豆数
         $beanWidth = 194;
         if(strlen($bean) == 4) $beanWidth = 182;
@@ -181,12 +183,15 @@ class PosterRepository
         }
 
         // 用户名称
-        $main->text($userInfo['username'], 30, 860, function ($font) {
-            $font->file(public_path('font/PingFang Regular.ttf'));
-            $font->size(28);
-            $font->color('#3C5852');
-            $font->align('left');
-        });
+        if($userInfo['username']){
+            $main->text($userInfo['username'], 30, 860, function ($font) {
+                $font->file(public_path('font/PingFang Regular.ttf'));
+                $font->size(28);
+                $font->color('#3C5852');
+                $font->align('left');
+            });
+        }
+
         // 用户头像
         if($userInfo['avatar']){
             $avatar = Image::make($userInfo['avatar'])->resize(88,88);

BIN
public/image/post/main.png