select(); }else{ $all_area = ChinaArea::where('level','>',0)->order('level asc,sort desc,id asc')->select(); } $this->success('ok',['list'=>make_tree($all_area)]); } /** * @title 获取地址库ID获取下一级 * @desc 获取地址库ID获取下一级 * @author qc * @method GET * @url /api/area/getAreaChildrenByID * @header name:Authorization require:1 desc:Token * @param name:id type:int require:0 default:0 desc:数据表地址记录id * @return name:name type:string default:-- desc:名称 * @return name:short_name type:string default:-- desc:简称 * @return name:level type:int default:-- desc:等级(1省,2市,3区,4道) * @return name:code type:int default:-- desc:编码 * @return name:lng type:string default:-- desc:经度 * @return name:lat type:string default:-- desc:纬度 * @return name:children type:array default:-- desc:下级(数据字段同上) */ public function getAreaChildrenByID() { $id = input('id'); $list = ChinaArea::where('pid',$id)->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 获取市级地址 * @desc 获取市级地址 * @author qc * @method GET * @url /api/area/getCityByName * @header name:Authorization require:1 desc:Token * @param name:name type:string require:0 default:0 desc:市名(或拼音)模糊查询(不传查全部) * @return name:name type:string default:-- desc:名称 * @return name:short_name type:string default:-- desc:简称 */ public function getCityByName() { $where = []; $where[] = ['level','=',2]; if(input('name')) $where[] = ['name|pinyin','like','%'.input('name').'%']; $all_city = ChinaArea::field('id,name,short_name,first')->where($where)->order('sort desc,id asc')->select(); $this->success('ok',['list'=>$all_city]); } /** * @title 首字母分组获取地级市 * @desc 首字母分组获取地级市 * @author qc * @method GET * @url /api/area/getAllCity * @header name:Authorization require:1 desc:Token * @return name:first type:string default:-- desc:首字母 * @return name:city_list type:array default:-- desc:城市列表 * @return name:city_list.name type:string default:-- desc:名称 * @return name:city_list.short_name type:string default:-- desc:简称 */ public function getAllCity() { $list = ChinaArea::getAllCity(); $this->success('ok',['list'=>$list]); } }