suiyi-erff vor 2 Jahren
Ursprung
Commit
ca971a1f5c
2 geänderte Dateien mit 10 neuen und 4 gelöschten Zeilen
  1. 1
    1
      application/admin/controller/District.php
  2. 9
    3
      application/admin/model/District.php

+ 1
- 1
application/admin/controller/District.php Datei anzeigen

@@ -27,7 +27,7 @@ class District extends BaseController
// }

public function province()
{
{ //获取城市接口地址
try {
$District_model = new \app\admin\model\District();
$result = $District_model->province();

+ 9
- 3
application/admin/model/District.php Datei anzeigen

@@ -20,15 +20,21 @@ class District extends Model

public function getChildren($adcode)
{

return $this->where('parent_id', $adcode)->field('adcode as value,name as label')->select();
}

public function province()
{
$result = $this->where('level', '1')->field('adcode as value,name as label')->select();
//$result = $this->where('level','1')->field('adcode as value,name as label')->select();
$result = $this->where('level','1')->where('level','2')->field('adcode as value,name as label')->select();
foreach ($result as $k => $v) {
$result[$k]['children'] = $this->getChildren($v['value']);
//市
if($v['value']==1) {
$result[$k]['children'] = $this->getChildren($v['value']);
}elseif($v['value']==2){
//区
$result[$k]['District'] = $this->getChildren($v['value']);
}
}
$result = ['rows' => $result];
return $result;

Laden…
Abbrechen
Speichern