From ad95e1d721834662f0d6bd04d869897c64804ff0 Mon Sep 17 00:00:00 2001 From: todaywindy Date: Fri, 27 Jun 2025 17:09:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/workers/Worker.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/application/admin/controller/workers/Worker.php b/application/admin/controller/workers/Worker.php index 693b903..d1b275c 100644 --- a/application/admin/controller/workers/Worker.php +++ b/application/admin/controller/workers/Worker.php @@ -134,7 +134,13 @@ class Worker extends Backend $worker_ids = []; foreach ($list->items() as $item){ $dt = $item->toArray(); - $dt['tel'] = substr($dt['tel'], 0, 3) . '****' . substr($dt['tel'], -4); + $tel = $dt['tel']; + if (preg_match('/^\d{7,}$/', $tel)) { + $dt['tel'] = mb_substr($tel, 0, 3, 'UTF-8') . '****' . mb_substr($tel, -4, null, 'UTF-8'); + } else { + // 不处理非手机号,比如中文名称 + $dt['tel'] = $tel; + } $data[] = $dt; $worker_ids [] = $item['id']; } @@ -159,8 +165,8 @@ class Worker extends Backend $result = array("total" => $list->total(), "rows" => $data); - - return json($result); +// dd($result); + return $result; }