切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
4 years ago
提交
e505e616dc4c033cc3f813c3bab6dad932b27165
1 个父辈
6bdebf07
1 个管道 的构建
通过
耗费 6 秒
职位海报修改
变更
2
构建
2
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
67 行增加
和
66 行删除
application/api/controller/v2/Index.php
application/api/controller/v2/User.php
application/api/controller/v2/Index.php
查看文件 @
e505e61
...
...
@@ -422,80 +422,82 @@ class Index extends Api
$user_id
=
$this
->
auth
->
id
>
0
?
$this
->
auth
->
id
:
0
;
$qrcode_id
=
"
{
$job_id
}
_
{
$user_id
}
"
;
$qrcode
=
$dir
.
'/qrcode_'
.
$qrcode_id
.
'.png'
;
if
(
!
file_exists
(
$qrcode
)
||
imagesx
(
imagecreatefromjpeg
(
ROOT_PATH
.
'public/'
.
$qrcode
))
!=
192
){
$user_id
=
$this
->
auth
->
id
>
0
?
$this
->
auth
->
id
:
0
;
// $qrcode_width = 192;
$qrcode_width
=
1100
;
if
(
!
file_exists
(
$qrcode
)
||
imagesx
(
imagecreatefromjpeg
(
ROOT_PATH
.
'public/'
.
$qrcode
))
!=
$qrcode_width
){
$response
=
Wechat
::
miniProgram
()
->
app_code
->
getUnlimit
(
$qrcode_id
,
[
'page'
=>
'pages/zhiwei_xq/zhiwei_xq'
,
'width'
=>
280
,
//最小宽度280
'width'
=>
$qrcode_width
,
//最小宽度280
]);
if
(
$response
instanceof
\EasyWeChat\Kernel\Http\StreamResponse
)
{
$response
->
saveAs
(
$dir
,
str_replace
(
$dir
.
'/'
,
''
,
$qrcode
));
}
// 280不满足,再缩小
\think\Image
::
open
(
$qrcode
)
->
thumb
(
192
,
192
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$qrcode
);
\think\Image
::
open
(
$qrcode
)
->
thumb
(
$qrcode_width
,
$qrcode_width
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$qrcode
);
}
//将职位图片首图保存到本地
$images
=
db
(
'job'
)
->
where
(
'id'
,
$job_id
)
->
value
(
'images'
);
$image
=
cdnurl
(
explode
(
','
,
$images
)[
0
],
true
);
// $image = 'https://recruit.brofirst.cn'.explode(',',$images)[0];
$job_image
=
$dir
.
'/image_'
.
$job_id
.
'.png'
;
file_put_contents
(
$job_image
,
file_get_contents
(
$image
));
\think\Image
::
open
(
$job_image
)
->
thumb
(
637
,
352
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$job_image
);
$path_ttf
=
ROOT_PATH
.
'public/assets/fonts/PingFang.ttf'
;
$filename
=
$dir
.
'/'
.
$job_id
.
'.png'
;
$image
=
\think\Image
::
open
(
ROOT_PATH
.
'public/assets/img/miniProgram/job_back_v2.png'
);
// 职位名称居中
$size
=
30
;
$box1
=
imagettfbbox
(
$size
,
0
,
$path_ttf
,
$job
[
'job_name'
]);
$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
;
// 工价
$size_11
=
25
;
$factory_price_total
=
'工价:'
.
$job
[
'factory_price_total'
]
.
'元/小时'
;
$box2
=
imagettfbbox
(
$size_11
,
0
,
$path_ttf
,
$factory_price_total
);
$box2_minx
=
min
(
$box2
[
0
],
$box2
[
2
],
$box2
[
4
],
$box2
[
6
]);
$box2_maxx
=
max
(
$box2
[
0
],
$box2
[
2
],
$box2
[
4
],
$box2
[
6
]);
/* 计算文字初始坐标和尺寸 */
$w
=
$box2_maxx
-
$box2_minx
;
$box2_minx
+=
$image
->
width
()
-
$w
-
106
;
// 工资
$salary
=
'工资:'
.
$job
[
'salary'
];
$box3
=
imagettfbbox
(
$size_11
,
0
,
$path_ttf
,
$salary
);
$box3_minx
=
min
(
$box3
[
0
],
$box3
[
2
],
$box3
[
4
],
$box3
[
6
]);
$box3_maxx
=
max
(
$box3
[
0
],
$box3
[
2
],
$box3
[
4
],
$box3
[
6
]);
/* 计算文字初始坐标和尺寸 */
$w
=
$box3_maxx
-
$box3_minx
;
$box3_minx
+=
$image
->
width
()
-
$w
-
106
;
// 备注居中
$last_text
=
'码上报名'
;
$box4
=
imagettfbbox
(
$size
,
0
,
$path_ttf
,
$last_text
);
$box4_minx
=
min
(
$box4
[
0
],
$box4
[
2
],
$box4
[
4
],
$box4
[
6
]);
$box4_maxx
=
max
(
$box4
[
0
],
$box4
[
2
],
$box4
[
4
],
$box4
[
6
]);
/* 计算文字初始坐标和尺寸 */
$w
=
$box4_maxx
-
$box4_minx
;
$box4_minx
+=
(
$image
->
width
()
-
$w
)
/
2
;
$image
->
water
(
$job_image
,[
25
,
25
])
->
text
(
$job
[
'job_name'
],
$path_ttf
,
$size
,
'#323233'
,[
$box1_minx
,
411
])
->
text
(
$job
[
'job_name'
],
$path_ttf
,
$size
,
'#323233'
,[
$box1_minx
+
1
,
411
])
//画两遍,加粗
->
text
(
$factory_price_total
,
$path_ttf
,
$size_11
,
'#323233'
,[
$box2_minx
,
477
])
->
text
(
$factory_price_total
,
$path_ttf
,
$size_11
,
'#323233'
,[
$box2_minx
+
1
,
477
])
->
text
(
$salary
,
$path_ttf
,
$size_11
,
'#323233'
,[
$box3_minx
,
532
])
->
text
(
$salary
,
$path_ttf
,
$size_11
,
'#323233'
,[
$box3_minx
+
1
,
532
])
->
text
(
$last_text
,
$path_ttf
,
$size
,
'#FE9515'
,[
$box4_minx
,
641
])
->
text
(
$last_text
,
$path_ttf
,
$size
,
'#FE9515'
,[
$box4_minx
+
1
,
641
])
->
water
(
$qrcode
,[
249
,
698
])
->
save
(
$filename
);
$url
=
request
()
->
domain
()
.
'/'
.
$filename
.
'?v='
.
time
();
// //将职位图片首图保存到本地
// $images = db('job')->where('id',$job_id)->value('images');
// $image = cdnurl(explode(',',$images)[0],true);
// // $image = 'https://recruit.brofirst.cn'.explode(',',$images)[0];
// $job_image = $dir.'/image_'.$job_id.'.png';
// file_put_contents($job_image,file_get_contents($image));
// \think\Image::open($job_image)->thumb(637,352,\think\Image::THUMB_CENTER)->save($job_image);
//
// $path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
// $filename = $dir.'/'.$job_id.'.png';
//
// $image = \think\Image::open(ROOT_PATH.'public/assets/img/miniProgram/job_back_v2.png');
// // 职位名称居中
// $size = 30;
// $box1 = imagettfbbox($size, 0, $path_ttf, $job['job_name']);
// $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;
//
// // 工价
// $size_11 = 25;
// $factory_price_total = '工价:'.$job['factory_price_total'].'元/小时';
// $box2 = imagettfbbox($size_11, 0, $path_ttf, $factory_price_total);
// $box2_minx = min($box2[0], $box2[2], $box2[4], $box2[6]);
// $box2_maxx = max($box2[0], $box2[2], $box2[4], $box2[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box2_maxx - $box2_minx;
// $box2_minx += $image->width() - $w - 106;
//
// // 工资
// $salary = '工资:'.$job['salary'];
// $box3 = imagettfbbox($size_11, 0, $path_ttf, $salary);
// $box3_minx = min($box3[0], $box3[2], $box3[4], $box3[6]);
// $box3_maxx = max($box3[0], $box3[2], $box3[4], $box3[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box3_maxx - $box3_minx;
// $box3_minx += $image->width() - $w - 106;
//
// // 备注居中
// $last_text = '码上报名';
// $box4 = imagettfbbox($size, 0, $path_ttf, $last_text);
// $box4_minx = min($box4[0], $box4[2], $box4[4], $box4[6]);
// $box4_maxx = max($box4[0], $box4[2], $box4[4], $box4[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box4_maxx - $box4_minx;
// $box4_minx += ($image->width() - $w) / 2;
//
// $image->water($job_image,[25,25])
// ->text($job['job_name'],$path_ttf,$size,'#323233',[$box1_minx,411])
// ->text($job['job_name'],$path_ttf,$size,'#323233',[$box1_minx+1,411]) //画两遍,加粗
// ->text($factory_price_total,$path_ttf,$size_11,'#323233',[$box2_minx,477])
// ->text($factory_price_total,$path_ttf,$size_11,'#323233',[$box2_minx+1,477])
// ->text($salary,$path_ttf,$size_11,'#323233',[$box3_minx,532])
// ->text($salary,$path_ttf,$size_11,'#323233',[$box3_minx+1,532])
// ->text($last_text,$path_ttf,$size,'#FE9515',[$box4_minx,641])
// ->text($last_text,$path_ttf,$size,'#FE9515',[$box4_minx+1,641])
// ->water($qrcode,[249,698])
// ->save($filename);
// $url = request()->domain().'/'.$filename.'?v='.time();
$url
=
request
()
->
domain
()
.
'/'
.
$qrcode
.
'?v='
.
time
();
$this
->
success
(
'成功'
,
compact
(
'url'
));
}
...
...
application/api/controller/v2/User.php
查看文件 @
e505e61
...
...
@@ -1275,7 +1275,6 @@ class User extends Api
$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
(
$qrcode_width
,
$qrcode_width
,
\think\Image
::
THUMB_CENTER
)
->
save
(
$qrcode
);
//压缩kb
}
...
...
请
注册
或
登录
后发表评论