<script type="text/java script" src="https://api.map.baidu.com/api?v=2.0&ak='自己申请'&s=1"></script> <script type="text/java script" charset="utf-8"> var geolocation = new BMap.Geolocation(); geolocation.getCurrentPosition(function (r) { if (this.getStatus() == BMAP_STATUS_SUCCESS) { var lat = r.point.lat; var lng = r.point.lng; } // return; var data = {'lat': lat, 'merchid': "{$item['id']}",'classid': "{$classitem['id']}", 'lng': lng}; $.ajax({ url: "{php echo mobileUrl('shop/category/ajaxcodot')}", data: data, cache: false }).done(function (result) { var data = jQuery.parseJSON(result); if (data.status == 1) { if(data.result.code == 1){ console.log(data.result.code) $(".shop").html(data.result.html) // $("#coll").hide() }else{ $(".shop").hide() $(".noinfo").show() } } else { alert("微信接口繁忙,请稍后再试!"); } }); }) </script>
public function ajaxdot()//查询结果页 { global $_W; global $_GPC; $province = $_GPC['province']; $city = $_GPC['city']; $area = $_GPC['area']; $classid = $_GPC['classid']; $lat = floatval($_GPC['lat']); $lng = floatval($_GPC['lng']); $merch = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_merch_user') . ' WHERE id = '.$_GPC['merchid']); $where = 'where 1'; $where.= " and province = '$province'"; if($merch['cateid'] != 6) $where.= " and company_number = '{$merch['company_number']}'"; if(!empty($city)){ $where.= " and city = '$city'"; } if(!empty($area)){ $where.= " and area = '$area'"; } if($merch['cateid'] == 1 && $classid){ // var_dump($classid);exit; $class = pdo_fetch('SELECT class_type FROM ' . tablename('ewei_shop_merch_user_class') . ' WHERE id = '.$classid); $class_type = $class['class_type']; $where.= " and class_type = '$class_type'"; } if(!empty($_GPC['classid'])){ $classitem = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_merch_user_class') . ' WHERE id = :classid',array('classid' => $_GPC['classid'])); } $table = tablename('ewei_shop_merch_user_address'); if($merch['cateid'] == 6){ if($merch['company_number'] == 'TXDX001'){ $where.= " and class_type = 'DX'"; }else if($merch['company_number'] == 'TXDX002'){ $where.= " and class_type = 'YD'"; }else if($merch['company_number'] == 'TXDX003'){ $where.= " and class_type = 'LT'"; } $table =tablename('ewei_shop_merch_tx_address'); } $detail = pdo_fetchall("SELECT * FROM $table " ."$where"); // var_dump($detail); if($detail){ $html = ''; foreach ($detail as $key=>$v) { if($v['lat'] == '' || $v['lng'] == ''){ $lntarr = $this->addresstolatlag($v['detail']); $store['lng'] = $lntarr[0]; $store['lat'] = $lntarr[1]; // var_dump($lntarr); $lat_num = explode('.', $store['lat']); if (1 < sizeof($lat_num)) { $decimal = end($lat_num); $count = strlen($decimal); if ($count <= 6) { $gcj02 = $this->Convert_GCJ02_To_BD09($store['lat'], $store['lng']); $store['lat'] = $gcj02['lat']; $store['lng'] = $g