在CSDN购买了一个外卖人9.1的源码
布置之后其他功能基本正常
就是有一个切换城市的功能
无论添加什么城市,切换的时候他都显示当前城市未开通
//根据经纬坐标获取所在地区信息
function get_areainfo($lng,$lat){
$arealist = $this->mysql->getarr("select lng,lat,name,adcode from ".Mysite::$app->config['tablepre']."area where id > 0 and adcode > 0 order by orderid asc ");
$areaarray = array();
if( !empty($arealist) ){
foreach($arealist as $key=>$arevl){
$waimai_psrange = '';
$platpsinfo = $this->mysql->select_one("select * from ".Mysite::$app->config['tablepre']."platpsset where cityid='".$arevl['adcode']."' ");
if( !empty($platpsinfo) ){
$waimai_psrange = $platpsinfo['waimai_psrange'];
if(!empty($waimai_psrange)){
$psrangeinfo = explode('#',$waimai_psrange);
$ddata = array();
if( !empty($psrangeinfo) ){
foreach($psrangeinfo as $key=>$val){
if( !empty($val) ){
$adata = array();
$tem = explode('@',$val);
foreach($tem as $k=>$v){
if(!empty($v)){
$tempbb = explode(',',$v);
$cnew = array('lng'=>$tempbb[1],'lat'=>$tempbb[0]);
$adata[] = $cnew;
}
}
if(count($adata) > 0){
$ddata[] = $adata;
}
}
}
}
if(!empty($ddata)){
$result = $this->pointInPolygon($ddata,$lat,$lng);
if( $result ){
$areaarray = $arevl;
break;
}
}
}
}
}
}
return $areaarray;
}
//根据经纬坐标获取所在分站
function getchoiceadcode(){
$lnglat = trim(IFilter::act(IReq::get('lnglat')));
$address = trim(IFilter::act(IReq::get('address')));
if( empty($lnglat) ){
$this->message('获取位置坐标失败请重新获取');
}
$lnglatarr = explode(',',$lnglat);
$lng = $lnglatarr[0];
$lat = $lnglatarr[1];
if( !empty($lng) && !empty($lat) ){
$areainfo = array();
$areainfo['areainfo'] = $this->get_areainfo($lng,$lat);
if( empty($areainfo['areainfo']) ){
$this->message('当前城市暂未开通');
}else{
if( !empty($address) ){
ICookie::set('lat',$lat,86400*365*10);
ICookie::set('lng',$lng,86400*365*10);
ICookie::set('addressname',$address,86400*365*10);
ICookie::set('mapname',$address,86400*365*10);
$city_id = "CITY_ID_".$areainfo['areainfo']['adcode'];
$city_name = "CITY_NAME_".$areainfo['areainfo']['name'];
ICookie::set('CITY_ID',$city_id,86400*365*10);
ICookie::set('CITY_NAME',$city_name,86400*365*10);
}
$this->success($areainfo);
}
}else{
$this->message('获取位置坐标失败请重新获取');
}
}