['except' => ['province','city','area','street','village','brigade'] ] ]; /** * 省 */ public function province(){ $res = Db::table('fa_geo_province')->where(['switch'=>1]) ->field('province_id id,province_code code,province_name name') ->select(); $this->apiSuccess('OK',$res); } /** * 市 */ public function city(){ $pcode = get_params('pcode'); // $pcode = '130000'; if(!$pcode) $this->apiError('请先选择省份'); $res = Db::table('fa_geo_city')->where(['switch'=>1,'province_code'=>$pcode]) ->field('city_id id,city_code code,city_name name') ->select(); $this->apiSuccess('OK',$res); } /** * 区 */ public function area(){ $pcode = get_params('pcode'); // $pcode = '140100'; if(!$pcode) $this->apiError('请先选择城市'); $res = Db::table('fa_geo_area')->where(['switch'=>1,'city_code'=>$pcode]) ->field('area_id id,area_code code,area_name name') ->select(); $this->apiSuccess('OK',$res); } /** * 街道 */ public function street(){ $pcode = get_params('pcode'); // $pcode = '410102'; if(!$pcode) $this->apiError('请先选择区/县'); $res = Db::table('fa_geo_street')->where(['switch'=>1,'area_code'=>$pcode]) ->field('street_id id,street_code code,street_name name') ->select(); $this->apiSuccess('OK',$res); } /** * 村 */ public function village(){ $pcode = get_params('pcode'); // $pcode = '410102'; if(!$pcode) $this->apiError('请先选择镇/街道'); $res = Db::table('fa_geo_village')->where(['switch'=>1,'street_code'=>$pcode]) ->field('village_id id,village_code code,village_name name') ->select(); $this->apiSuccess('OK',$res); } /** * 大队 */ public function brigade(){ $res = Db::table('fa_geo_brigade') ->select(); $this->apiSuccess('OK',$res); } }