feat(admin,partner): Tencent map location picker and expose LBS key
Store create/edit on HQ and partner can pick coords via Tencent locpicker; client-config exposes TENCENT_LBS_KEY; seed empty system settings from env. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { FilePdfOutlined, LinkOutlined } from '@ant-design/icons';
|
||||
import { FilePdfOutlined, LinkOutlined, EnvironmentOutlined } from '@ant-design/icons';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import {
|
||||
ADMIN_OPTIONS_PAGE_SIZE,
|
||||
@@ -37,6 +37,7 @@ import { useAdminList } from '../lib/useAdminList';
|
||||
import { resolveRegionBinding } from '../lib/china-region';
|
||||
import ChinaRegionCascader from '../components/ChinaRegionCascader';
|
||||
import OssUpload from '../components/OssUpload';
|
||||
import TencentLocPickerModal from '../components/TencentLocPickerModal';
|
||||
|
||||
const CREATE_STEPS = [
|
||||
{ title: '基本信息' },
|
||||
@@ -44,17 +45,6 @@ const CREATE_STEPS = [
|
||||
{ title: '结算资质' },
|
||||
];
|
||||
|
||||
/** 用店名 + 地址打开百度地图搜索,便于人工核对经纬度 */
|
||||
function openBaiduMapSearch(parts: Array<string | null | undefined>) {
|
||||
const query = parts.map((p) => String(p || '').trim()).filter(Boolean).join(' ');
|
||||
if (!query) {
|
||||
message.warning('请先填写门店名称和地址');
|
||||
return;
|
||||
}
|
||||
const url = `https://map.baidu.com/search/${encodeURIComponent(query)}/@0,0,12z?querytype=s&da_src=shareurl&wd=${encodeURIComponent(query)}`;
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
function fillGeolocation(
|
||||
setCoords: (lat: number, lng: number) => void,
|
||||
setLoading: (v: boolean) => void,
|
||||
@@ -356,6 +346,8 @@ export default function StoresPage() {
|
||||
const [createStep, setCreateStep] = useState(0);
|
||||
const [createError, setCreateError] = useState('');
|
||||
const [locating, setLocating] = useState(false);
|
||||
const [mapPickerOpen, setMapPickerOpen] = useState(false);
|
||||
const [mapPickerTarget, setMapPickerTarget] = useState<'create' | 'edit'>('create');
|
||||
const [partners, setPartners] = useState<PartnerOption[]>([]);
|
||||
const [cities, setCities] = useState<CityOption[]>([]);
|
||||
const [categoryTree, setCategoryTree] = useState<CategoryNode[]>([]);
|
||||
@@ -839,24 +831,16 @@ export default function StoresPage() {
|
||||
获取当前位置
|
||||
</Button>
|
||||
<Button
|
||||
icon={<LinkOutlined />}
|
||||
icon={<EnvironmentOutlined />}
|
||||
onClick={() => {
|
||||
const name = String(editForm.getFieldValue('name') || detail.name || '');
|
||||
const district = String(editForm.getFieldValue('district') || detail.district || '');
|
||||
const address = String(editForm.getFieldValue('address') || detail.address || '');
|
||||
openBaiduMapSearch([
|
||||
String(detail.province || ''),
|
||||
String(detail.cityName || ''),
|
||||
district,
|
||||
address,
|
||||
name,
|
||||
]);
|
||||
setMapPickerTarget('edit');
|
||||
setMapPickerOpen(true);
|
||||
}}
|
||||
>
|
||||
百度地图查询
|
||||
腾讯地图选点
|
||||
</Button>
|
||||
<Typography.Text type="secondary">
|
||||
打开百度地图核对位置后,将坐标填回上方经纬度
|
||||
搜索或拖图确认位置后自动填入经纬度
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
<Form.Item name="avgPrice" label="人均费用(选填)">
|
||||
@@ -1013,22 +997,16 @@ export default function StoresPage() {
|
||||
获取当前位置
|
||||
</Button>
|
||||
<Button
|
||||
icon={<LinkOutlined />}
|
||||
icon={<EnvironmentOutlined />}
|
||||
onClick={() => {
|
||||
const v = createForm.getFieldsValue();
|
||||
openBaiduMapSearch([
|
||||
v.province,
|
||||
v.city,
|
||||
v.district,
|
||||
v.address,
|
||||
v.name,
|
||||
]);
|
||||
setMapPickerTarget('create');
|
||||
setMapPickerOpen(true);
|
||||
}}
|
||||
>
|
||||
百度地图查询
|
||||
腾讯地图选点
|
||||
</Button>
|
||||
<Typography.Text type="secondary">
|
||||
可手动填写 / 定位 / 百度地图核对后填入坐标
|
||||
可手动填写 / 定位 / 腾讯地图选点填入坐标
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
<Space wrap style={{ width: '100%' }}>
|
||||
@@ -1132,6 +1110,42 @@ export default function StoresPage() {
|
||||
onChange={(e) => setRejectReason(e.target.value)}
|
||||
/>
|
||||
</Modal>
|
||||
<TencentLocPickerModal
|
||||
open={mapPickerOpen}
|
||||
onClose={() => setMapPickerOpen(false)}
|
||||
latitude={
|
||||
mapPickerTarget === 'edit'
|
||||
? Number(editForm.getFieldValue('latitude') ?? detail?.latitude)
|
||||
: Number(createForm.getFieldValue('latitude'))
|
||||
}
|
||||
longitude={
|
||||
mapPickerTarget === 'edit'
|
||||
? Number(editForm.getFieldValue('longitude') ?? detail?.longitude)
|
||||
: Number(createForm.getFieldValue('longitude'))
|
||||
}
|
||||
onPick={(loc) => {
|
||||
if (mapPickerTarget === 'edit') {
|
||||
editForm.setFieldsValue({
|
||||
latitude: loc.latitude,
|
||||
longitude: loc.longitude,
|
||||
...(loc.address && !editForm.getFieldValue('address')
|
||||
? { address: loc.address }
|
||||
: {}),
|
||||
});
|
||||
} else {
|
||||
createForm.setFieldsValue({
|
||||
latitude: loc.latitude,
|
||||
longitude: loc.longitude,
|
||||
...(loc.address && !createForm.getFieldValue('address')
|
||||
? { address: loc.address }
|
||||
: {}),
|
||||
});
|
||||
}
|
||||
message.success(
|
||||
`已选点 ${loc.latitude.toFixed(6)}, ${loc.longitude.toFixed(6)}${loc.name ? `(${loc.name})` : ''}`,
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user