| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /**
- * 流程单二维码落地页:微信扫描打开,展示工单信息。
- * 访问:/psqr.php?d=...
- */
- header('Content-Type: text/html; charset=utf-8');
- $data = [];
- $k = isset($_GET['k']) ? preg_replace('/[^a-fA-F0-9]/', '', (string)$_GET['k']) : '';
- if ($k !== '') {
- $files = [
- dirname(__DIR__) . '/runtime/psqr/' . $k . '.json',
- __DIR__ . '/uploads/psqr/' . $k . '.json',
- ];
- foreach ($files as $file) {
- if (is_file($file)) {
- $tmp = json_decode((string)file_get_contents($file), true);
- if (is_array($tmp)) {
- $data = $tmp;
- break;
- }
- }
- }
- }
- $raw = isset($_GET['d']) ? (string)$_GET['d'] : '';
- if (!$data && $raw !== '') {
- $pad = strtr($raw, '-_', '+/');
- $mod = strlen($pad) % 4;
- if ($mod) {
- $pad .= str_repeat('=', 4 - $mod);
- }
- $json = base64_decode($pad, true);
- $tmp = $json !== false ? json_decode($json, true) : null;
- if (is_array($tmp)) {
- $data = $tmp;
- }
- }
- $h = function ($key) use ($data) {
- $v = isset($data[$key]) ? (string)$data[$key] : '';
- if (function_exists('mb_substr')) {
- $v = mb_substr($v, 0, 80, 'UTF-8');
- }
- return htmlspecialchars($v, ENT_QUOTES, 'UTF-8');
- };
- $no = $h('no');
- $name = $h('name');
- $qty = $h('qty');
- $plate = $h('plate');
- $total = $h('total');
- $cur = $h('cur');
- $title = $no !== '' ? $no : '流程单';
- ?>
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
- <meta name="format-detection" content="telephone=no">
- <title><?php echo $title; ?> · 流程单</title>
- <style>
- * { box-sizing: border-box; }
- body {
- margin: 0;
- background: #e8eee4;
- font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
- color: #1a2a1a;
- }
- .card {
- max-width: 420px;
- margin: 24px auto;
- background: #fff;
- border: 4px solid #2f7a3a;
- border-radius: 8px;
- overflow: hidden;
- box-shadow: 0 8px 24px rgba(20, 60, 30, 0.12);
- }
- .hd {
- background: #2f7a3a;
- color: #fff;
- padding: 16px 18px 14px;
- }
- .hd h1 { margin: 0; font-size: 18px; font-weight: 700; }
- .hd p { margin: 6px 0 0; font-size: 13px; opacity: .9; }
- dl { margin: 0; padding: 8px 0 16px; }
- dt {
- padding: 10px 18px 0;
- font-size: 12px;
- color: #6a7a6a;
- }
- dd {
- margin: 0;
- padding: 4px 18px 10px;
- font-size: 17px;
- font-weight: 600;
- line-height: 1.45;
- border-bottom: 1px solid #eef3ee;
- word-break: break-all;
- }
- dd:last-child { border-bottom: 0; }
- .empty { padding: 40px 20px; text-align: center; color: #888; }
- </style>
- </head>
- <body>
- <div class="card">
- <div class="hd">
- <h1>产品工序流程卡</h1>
- <p>扫码查看本张流程单信息</p>
- </div>
- <?php if ($no === '' && $name === '') { ?>
- <div class="empty">二维码内容无效</div>
- <?php } else { ?>
- <dl>
- <dt>工单编号</dt><dd><?php echo $no !== '' ? $no : '—'; ?></dd>
- <dt>名称</dt><dd><?php echo $name !== '' ? $name : '—'; ?></dd>
- <dt>总数量</dt><dd><?php echo $qty !== '' ? $qty : '—'; ?></dd>
- <dt>每版</dt><dd><?php echo $plate !== '' ? $plate : '—'; ?></dd>
- <dt>总流程</dt><dd><?php echo $total !== '' ? $total : '—'; ?></dd>
- <dt>当前流程号</dt><dd><?php echo $cur !== '' ? $cur : '—'; ?></dd>
- </dl>
- <?php } ?>
- </div>
- </body>
- </html>
|