edit-api-area
This commit is contained in:
@@ -23,46 +23,42 @@ class Aptinfo extends Wxapp{
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
$this->load->model('area_model');
|
||||
$this->load->model("sys/sys_city_model");
|
||||
$this->load->model('sys/sys_area_model');
|
||||
|
||||
$city_code = $this->input_param('c_code');
|
||||
$cms_id = $this->input_param('cms_id');
|
||||
|
||||
!$city_code && $city_code = 350206;
|
||||
$citys = $this->sys_city_model->select(['status'=>1],'','','','city_id,name');
|
||||
|
||||
//获取城市
|
||||
$citys = ['350200','350800'];
|
||||
$city_ids = implode(',',$citys);
|
||||
$where["city_id in ({$city_ids})"] = null;
|
||||
$fileds = 'id,city_id,city_name,county_id,county_name';
|
||||
$county_rows = $this->area_model->map('city_id','',$where,'','','',$fileds);
|
||||
$city_list = $county_list = [];
|
||||
foreach($citys as $val){
|
||||
$city_list[] = [
|
||||
'id' => $val,
|
||||
'parid' => 1,
|
||||
'name' => $county_rows[$val][0]['city_name'],
|
||||
'regtype' => 1
|
||||
];
|
||||
if($county_rows){
|
||||
foreach($county_rows[$val] as $val2){
|
||||
$county_list[] = [
|
||||
'id' => $val2['county_id'],
|
||||
'parid' => $val2['city_id'],
|
||||
'name' => $val2['county_name'],
|
||||
$city_list = [];
|
||||
foreach($citys as $key=>$val){
|
||||
$areas = $this->sys_area_model->select(['city_id'=>$val['city_id'],'status'=>1],'','','','county_id,county_name');
|
||||
if($areas){
|
||||
$city_list[] = [
|
||||
'id' => $val['city_id'],
|
||||
'parid' => 1,
|
||||
'name' => $val['name'],
|
||||
'regtype' => 1
|
||||
];
|
||||
foreach($areas as $k1=>$v1){
|
||||
$city_list[] = [
|
||||
'id' => $v1['county_id'],
|
||||
'parid' => $val['city_id'],
|
||||
'name' => $v1['county_name'],
|
||||
'regtype' => 2
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
//获取默认选中地区
|
||||
$city_row = $this->area_model->get(['county_id'=>$city_code]);
|
||||
$city_row = $this->sys_area_model->get(['county_id'=>$city_code,'status'=>1]);
|
||||
if(!$city_row){
|
||||
$city_row = $this->area_model->get(['county_id'=>350206]);
|
||||
}
|
||||
$city_row = $this->sys_area_model->get(['county_id'=>350206,'status'=>1]);
|
||||
}
|
||||
$default = $city_row['city_name'].'/'.$city_row['county_name'];
|
||||
|
||||
$c_list = array_merge($city_list,$county_list);
|
||||
//获取背景图
|
||||
$img = 'https://qs.haodian.cn/wechat_app/liche/buyCar/ex-default.jpg';
|
||||
if($cms_id){
|
||||
@@ -71,7 +67,7 @@ class Aptinfo extends Wxapp{
|
||||
$json['bg_img'] && $img = build_qiniu_image_url($json['bg_img']);
|
||||
}
|
||||
$data = [
|
||||
'city_list' => $c_list,
|
||||
'city_list' => $city_list,
|
||||
'def_city' => $default,
|
||||
'img' => $img,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user