切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
macbook
4 years ago
提交
7ee27f972951ccc68b1926c10a036a442f0fa1c7
1 个父辈
981fecc0
1 个管道 的构建
通过
耗费 27 秒
个人海报优化
变更
2
构建
2
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
10 行增加
和
10 行删除
application/api/controller/v2/User.php
public/assets/img/miniProgram/user_back_v2.png
application/api/controller/v2/User.php
查看文件 @
7ee27f9
...
...
@@ -1261,43 +1261,43 @@ class User extends Api
if
(
!
file_exists
(
$dir
)){
mkdir
(
$dir
,
0777
,
true
);
}
// 用户小程序码
$qrcode
=
$dir
.
'/qrcode_'
.
$user
[
'id'
]
.
'.png'
;
if
(
!
file_exists
(
$qrcode
)){
if
(
!
file_exists
(
$qrcode
)
||
imagesx
(
imagecreatefromjpeg
(
ROOT_PATH
.
'public/'
.
$qrcode
))
!=
338
){
$response
=
Wechat
::
miniProgram
()
->
app_code
->
getUnlimit
(
$user
[
'id'
],
[
'page'
=>
'pages/indexone/indexone'
,
'width'
=>
280
,
//最小宽度280
'width'
=>
338
,
//最小宽度280
]);
if
(
$response
instanceof
\EasyWeChat\Kernel\Http\StreamResponse
)
{
$response
->
saveAs
(
$dir
,
str_replace
(
$dir
.
'/'
,
''
,
$qrcode
));
}
// 280不满足,再缩小
\think\Image
::
open
(
$qrcode
)
->
thumb
(
169
,
169
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$qrcode
);
//
\think\Image::open($qrcode)->thumb(169,169,\think\Image::THUMB_CENTER)->save($qrcode);
}
//将用户头像保存到本地
$avatar
=
$dir
.
'/avatar_'
.
$user
[
'id'
]
.
'.png'
;
file_put_contents
(
$avatar
,
file_get_contents
(
$user
[
'avatar'
]));
\think\Image
::
open
(
$avatar
)
->
thumb
(
64
,
64
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$avatar
);
\think\Image
::
open
(
$avatar
)
->
thumb
(
128
,
128
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$avatar
);
createRoundImg
(
$avatar
);
$path_ttf
=
ROOT_PATH
.
'public/assets/fonts/PingFang.ttf'
;
$filename
=
$dir
.
'/'
.
$user
[
'id'
]
.
'.png'
;
$image
=
\think\Image
::
open
(
ROOT_PATH
.
'public/assets/img/miniProgram/user_back.png'
);
$image
=
\think\Image
::
open
(
ROOT_PATH
.
'public/assets/img/miniProgram/user_back
_v2
.png'
);
// 昵称居中
$nickname
=
$user
[
'nickname'
];
$size
=
12
;
$size
=
30
;
$box1
=
imagettfbbox
(
$size
,
0
,
$path_ttf
,
$nickname
);
$box1_minx
=
min
(
$box1
[
0
],
$box1
[
2
],
$box1
[
4
],
$box1
[
6
]);
$box1_maxx
=
max
(
$box1
[
0
],
$box1
[
2
],
$box1
[
4
],
$box1
[
6
]);
/* 计算文字初始坐标和尺寸 */
$w
=
$box1_maxx
-
$box1_minx
;
$box1_minx
+=
(
$image
->
width
()
-
$w
)
/
2
;
$image
->
water
(
$avatar
,[
156
,
52
])
->
text
(
$nickname
,
$path_ttf
,
$size
,
'#020202'
,[
$box1_minx
,
131
])
->
water
(
$qrcode
,[
103
,
181
])
$image
->
water
(
$avatar
,[
312
,
104
])
->
text
(
$nickname
,
$path_ttf
,
$size
,
'#020202'
,[
$box1_minx
,
262
])
->
water
(
$qrcode
,[
206
,
362
])
->
save
(
$filename
);
$url
=
request
()
->
domain
()
.
'/'
.
$filename
.
'?v='
.
time
();
$this
->
success
(
'成功'
,
compact
(
'url'
));
...
...
public/assets/img/miniProgram/user_back_v2.png
0 → 100644
查看文件 @
7ee27f9
747 字节
请
注册
或
登录
后发表评论