diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index ce2e2b4ee..e88a5938a 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -506,9 +506,9 @@ class SystemController extends AbstractController if (is_array($all['modes'])) { if (in_array('locat', $all['modes'])) { $mapTypes = [ - 'baidu' => ['key' => 'locat_bd_lbs_key', 'point' => 'locat_bd_lbs_point', 'msg' => '请填写百度地图AK'], - 'amap' => ['key' => 'locat_amap_key', 'point' => 'locat_amap_point', 'msg' => '请填写高德地图Key'], - 'tencent' => ['key' => 'locat_tencent_key', 'point' => 'locat_tencent_point', 'msg' => '请填写腾讯地图Key'], + 'baidu' => ['key' => 'locat_bd_lbs_key', 'point' => 'locat_bd_lbs_point', 'msg' => '请填写百度地图AK'], + 'amap' => ['key' => 'locat_amap_key', 'point' => 'locat_amap_point', 'msg' => '请填写高德地图Key'], + 'tencent' => ['key' => 'locat_tencent_key', 'point' => 'locat_tencent_point', 'msg' => '请填写腾讯地图Key'], ]; $type = $all['locat_map_type']; if (!isset($mapTypes[$type])) { diff --git a/app/Models/UserBot.php b/app/Models/UserBot.php index cbd4ff42a..b1c4c38e1 100644 --- a/app/Models/UserBot.php +++ b/app/Models/UserBot.php @@ -103,16 +103,27 @@ class UserBot extends AbstractModel return $menu; } if (in_array('locat', $setting['modes']) && Base::isEEUIApp()) { - $menu[] = [ - 'key' => 'locat-checkin', - 'label' => Doo::translate('定位签到'), - 'config' => [ - 'key' => $setting['locat_bd_lbs_key'], - 'lng' => $setting['locat_bd_lbs_point']['lng'], - 'lat' => $setting['locat_bd_lbs_point']['lat'], - 'radius' => $setting['locat_bd_lbs_point']['radius'], - ] + $mapTypes = [ + 'baidu' => ['key' => 'locat_bd_lbs_key', 'point' => 'locat_bd_lbs_point', 'msg' => '请填写百度地图AK'], + 'amap' => ['key' => 'locat_amap_key', 'point' => 'locat_amap_point', 'msg' => '请填写高德地图Key'], + 'tencent' => ['key' => 'locat_tencent_key', 'point' => 'locat_tencent_point', 'msg' => '请填写腾讯地图Key'], ]; + $type = $setting['locat_map_type']; + if (isset($mapTypes[$type])) { + $conf = $mapTypes[$type]; + $point = $setting[$conf['point']]; + $menu[] = [ + 'key' => 'locat-checkin', + 'label' => Doo::translate('定位签到'), + 'config' => [ + 'type' => $type, + 'key' => $setting[$conf['key']], + 'lng' => $point['lng'], + 'lat' => $point['lat'], + 'radius' => intval($point['radius']), + ] + ]; + } } if (in_array('manual', $setting['modes'])) { $menu[] = [ @@ -234,7 +245,7 @@ class UserBot extends AbstractModel if (empty($extra)) { return '当前客户端版本低(所需版本≥v0.39.75)。'; } - if ($extra['type'] === 'bd') { + if (in_array($extra['type'], ['baidu', 'amap', 'tencent'])) { // todo 判断距离 } else { return '错误的定位签到。'; diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 6c7f2f78b..9aef51441 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -1842,6 +1842,7 @@ export default { // 位置签到 case "locat-checkin": this.$store.dispatch('openAppMapPage', { + type: item.config.type, key: item.config.key, point: `${item.config.lng},${item.config.lat}`, radius: item.config.radius, @@ -1849,27 +1850,14 @@ export default { if (!$A.isJson(data)) { return } - if (data.distance > item.config.radius) { - $A.modalError(`你选择的位置「${data.title}」不在签到范围内`) - return - } - const thumb = $A.urlAddParams('https://api.map.baidu.com/staticimage/v2', { - ak: item.config.key, - center: `${data.point.lng},${data.point.lat}`, - markers: `${data.point.lng},${data.point.lat}`, - width: 800, - height: 480, - zoom: 19, - copyright: 1, - }) this.sendLocationMsg({ - type: 'bd', + type: item.config.type, lng: data.point.lng, lat: data.point.lat, title: data.title, distance: data.distance, address: data.address || '', - thumb + thumb: data.thumb, }) }) break; diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index cb2b9b99e..7374ff03b 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -1260,7 +1260,7 @@ export default { /** * 打开地图选位置(App) * @param dispatch - * @param objects {{key: string, point: string}} + * @param objects {{type: string, key: string, point: string, radius: number}} * @returns {Promise} */ openAppMapPage({dispatch}, objects) { @@ -1292,6 +1292,42 @@ export default { const data = $A.jsonParse($A.eeuiAppGetVariate(`location::${channel}`)); if (data.point) { $A.eeuiAppSetVariate(`location::${channel}`, ""); + if (data.distance > objects.radius) { + $A.modalError(`你选择的位置「${data.title}」不在签到范围内`) + return + } + data.thumb = null; + if (objects.type === 'baidu') { + data.thumb = $A.urlAddParams('https://api.map.baidu.com/staticimage/v2', { + ak: objects.key, + center: `${data.point.lng},${data.point.lat}`, + markers: `${data.point.lng},${data.point.lat}`, + width: 800, + height: 480, + zoom: 19, + copyright: 1, + }) + } else if (objects.type === 'amap') { + data.thumb = $A.urlAddParams('https://restapi.amap.com/v3/staticmap', { + key: objects.key, + center: `${data.point.lng},${data.point.lat}`, + markers: `${data.point.lng},${data.point.lat}`, + width: 800, + height: 480, + zoom: 19, + copyright: 1, + }) + } else if (objects.type === 'tencent') { + data.thumb = $A.urlAddParams('https://apis.map.qq.com/ws/staticmap/v2', { + key: objects.key, + center: `${data.point.lng},${data.point.lat}`, + markers: `${data.point.lng},${data.point.lat}`, + width: 800, + height: 480, + zoom: 19, + copyright: 1, + }) + } resolve(data); } }