From 2308c4cc91d5d21f5223f984be8d2ba69539e4cf Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 3 Dec 2025 14:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9h5=E6=98=BE=E7=A4=BA=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9C=81=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/admin/controllers/auto/Area.php | 17 +++++++++++------ agent/admin/controllers/auto/BaseController.php | 5 +++++ agent/admin/controllers/auto/Config.php | 8 ++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/agent/admin/controllers/auto/Area.php b/agent/admin/controllers/auto/Area.php index 190c9d45..94fd188c 100644 --- a/agent/admin/controllers/auto/Area.php +++ b/agent/admin/controllers/auto/Area.php @@ -44,7 +44,12 @@ class Area extends BaseController */ public function city_get() { - $city_rows = $this->area_model->select_groupby('city_id', [], 'firstchar asc', '', '', 'firstchar,province_name,city_id,city_name'); + $provinceIds = implode(',', self::PROVINCE_LIST); + $where = []; + if ($provinceIds) { + $where["province_id in ({$provinceIds})"] = null; + } + $city_rows = $this->area_model->select_groupby('city_id', $where, 'firstchar asc', '', '', 'firstchar,province_name,city_id,city_name'); $data = []; foreach ($city_rows as $item) { $data[$item['firstchar']][] = [ @@ -52,11 +57,11 @@ class Area extends BaseController 'city_name' => $item['city_name'] != '市辖区' ? $item['city_name'] : $item['province_name'] ]; } - foreach (range('A', 'Z') as $letter) { - if (!isset($data[$letter])) { - $data[$letter] = []; - } - } +// foreach (range('A', 'Z') as $letter) { +// if (!isset($data[$letter])) { +// $data[$letter] = []; +// } +// } ksort($data); $this->return_response_list($data); } diff --git a/agent/admin/controllers/auto/BaseController.php b/agent/admin/controllers/auto/BaseController.php index e3fe6f75..5cd42508 100644 --- a/agent/admin/controllers/auto/BaseController.php +++ b/agent/admin/controllers/auto/BaseController.php @@ -30,6 +30,11 @@ abstract class BaseController extends REST_Controller const SERVICE_PHONE = '13388887777'; const APP_ID = 1; //应用id const DEFAULT_AVATAR = 'https://img.liche.cn/liche/2025/11/77c2d0795e49dd06/e5a81f095b32724b.jpg?imageView2/2/w/200/h/200/interlace/1'; + //显示对应省份 + const PROVINCE_LIST = [ + 350000, 440000, 460000 + ]; + public function __construct() { parent::__construct(); diff --git a/agent/admin/controllers/auto/Config.php b/agent/admin/controllers/auto/Config.php index 6c0fbfe9..532bbb59 100644 --- a/agent/admin/controllers/auto/Config.php +++ b/agent/admin/controllers/auto/Config.php @@ -83,7 +83,7 @@ class Config extends BaseController $latitude = $this->input_param('latitude'); $longitude = $this->input_param('longitude'); $cityId = $this->input_param('cityId'); - if($cityId){ + if ($cityId) { $row = $this->area_model->get(['city_id' => $cityId]); if ($row) { $data = [ @@ -93,19 +93,19 @@ class Config extends BaseController 'cityName' => $row['city_name'], ]; } - }else{ + } else { if (!$latitude || !$longitude) { $this->return_json('参数错误'); } $tcGeocoder = new TcGeocoder(); $result = $tcGeocoder->reverseGeocode($latitude, $longitude); - debug_log("解析结果:".json_encode($result),'local.log'); + debug_log("解析结果:" . json_encode($result), 'local.log'); if (!$result) { $this->return_json('地址解析失败'); } $adcode = $result['ad_info']['adcode']; $row = $this->area_model->get(['county_id' => $adcode]); - if ($row) { + if ($row && in_array($row['province_id'], self::PROVINCE_LIST)) { $data = [ 'provinceId' => $row['province_id'], 'provinceName' => $row['province_name'],