From 3a8c7f2cf762c35c012f5ddd27668e234475a129 Mon Sep 17 00:00:00 2001 From: devil Date: Mon, 14 Sep 2020 22:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/ConfigService.php | 18 ----- application/service/OrderService.php | 15 ----- application/service/UserService.php | 15 ----- sourcecode/weixin/app.js | 67 +++++++++++++------ sourcecode/weixin/pages/buy/buy.js | 13 ++-- .../extraction-address/extraction-address.js | 17 ++--- .../distribution/extraction/extraction.js | 15 ++--- .../user-order-detail/user-order-detail.js | 15 ++--- 8 files changed, 65 insertions(+), 110 deletions(-) diff --git a/application/service/ConfigService.php b/application/service/ConfigService.php index 10d236169..ca914a300 100755 --- a/application/service/ConfigService.php +++ b/application/service/ConfigService.php @@ -336,24 +336,6 @@ class ConfigService } } - // 坐标处理 - if(!empty($data) && is_array($data) && in_array(APPLICATION_CLIENT_TYPE, config('shopxo.coordinate_transformation'))) - { - foreach($data as &$v) - { - // 坐标转换 百度转火星(高德,谷歌,腾讯坐标) - if(isset($v['lng']) && isset($v['lat'])) - { - $map = \base\GeoTransUtil::BdToGcj($v['lng'], $v['lat']); - if(isset($map['lng']) && isset($map['lat'])) - { - $v['lng'] = $map['lng']; - $v['lat'] = $map['lat']; - } - } - } - } - // 自提点地址列表数据钩子 $hook_name = 'plugins_service_site_extraction_address_list'; Hook::listen($hook_name, [ diff --git a/application/service/OrderService.php b/application/service/OrderService.php index dad109fdd..7f14b52db 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -1317,21 +1317,6 @@ class OrderService { // 销售模式+自提模式 地址信息 $data = Db::name('OrderAddress')->where(['order_id'=>$order_id])->find(); - - // 坐标处理 - if(!empty($data) && is_array($data) && in_array(APPLICATION_CLIENT_TYPE, config('shopxo.coordinate_transformation'))) - { - // 坐标转换 百度转火星(高德,谷歌,腾讯坐标) - if(isset($data['lng']) && isset($data['lat'])) - { - $map = \base\GeoTransUtil::BdToGcj($data['lng'], $data['lat']); - if(isset($map['lng']) && isset($map['lat'])) - { - $data['lng'] = $map['lng']; - $data['lat'] = $map['lat']; - } - } - } return empty($data) ? [] : $data; } diff --git a/application/service/UserService.php b/application/service/UserService.php index c978a6b2d..b39dbd91a 100755 --- a/application/service/UserService.php +++ b/application/service/UserService.php @@ -418,21 +418,6 @@ class UserService $is_default = false; foreach($data as &$v) { - // 坐标处理 - if(in_array(APPLICATION_CLIENT_TYPE, config('shopxo.coordinate_transformation'))) - { - // 坐标转换 百度转火星(高德,谷歌,腾讯坐标) - if(isset($v['lng']) && isset($v['lat'])) - { - $map = \base\GeoTransUtil::BdToGcj($v['lng'], $v['lat']); - if(isset($map['lng']) && isset($map['lat'])) - { - $v['lng'] = $map['lng']; - $v['lat'] = $map['lat']; - } - } - } - // 地区 $v['province_name'] = RegionService::RegionName($v['province']); $v['city_name'] = RegionService::RegionName($v['city']); diff --git a/sourcecode/weixin/app.js b/sourcecode/weixin/app.js index 585a8ee1c..10a2c5e46 100755 --- a/sourcecode/weixin/app.js +++ b/sourcecode/weixin/app.js @@ -68,7 +68,7 @@ App({ // 请求地址 request_url: "{{request_url}}", request_url: 'http://shopxo.com/', - // request_url: 'https://dev.shopxo.net/', + request_url: 'https://dev.shopxo.net/', // 基础信息 application_title: "{{application_title}}", @@ -531,14 +531,7 @@ App({ this.showToast('事件值格式有误'); return false; } - - var map = this.BMapTransqqMap(parseFloat(values[2]), parseFloat(values[3])); - wx.openLocation({ - name: values[0], - address: values[1], - longitude: map.lng, - latitude: map.lat - }); + this.open_location(values[2], values[3], values[0], values[1]); break; // 拨打电话 @@ -802,18 +795,48 @@ App({ }, 100); }, - BMapTransqqMap(lng, lat) { -   let x_pi = 3.14159265358979324 * 3000.0 / 180.0; -   let x = lng - 0.0065; -   let y = lat - 0.006; -   let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); -   let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); -   let lngs = z * Math.cos(theta); -   let lats = z * Math.sin(theta); -   return { -     lng: lngs, -     lat: lats -   }; - }, + /** + * 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标) + * object 回调操作对象 + * method 回调操作对象的函数 + */ + map_bd_to_gcj(lng, lat) { +   let x_pi = 3.14159265358979324 * 3000.0 / 180.0; +   let x = lng - 0.0065; +   let y = lat - 0.006; +   let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); +   let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); +   let lngs = z * Math.cos(theta); +   let lats = z * Math.sin(theta); +   return { +     lng: lngs, +     lat: lats +   }; + }, + + /** + * 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标) + * lng 经度 + * lat 纬度 + * name 地图上面显示的名称 + * address 地图上面显示的详细地址 + * scale 缩放比例,范围5~18 + */ + open_location(lng, lat, name, address, scale) { + if(lng == undefined || lat == undefined || lng == '' || lat == '') { + this.showToast('坐标有误'); + return false; + } + + // 转换坐标打开位置 + var position = this.map_bd_to_gcj(parseFloat(lng), parseFloat(lat)); + wx.openLocation({ + name: name || '', + address: address || '', + scale: scale || 18, + longitude: position.lng, + latitude: position.lat + }); + }, }); \ No newline at end of file diff --git a/sourcecode/weixin/pages/buy/buy.js b/sourcecode/weixin/pages/buy/buy.js index 4413a1766..a878bd446 100755 --- a/sourcecode/weixin/pages/buy/buy.js +++ b/sourcecode/weixin/pages/buy/buy.js @@ -365,14 +365,9 @@ Page({ return false; } - var lng = parseFloat(data.lng || 0); - var lat = parseFloat(data.lat || 0); - wx.openLocation({ - latitude: lat, - longitude: lng, - scale: 18, - name: data.name || data.alias || '', - address: (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || ''), - }); + // 打开地图 + var name = data.name || data.alias || ''; + var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || ''); + app.open_location(data.lng, data.lat, name, address); }, }); diff --git a/sourcecode/weixin/pages/extraction-address/extraction-address.js b/sourcecode/weixin/pages/extraction-address/extraction-address.js index fa562ea97..cfea8fa21 100644 --- a/sourcecode/weixin/pages/extraction-address/extraction-address.js +++ b/sourcecode/weixin/pages/extraction-address/extraction-address.js @@ -107,22 +107,17 @@ Page({ // 地图查看 address_map_event(e) { var index = e.currentTarget.dataset.index || 0; - var ads = this.data.data_list[index] || null; - if (ads == null) + var data = this.data.data_list[index] || null; + if (data == null) { app.showToast("地址有误"); return false; } - var lng = parseFloat(ads.lng || 0); - var lat = parseFloat(ads.lat || 0); - wx.openLocation({ - latitude: lat, - longitude: lng, - scale: 18, - name: ads.alias || '', - address: (ads.province_name || '') + (ads.city_name || '') + (ads.county_name || '') + (ads.address || ''), - }); + // 打开地图 + var name = data.alias || ''; + var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || ''); + app.open_location(data.lng, data.lat, name, address); }, // 地址内容事件 diff --git a/sourcecode/weixin/pages/plugins/distribution/extraction/extraction.js b/sourcecode/weixin/pages/plugins/distribution/extraction/extraction.js index cfea4f246..2bc3915be 100644 --- a/sourcecode/weixin/pages/plugins/distribution/extraction/extraction.js +++ b/sourcecode/weixin/pages/plugins/distribution/extraction/extraction.js @@ -91,17 +91,12 @@ Page({ if ((this.data.extraction || null) == null) { return false; } + var data = this.data.extraction; - var ads = this.data.extraction; - var lng = parseFloat(ads.lng || 0); - var lat = parseFloat(ads.lat || 0); - wx.openLocation({ - latitude: lat, - longitude: lng, - scale: 18, - name: ads.alias || '', - address: (ads.province_name || '') + (ads.city_name || '') + (ads.county_name || '') + (ads.address || ''), - }); + // 打开地图 + var name = data.alias || ''; + var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || ''); + app.open_location(data.lng, data.lat, name, address); }, // 进入取货订单管理 diff --git a/sourcecode/weixin/pages/user-order-detail/user-order-detail.js b/sourcecode/weixin/pages/user-order-detail/user-order-detail.js index 09f255f0c..5aaff8fb4 100755 --- a/sourcecode/weixin/pages/user-order-detail/user-order-detail.js +++ b/sourcecode/weixin/pages/user-order-detail/user-order-detail.js @@ -124,17 +124,12 @@ Page({ app.showToast("地址有误"); return false; } + var data = this.data.detail.address_data; - var ads = this.data.detail.address_data; - var lng = parseFloat(ads.lng || 0); - var lat = parseFloat(ads.lat || 0); - wx.openLocation({ - latitude: lat, - longitude: lng, - scale: 18, - name: ads.alias || '', - address: (ads.province_name || '') + (ads.city_name || '') + (ads.county_name || '') + (ads.address || ''), - }); + // 打开地图 + var name = data.alias || ''; + var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || ''); + app.open_location(data.lng, data.lat, name, address); }, // 下拉刷新