WIN-2308041133\Administrator 1 tydzień temu
rodzic
commit
57c1fbb03d
1 zmienionych plików z 99 dodań i 35 usunięć
  1. 99 35
      app/api/controller/user/UserBillController.php

+ 99 - 35
app/api/controller/user/UserBillController.php

@@ -161,6 +161,13 @@ class UserBillController
             $siteUrl = sys_config('site_url');
             $routineSpreadBanner = sys_data('routine_spread_banner');
             if (!count($routineSpreadBanner)) return app('json')->fail('暂无海报');
+
+            // 获取用户头像URL,确保是完整URL
+            $avatarUrl = $user['avatar'];
+            if ($avatarUrl && strpos($avatarUrl, 'http') === false) {
+                $avatarUrl = $siteUrl . $avatarUrl;
+            }
+
             if ($type == 1) {
                 //小程序
                 $name = $user['uid'] . '_' . $user['is_promoter'] . '_user_routine.jpg';
@@ -203,8 +210,21 @@ class UserBillController
                     $posterInfo = '海报生成失败:(';
                     $config = array(
                         'image' => array(
+                            // 添加头像
+                            array(
+                                'url' => $avatarUrl ?: '',     // 头像资源
+                                'stream' => 0,
+                                'left' => 125,                 // 头像位置左
+                                'top' => 300,                  // 头像位置上
+                                'right' => 0,
+                                'bottom' => 0,
+                                'width' => 120,                // 头像宽度
+                                'height' => 120,               // 头像高度
+                                'opacity' => 100,
+                                'radius' => 60                 // 圆形头像,半径设为宽度/高度的一半
+                            ),
                             array(
-                                'url' => $urlCode,     //二维码资源
+                                'url' => $urlCode,             // 二维码资源
                                 'stream' => 0,
                                 'left' => 114,
                                 'top' => 790,
@@ -216,22 +236,44 @@ class UserBillController
                             )
                         ),
                         'text' => array(
+                            // 昵称放在头像旁边
                             array(
                                 'text' => $user['nickname'],
-                                'left' => 250,
-                                'top' => 840,
+                                'left' => 260,                 // 在头像右侧
+                                'top' => 340,                  // 与头像垂直居中对齐
                                 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],     //字体文件
-                                'fontSize' => 16,             //字号
-                                'fontColor' => '40,40,40',       //字体颜色
+                                'fontSize' => 30,              //字号
+                                'fontColor' => '40,40,40',     //字体颜色
+                                'angle' => 0,
+                            ),
+                            // 第一行:邀请好友
+                            array(
+                                'text' => '邀请好友',
+                                'left' => 125,
+                                'top' => 450,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
+                                'fontSize' => 40,
+                                'fontColor' => '40,40,40',
+                                'angle' => 0,
+                            ),
+                            // 第二行:PIZZA
+                            array(
+                                'text' => 'PIZZA',  // 可替换为 sys_config('site_name')
+                                'left' => 125,
+                                'top' => 520,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
+                                'fontSize' => 70,
+                                'fontColor' => '40,40,40',
                                 'angle' => 0,
                             ),
+                            // 第三行:邀请您加入XX
                             array(
                                 'text' => '邀请您加入' . sys_config('site_name'),
-                                'left' => 250,
-                                'top' => 880,
-                                'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'],     //字体文件
-                                'fontSize' => 16,             //字号
-                                'fontColor' => '40,40,40',       //字体颜色
+                                'left' => 125,
+                                'top' => 620,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'],
+                                'fontSize' => 30,
+                                'fontColor' => '40,40,40',
                                 'angle' => 0,
                             )
                         ),
@@ -289,8 +331,21 @@ class UserBillController
                     $posterInfo = '海报生成失败:(';
                     $config = array(
                         'image' => array(
+                            // 添加头像
                             array(
-                                'url' => $urlCode,     //二维码资源
+                                'url' => $avatarUrl ?: '',     // 头像资源
+                                'stream' => 0,
+                                'left' => 125,                 // 头像位置左
+                                'top' => 300,                  // 头像位置上
+                                'right' => 0,
+                                'bottom' => 0,
+                                'width' => 120,                // 头像宽度
+                                'height' => 120,               // 头像高度
+                                'opacity' => 100,
+                                'radius' => 60                 // 圆形头像
+                            ),
+                            array(
+                                'url' => $urlCode,             // 二维码资源
                                 'stream' => 0,
                                 'left' => 195,
                                 'top' => 810,
@@ -299,38 +354,47 @@ class UserBillController
                                 'width' => 360,
                                 'height' => 360,
                                 'opacity' => 100
-                            ),
-//                            array(
-//                                'url' => $user['avatar'],     //头像资源
-//                                'stream' => 50,
-//                                'left' => 164,
-//                                'top' => 500,
-//                                'right' => 0,
-//                                'bottom' => 0,
-//                                'width' => 180,
-//                                'height' => 180,
-//                                'opacity' => 100
-//                            )
+                            )
                         ),
                         'text' => array(
+                            // 昵称放在头像旁边
                             array(
                                 'text' => $user['nickname'],
-//                                'text' => '',
-                                'left' => 140,
-                                'top' => 640,
-                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],     //字体文件
-                                'fontSize' => 50,             //字号
-                                'fontColor' => '40,40,40',       //字体颜色
+                                'left' => 260,
+                                'top' => 340,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
+                                'fontSize' => 50,
+                                'fontColor' => '40,40,40',
+                                'angle' => 0,
+                            ),
+                            // 第一行:邀请好友
+                            array(
+                                'text' => '邀请好友',
+                                'left' => 125,
+                                'top' => 450,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
+                                'fontSize' => 60,
+                                'fontColor' => '40,40,40',
+                                'angle' => 0,
+                            ),
+                            // 第二行:PIZZA
+                            array(
+                                'text' => 'PIZZA',  // 可替换为 sys_config('site_name')
+                                'left' => 125,
+                                'top' => 520,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
+                                'fontSize' => 80,
+                                'fontColor' => '40,40,40',
                                 'angle' => 0,
                             ),
+                            // 第三行:邀请您加入XX
                             array(
                                 'text' => '邀请您加入' . sys_config('site_name'),
-//                                'text' => '',
-                                'left' => 120,
-                                'top' => 720,
-                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],  // 加粗字体
-                                'fontSize' => 40,             //字号
-                                'fontColor' => '40,40,40',       //字体颜色
+                                'left' => 125,
+                                'top' => 620,
+                                'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
+                                'fontSize' => 50,
+                                'fontColor' => '40,40,40',
                                 'angle' => 0,
                             )
                         ),