suiyi-erff 2 년 전
부모
커밋
ca971a1f5c
2개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 1
    1
      application/admin/controller/District.php
  2. 9
    3
      application/admin/model/District.php

+ 1
- 1
application/admin/controller/District.php 파일 보기

@@ -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 파일 보기

@@ -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;

Loading…
취소
저장