Commit bce61d7d authored by 李腾's avatar 李腾

feat: 新建/编辑门店经纬度信息替换为高德地图

parent 4212a03a
...@@ -12,5 +12,6 @@ module.exports = { ...@@ -12,5 +12,6 @@ module.exports = {
'no-plusplus': ['off'], 'no-plusplus': ['off'],
'@typescript-eslint/camelcase': ['off'], '@typescript-eslint/camelcase': ['off'],
'@typescript-eslint/no-unused-vars': ['off'], '@typescript-eslint/no-unused-vars': ['off'],
'import/extensions': 0,
}, },
}; };
...@@ -2,7 +2,7 @@ const isProduction = process.env.NODE_ENV === 'production'; ...@@ -2,7 +2,7 @@ const isProduction = process.env.NODE_ENV === 'production';
const isPre = process.env.PRE_ENV === 'pre'; const isPre = process.env.PRE_ENV === 'pre';
const envAPi = { const envAPi = {
api: 'https://security.q-gp.com', //'https://security-xyqb.liangkebang.net', api: 'https://security-xyqb.liangkebang.net', //'https://security-xyqb.liangkebang.net',
kdspOpApi: 'https://sc-merchant-api-xyqb.liangkebang.net', kdspOpApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
kdspApi: 'https://sc-merchant-api-xyqb.liangkebang.net', kdspApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
goodsApi: 'https://sc-merchant-api-xyqb.liangkebang.net', goodsApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
......
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Map, Marker, ZoomControl, CityListControl } from 'react-bmapgl'; import { Map, Marker } from 'react-amap';
import { Modal, Input } from 'antd'; import { Modal, Input } from 'antd';
const MAP_KEY = '82ae49bca6834ad0d5c9fb173e57f88a';
export default props => { export default props => {
const { visible, onSetPoint, onCancel, lngLat, addrInfo } = props; const { visible, onSetPoint, onCancel, lngLat: propsLngLat, addrInfo } = props;
let defaultLnglat = { lng: 116.404449, lat: 39.914889 }; let defaultLnglat = [116.404449, 39.914889];
if (lngLat) { if (propsLngLat) {
defaultLnglat = lngLat; defaultLnglat = [propsLngLat.lng, propsLngLat.lat];
} }
const [lnglat, setLnglat] = useState(defaultLnglat); const [lnglat, setLnglat] = useState(defaultLnglat);
const [lnglatText, setLnglatText] = useState(`${defaultLnglat.lng},${defaultLnglat.lat}`); const [lnglatText, setLnglatText] = useState(`${defaultLnglat[0]},${defaultLnglat[1]}`);
const handleOk = () => { const handleOk = () => {
onSetPoint(lnglatText); onSetPoint(lnglatText);
onCancel(true); onCancel(true);
}; };
const handleCancle = () => onCancel(true);
const onGetPoint = e => { const onGetPoint = e => {
setLnglat({ setLnglat([e.lnglat.lng, e.lnglat.lat]);
lng: e.latlng.lng, setLnglatText(`${e.lnglat.lng},${e.lnglat.lat}`);
lat: e.latlng.lat,
});
setLnglatText(`${e.latlng.lng},${e.latlng.lat}`);
}; };
// const translateCallback = obj => {
// console.log('obj :>> ', obj);
// setLnglat(obj.points[0]);
// };
const getPoint = () => { const getPoint = () => {
// const convertor = new window.BMapGL.Convertor(); if (!window.AMap) {
const myGeo = new window.BMapGL.Geocoder(); return;
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint(
addrInfo.address || '',
point => {
if (point) {
// convertor.translate([point], 1, 5, translateCallback);
setLnglat(point);
} }
},
addrInfo.provice || '北京市', window.AMap.plugin(['AMap.Geocoder'], () => {
); const city = addrInfo.provice || '北京市';
const geocoder = new window.AMap.Geocoder({
city,
});
geocoder.getLocation(addrInfo.address, (status, result) => {
if (status === 'complete' && result.geocodes.length) {
const { lng, lat } = result.geocodes[0].location;
setLnglat([lng, lat]);
} else {
console.error('根据地址查询位置失败');
// setLnglat([116.397561,39.909063])
}
});
});
}; };
useEffect(() => { useEffect(() => {
...@@ -58,31 +57,23 @@ export default props => { ...@@ -58,31 +57,23 @@ export default props => {
visible={visible} visible={visible}
width="800px" width="800px"
onOk={() => handleOk()} onOk={() => handleOk()}
onCancel={() => handleCancle()} onCancel={() => onCancel(true)}
> >
<div style={{ marginBottom: '20px' }}> <div style={{ marginBottom: '20px' }}>
<Input value={lnglatText} placeholder="点击地图选择经纬度" /> <Input value={lnglatText} placeholder="点击地图选择经纬度" />
</div> </div>
<div style={{ width: '100%', height: '360px' }}> <div style={{ width: '100%', height: '360px' }}>
<Map <Map
plugins={['ToolBar']}
center={lnglat} center={lnglat}
enableScrollWheelZoom amapkey={MAP_KEY}
enableDoubleClickZoom events={{
coordType="gcj02" created: getPoint,
onClick={e => onGetPoint(e)} click: onGetPoint,
}}
zoom={15} zoom={15}
> >
<Marker <Marker position={lnglat}></Marker>
position={lnglat}
Icon
coordType="gcj02"
autoViewport
viewportOptions={{
zoomFactor: -12,
}}
/>
<CityListControl />
<ZoomControl />
</Map> </Map>
</div> </div>
</Modal> </Modal>
......
...@@ -2,19 +2,10 @@ import React, { useState, useEffect, useRef } from 'react'; ...@@ -2,19 +2,10 @@ import React, { useState, useEffect, useRef } from 'react';
import { Form } from '@ant-design/compatible'; import { Form } from '@ant-design/compatible';
import moment from 'moment'; import moment from 'moment';
import { PlusSquareFilled, MinusSquareFilled } from '@ant-design/icons'; import { PlusSquareFilled, MinusSquareFilled } from '@ant-design/icons';
import { import { Modal, Input, TimePicker, Checkbox, Cascader, Radio, notification } from 'antd';
Modal,
Input,
DatePicker,
TimePicker,
Checkbox,
Cascader,
Radio,
notification,
} from 'antd';
import { apiAddrArea, apiCreatStore, apiEditStore } from '../services'; import { apiAddrArea, apiCreatStore, apiEditStore } from '../services';
import { weekOptions, weekDefault, layout } from '../data'; import { weekOptions, weekDefault, layout } from '../data';
import MapModal from '@/components/BaiduMap'; import MapModal from '@/components/GaoDeMap';
import style from './style.less'; import style from './style.less';
import { isCheckNumberLine } from '@/utils/validator'; import { isCheckNumberLine } from '@/utils/validator';
...@@ -89,6 +80,9 @@ const StoreModal = props => { ...@@ -89,6 +80,9 @@ const StoreModal = props => {
const openMap = v => { const openMap = v => {
const values = getFieldsValue(); const values = getFieldsValue();
let provice = '北京市'; let provice = '北京市';
if (!values.addr) {
return;
}
if (values.addr.length > 0) { if (values.addr.length > 0) {
areaAddr.forEach(item => { areaAddr.forEach(item => {
if (item.value === values.addr[0]) { if (item.value === values.addr[0]) {
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>量星球商户管理系统</title> <title>量星球商户管理系统</title>
<script <!-- <script type="text/javascript"
type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=5gZyih0oAhiNdbbdPKTc9ZGYOwel8bYN&type=webgl"></script> -->
src="https://api.map.baidu.com/api?v=3.0&ak=5gZyih0oAhiNdbbdPKTc9ZGYOwel8bYN&type=webgl" <script type="text/javascript">
></script> window._AMapSecurityConfig = {
securityJsCode: '99349c5c13106863571748b3e7756499'
}
</script>
<link rel="icon" href="/favicon.png" type="image/x-icon" /> <link rel="icon" href="/favicon.png" type="image/x-icon" />
</head> </head>
<body>
<body>
<noscript>Out-of-the-box mid-stage front/design solution!</noscript> <noscript>Out-of-the-box mid-stage front/design solution!</noscript>
<div id="root"> <div id="root">
<style> <style>
...@@ -24,6 +26,7 @@ ...@@ -24,6 +26,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.ant-spin { .ant-spin {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
...@@ -126,7 +129,8 @@ ...@@ -126,7 +129,8 @@
height: 14px; height: 14px;
} }
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { @media all and (-ms-high-contrast: none),
(-ms-high-contrast: active) {
.ant-spin-blur { .ant-spin-blur {
background: #fff; background: #fff;
opacity: 0.5; opacity: 0.5;
...@@ -161,12 +165,11 @@ ...@@ -161,12 +165,11 @@
</style> </style>
<div class="page-loading-warp"> <div class="page-loading-warp">
<div class="ant-spin ant-spin-lg ant-spin-spinning"> <div class="ant-spin ant-spin-lg ant-spin-spinning">
<span class="ant-spin-dot ant-spin-dot-spin" <span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i
><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span>
><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i
></span>
</div> </div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment