|
|
@@ -161,13 +161,6 @@ 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';
|
|
|
@@ -206,25 +199,32 @@ class UserBillController
|
|
|
];
|
|
|
if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold');
|
|
|
if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal');
|
|
|
+ $avatar = $user['avatar'] ?? '';
|
|
|
+ if (empty($avatar)) { // 可选:返回错误或用默认头像
|
|
|
+ return app('json')->fail('用户头像不存在');
|
|
|
+ }
|
|
|
+ $avatarUrl = $avatar;
|
|
|
+ if (strpos($avatarUrl, 'http') !== 0) {
|
|
|
+ $avatarUrl = rtrim($siteUrl, '/') . '/' . ltrim($avatarUrl, '/');
|
|
|
+ }
|
|
|
foreach ($routineSpreadBanner as $key => &$item) {
|
|
|
$posterInfo = '海报生成失败:(';
|
|
|
$config = array(
|
|
|
'image' => array(
|
|
|
- // 添加头像
|
|
|
- array(
|
|
|
- 'url' => $avatarUrl ?: '', // 头像资源
|
|
|
+ array( // ===== 新增:圆形头像(右上位置,适配小海报) =====
|
|
|
+ 'url' => $avatarUrl,
|
|
|
'stream' => 0,
|
|
|
- 'left' => 125, // 头像位置左
|
|
|
- 'top' => 300, // 头像位置上
|
|
|
+ 'left' => 240, // 调整:与昵称对齐左边
|
|
|
+ 'top' => 720, // 调整:昵称上方,避免重叠
|
|
|
'right' => 0,
|
|
|
'bottom' => 0,
|
|
|
- 'width' => 120, // 头像宽度
|
|
|
- 'height' => 120, // 头像高度
|
|
|
+ 'width' => 70,
|
|
|
+ 'height' => 70,
|
|
|
'opacity' => 100,
|
|
|
- 'radius' => 60 // 圆形头像,半径设为宽度/高度的一半
|
|
|
+ 'circle' => true // 圆形蒙版
|
|
|
),
|
|
|
array(
|
|
|
- 'url' => $urlCode, // 二维码资源
|
|
|
+ 'url' => $urlCode, //二维码资源
|
|
|
'stream' => 0,
|
|
|
'left' => 114,
|
|
|
'top' => 790,
|
|
|
@@ -236,44 +236,22 @@ class UserBillController
|
|
|
)
|
|
|
),
|
|
|
'text' => array(
|
|
|
- // 昵称放在头像旁边
|
|
|
array(
|
|
|
'text' => $user['nickname'],
|
|
|
- 'left' => 260, // 在头像右侧
|
|
|
- 'top' => 340, // 与头像垂直居中对齐
|
|
|
+ 'left' => 250,
|
|
|
+ 'top' => 840,
|
|
|
'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], //字体文件
|
|
|
- 'fontSize' => 30, //字号
|
|
|
- 'fontColor' => '40,40,40', //字体颜色
|
|
|
+ 'fontSize' => 16, //字号
|
|
|
+ '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' => 125,
|
|
|
- 'top' => 620,
|
|
|
- 'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'],
|
|
|
- 'fontSize' => 30,
|
|
|
- 'fontColor' => '40,40,40',
|
|
|
+ 'left' => 250,
|
|
|
+ 'top' => 880,
|
|
|
+ 'fontPath' => $rootPath . 'public' . DS . $filelink['Normal'], //字体文件
|
|
|
+ 'fontSize' => 16, //字号
|
|
|
+ 'fontColor' => '40,40,40', //字体颜色
|
|
|
'angle' => 0,
|
|
|
)
|
|
|
),
|
|
|
@@ -327,25 +305,27 @@ class UserBillController
|
|
|
];
|
|
|
if (!file_exists($filelink['Bold'])) return app('json')->fail('缺少字体文件Bold');
|
|
|
if (!file_exists($filelink['Normal'])) return app('json')->fail('缺少字体文件Normal');
|
|
|
+ $avatar = $user['avatar'] ?? '';
|
|
|
+ if (empty($avatar)) {
|
|
|
+ return app('json')->fail('用户头像不存在');
|
|
|
+ }
|
|
|
+ $avatarUrl = $avatar;
|
|
|
+ if (strpos($avatarUrl, 'http') !== 0) {
|
|
|
+ $avatarUrl = rtrim($siteUrl, '/', '\\') . '/' . ltrim($avatarUrl, '/');
|
|
|
+ }
|
|
|
foreach ($routineSpreadBanner as $key => &$item) {
|
|
|
$posterInfo = '海报生成失败:(';
|
|
|
$config = array(
|
|
|
+ array( // ===== 新增:圆形头像(左上位置,适配大海报) =====
|
|
|
+ 'url' => $avatarUrl, 'stream' => 0, 'left' => 120, // 调整:与文字对齐
|
|
|
+ 'top' => 50, // 调整:海报顶部
|
|
|
+ 'right' => 0,
|
|
|
+ 'bottom' => 0, 'width' => 150, 'height' => 150,
|
|
|
+ 'opacity' => 100, 'circle' => true // 圆形蒙版
|
|
|
+ ),
|
|
|
'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' => 195,
|
|
|
'top' => 810,
|
|
|
@@ -354,47 +334,27 @@ class UserBillController
|
|
|
'width' => 360,
|
|
|
'height' => 360,
|
|
|
'opacity' => 100
|
|
|
- )
|
|
|
+ ),
|
|
|
),
|
|
|
'text' => array(
|
|
|
- // 昵称放在头像旁边
|
|
|
array(
|
|
|
'text' => $user['nickname'],
|
|
|
- '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',
|
|
|
+// 'text' => '',
|
|
|
+ 'left' => 140,
|
|
|
+ 'top' => 640,
|
|
|
+ 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], //字体文件
|
|
|
+ 'fontSize' => 50, //字号
|
|
|
+ 'fontColor' => '40,40,40', //字体颜色
|
|
|
'angle' => 0,
|
|
|
),
|
|
|
- // 第三行:邀请您加入XX
|
|
|
array(
|
|
|
'text' => '邀请您加入' . sys_config('site_name'),
|
|
|
- 'left' => 125,
|
|
|
- 'top' => 620,
|
|
|
- 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'],
|
|
|
- 'fontSize' => 50,
|
|
|
- 'fontColor' => '40,40,40',
|
|
|
+// 'text' => '',
|
|
|
+ 'left' => 120,
|
|
|
+ 'top' => 720,
|
|
|
+ 'fontPath' => $rootPath . 'public' . DS . $filelink['Bold'], // 加粗字体
|
|
|
+ 'fontSize' => 40, //字号
|
|
|
+ 'fontColor' => '40,40,40', //字体颜色
|
|
|
'angle' => 0,
|
|
|
)
|
|
|
),
|