Merge branch 'dev'
This commit is contained in:
@@ -116,7 +116,7 @@ class MpdfDriver
|
||||
return [$css, $html];
|
||||
}
|
||||
|
||||
public function exportUsedCarPdf($car)
|
||||
public function exportUsedCarPdf($car,$user,$contact)
|
||||
{
|
||||
/*$car = [
|
||||
'title' => '奥迪Q3 2013款 35 TFSI 舒适型',
|
||||
@@ -154,12 +154,35 @@ class MpdfDriver
|
||||
'default_font' => 'sun-exta'
|
||||
]);
|
||||
|
||||
$mpdf->SetProtection(//限制篡改或盗用
|
||||
['print'], // 允许的权限 copy:允许复制、print:允许打印
|
||||
'', // 用户密码(可留空)
|
||||
'Admin@2026@!#' // 拥有者密码(一定要设置)
|
||||
);
|
||||
|
||||
//设置水印
|
||||
$mpdf->SetWatermarkText(
|
||||
$user['name'] .' '. $contact,
|
||||
0.08
|
||||
);
|
||||
$mpdf->showWatermarkText = true;
|
||||
|
||||
// 1️⃣ 车辆基本信息 HTML
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
// 2️⃣ 追加附件pdf
|
||||
foreach ($car['attachment'] as $attachment) {
|
||||
$this->appendPdf($mpdf,$attachment);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$cardTpl = base_path('app/common/utils/pdf/template/contactCard.stub');
|
||||
include $cardTpl;
|
||||
$cardHtml = ob_get_clean();
|
||||
// 3️⃣ 新增一页:名片页
|
||||
$mpdf->AddPage();
|
||||
$mpdf->WriteHTML($cardHtml);
|
||||
|
||||
$pdf = $mpdf->Output('车辆详情.pdf', 'S');
|
||||
$dir = runtime_path('pdf');
|
||||
if (!is_dir($dir)) mkdir($dir, 0777, true);
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
body {
|
||||
font-family: "sun-exta";
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
border: 1px solid #e5e5e5;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.qrcode-wrap {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.qrcode-wrap img {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.tip {
|
||||
margin-top: 20px;
|
||||
font-size: 10px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>联系人名片</h2>
|
||||
|
||||
<div class="card">
|
||||
<?php if (!empty($user['name'])): ?>
|
||||
<div class="row"><span class="label">姓名:</span><?= $user['name'] ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($user['email'])): ?>
|
||||
<div class="row"><span class="label">邮箱:</span><?= $user['email'] ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($user['phone'])): ?>
|
||||
<div class="row"><span class="label">电话:</span><?= $user['phone'] ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($user['whatsapp'])): ?>
|
||||
<div class="row"><span class="label">WhatsApp:</span><?= $user['whatsapp'] ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($user['social']) && !empty($user['social_code'])): ?>
|
||||
<div class="qrcode-wrap">
|
||||
<div><?= $user['social'] ?> 二维码</div>
|
||||
<img style = "width: 270px;height: 270px;margin-top: 30px;" src="<?= $user['social_code'] ?>">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="tip">
|
||||
扫码即可联系本人 | 本资料随 PDF 自动生成
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -110,11 +110,20 @@
|
||||
|
||||
<h2>产品图</h2>
|
||||
<div class="image-list">
|
||||
<?php foreach ($car['images'] as $img): ?>
|
||||
<div class="image-item">
|
||||
<img src="<?= $img ?>">
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<table width="100%" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<?php foreach ($car['images'] as $i => $img): ?>
|
||||
<td width="50%" align="center">
|
||||
<img src="<?= $img ?>" style="width:100%; border-radius:4px;">
|
||||
</td>
|
||||
|
||||
<?php if (($i + 1) % 2 === 0): ?>
|
||||
</tr><tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user