修改h5显示对应省份
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user