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',
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
"path-to-regexp": "^3.1.0", "path-to-regexp": "^3.1.0",
"qs": "^6.9.0", "qs": "^6.9.0",
"react": "^16.8.6", "react": "^16.8.6",
"react-bmapgl": "^0.2.7", "react-amap": "^1.2.8",
"react-copy-to-clipboard": "^5.0.1", "react-copy-to-clipboard": "^5.0.1",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
"react-helmet": "^5.2.1", "react-helmet": "^5.2.1",
...@@ -127,4 +127,4 @@ ...@@ -127,4 +127,4 @@
"scripts/**/*.js" "scripts/**/*.js"
], ],
"author": "congmin.hao" "author": "congmin.hao"
} }
\ No newline at end of file
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 || '', window.AMap.plugin(['AMap.Geocoder'], () => {
point => { const city = addrInfo.provice || '北京市';
if (point) { const geocoder = new window.AMap.Geocoder({
// convertor.translate([point], 1, 5, translateCallback); city,
setLnglat(point); });
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])
} }
}, });
addrInfo.provice || '北京市', });
);
}; };
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>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>量星球商户管理系统</title>
<script
type="text/javascript"
src="https://api.map.baidu.com/api?v=3.0&ak=5gZyih0oAhiNdbbdPKTc9ZGYOwel8bYN&type=webgl"
></script>
<link rel="icon" href="/favicon.png" type="image/x-icon" />
</head>
<body>
<noscript>Out-of-the-box mid-stage front/design solution!</noscript>
<div id="root">
<style>
.page-loading-warp {
padding: 120px;
display: flex;
justify-content: center;
align-items: center;
}
.ant-spin {
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
font-variant: tabular-nums;
line-height: 1.5;
list-style: none;
-webkit-font-feature-settings: 'tnum';
font-feature-settings: 'tnum';
position: absolute;
display: none;
color: #1890ff;
text-align: center;
vertical-align: middle;
opacity: 0;
-webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
-webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
}
.ant-spin-spinning { <head>
position: static; <meta charset="UTF-8" />
display: inline-block; <meta http-equiv="X-UA-Compatible" content="IE=edge" />
opacity: 1; <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
} <title>量星球商户管理系统</title>
<!-- <script type="text/javascript"
src="https://api.map.baidu.com/api?v=3.0&ak=5gZyih0oAhiNdbbdPKTc9ZGYOwel8bYN&type=webgl"></script> -->
<script type="text/javascript">
window._AMapSecurityConfig = {
securityJsCode: '99349c5c13106863571748b3e7756499'
}
</script>
<link rel="icon" href="/favicon.png" type="image/x-icon" />
</head>
.ant-spin-dot { <body>
position: relative; <noscript>Out-of-the-box mid-stage front/design solution!</noscript>
display: inline-block; <div id="root">
font-size: 20px; <style>
width: 20px; .page-loading-warp {
height: 20px; padding: 120px;
} display: flex;
justify-content: center;
align-items: center;
}
.ant-spin-dot-item { .ant-spin {
position: absolute; -webkit-box-sizing: border-box;
display: block; box-sizing: border-box;
width: 9px; margin: 0;
height: 9px; padding: 0;
background-color: #1890ff; color: rgba(0, 0, 0, 0.65);
border-radius: 100%; font-size: 14px;
-webkit-transform: scale(0.75); font-variant: tabular-nums;
-ms-transform: scale(0.75); line-height: 1.5;
transform: scale(0.75); list-style: none;
-webkit-transform-origin: 50% 50%; -webkit-font-feature-settings: 'tnum';
-ms-transform-origin: 50% 50%; font-feature-settings: 'tnum';
transform-origin: 50% 50%; position: absolute;
opacity: 0.3; display: none;
-webkit-animation: antSpinMove 1s infinite linear alternate; color: #1890ff;
animation: antSpinMove 1s infinite linear alternate; text-align: center;
} vertical-align: middle;
opacity: 0;
-webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
-webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
}
.ant-spin-dot-item:nth-child(1) { .ant-spin-spinning {
top: 0; position: static;
left: 0; display: inline-block;
} opacity: 1;
}
.ant-spin-dot-item:nth-child(2) { .ant-spin-dot {
top: 0; position: relative;
right: 0; display: inline-block;
-webkit-animation-delay: 0.4s; font-size: 20px;
animation-delay: 0.4s; width: 20px;
} height: 20px;
}
.ant-spin-dot-item:nth-child(3) { .ant-spin-dot-item {
right: 0; position: absolute;
bottom: 0; display: block;
-webkit-animation-delay: 0.8s; width: 9px;
animation-delay: 0.8s; height: 9px;
} background-color: #1890ff;
border-radius: 100%;
-webkit-transform: scale(0.75);
-ms-transform: scale(0.75);
transform: scale(0.75);
-webkit-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
transform-origin: 50% 50%;
opacity: 0.3;
-webkit-animation: antSpinMove 1s infinite linear alternate;
animation: antSpinMove 1s infinite linear alternate;
}
.ant-spin-dot-item:nth-child(4) { .ant-spin-dot-item:nth-child(1) {
bottom: 0; top: 0;
left: 0; left: 0;
-webkit-animation-delay: 1.2s; }
animation-delay: 1.2s;
}
.ant-spin-dot-spin { .ant-spin-dot-item:nth-child(2) {
-webkit-transform: rotate(45deg); top: 0;
-ms-transform: rotate(45deg); right: 0;
transform: rotate(45deg); -webkit-animation-delay: 0.4s;
-webkit-animation: antRotate 1.2s infinite linear; animation-delay: 0.4s;
animation: antRotate 1.2s infinite linear; }
}
.ant-spin-lg .ant-spin-dot { .ant-spin-dot-item:nth-child(3) {
font-size: 32px; right: 0;
width: 32px; bottom: 0;
height: 32px; -webkit-animation-delay: 0.8s;
} animation-delay: 0.8s;
}
.ant-spin-lg .ant-spin-dot i { .ant-spin-dot-item:nth-child(4) {
width: 14px; bottom: 0;
height: 14px; left: 0;
} -webkit-animation-delay: 1.2s;
animation-delay: 1.2s;
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { .ant-spin-dot-spin {
.ant-spin-blur { -webkit-transform: rotate(45deg);
background: #fff; -ms-transform: rotate(45deg);
opacity: 0.5; transform: rotate(45deg);
} -webkit-animation: antRotate 1.2s infinite linear;
} animation: antRotate 1.2s infinite linear;
}
.ant-spin-lg .ant-spin-dot {
font-size: 32px;
width: 32px;
height: 32px;
}
@-webkit-keyframes antSpinMove { .ant-spin-lg .ant-spin-dot i {
to { width: 14px;
opacity: 1; height: 14px;
} }
@media all and (-ms-high-contrast: none),
(-ms-high-contrast: active) {
.ant-spin-blur {
background: #fff;
opacity: 0.5;
} }
}
@keyframes antSpinMove { @-webkit-keyframes antSpinMove {
to { to {
opacity: 1; opacity: 1;
}
} }
}
@-webkit-keyframes antRotate { @keyframes antSpinMove {
to { to {
-webkit-transform: rotate(405deg); opacity: 1;
transform: rotate(405deg);
}
} }
}
@keyframes antRotate { @-webkit-keyframes antRotate {
to { to {
-webkit-transform: rotate(405deg); -webkit-transform: rotate(405deg);
transform: rotate(405deg); transform: rotate(405deg);
}
} }
</style> }
<div class="page-loading-warp">
<div class="ant-spin ant-spin-lg ant-spin-spinning"> @keyframes antRotate {
<span class="ant-spin-dot ant-spin-dot-spin" to {
><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i -webkit-transform: rotate(405deg);
><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i transform: rotate(405deg);
></span> }
</div> }
</style>
<div class="page-loading-warp">
<div class="ant-spin ant-spin-lg ant-spin-spinning">
<span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i
class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span>
</div> </div>
</div> </div>
</body> </div>
</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