1
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"miniprogramRoot": "dist/",
|
||||
"projectname": "playBallTogether",
|
||||
"description": "playBallTogether",
|
||||
"appid": "wx815b533167eb7b53",
|
||||
"appid": "wx915ecf6c01bea4ec",
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": true,
|
||||
|
||||
@@ -5,6 +5,7 @@ import img from '@/config/images';
|
||||
import { FormFieldConfig } from '@/config/formSchema/publishBallFormSchema';
|
||||
import SelectStadium from '../SelectStadium/SelectStadium'
|
||||
import { Stadium } from '../SelectStadium/StadiumDetail'
|
||||
import { normalize_address } from '@/utils/locationUtils'
|
||||
import './FormBasicInfo.scss'
|
||||
|
||||
type PlayGame = {
|
||||
@@ -54,7 +55,7 @@ const FormBasicInfo: React.FC<FormBasicInfoProps> = ({
|
||||
onChange({...value,
|
||||
venue_id,
|
||||
location_name: name,
|
||||
location: address,
|
||||
location: normalize_address(address || ''),
|
||||
latitude,
|
||||
longitude,
|
||||
court_type,
|
||||
|
||||
@@ -4,7 +4,7 @@ import Taro from '@tarojs/taro'
|
||||
import { Loading } from '@nutui/nutui-react-taro'
|
||||
import StadiumDetail, { StadiumDetailRef } from './StadiumDetail'
|
||||
import { CommonPopup, CustomPopup } from '../../../../components'
|
||||
import { getLocation } from '@/utils/locationUtils'
|
||||
import { getLocation, normalize_address } from '@/utils/locationUtils'
|
||||
import PublishService from '@/services/publishService'
|
||||
import images from '@/config/images'
|
||||
import './SelectStadium.scss'
|
||||
@@ -100,7 +100,7 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
|
||||
success: (res) => {
|
||||
setSelectedStadium({
|
||||
name: res.name,
|
||||
address: res.address,
|
||||
address: normalize_address(res.address || ''),
|
||||
longitude: res.longitude,
|
||||
latitude: res.latitude
|
||||
})
|
||||
|
||||
@@ -7,6 +7,7 @@ import TextareaTag from '@/components/TextareaTag'
|
||||
import UploadCover, { type CoverImageValue } from '@/components/UploadCover'
|
||||
import { useKeyboardHeight } from '@/store/keyboardStore'
|
||||
import { useDictionaryActions } from '@/store/dictionaryStore'
|
||||
import { normalize_address } from '@/utils/locationUtils'
|
||||
|
||||
import './StadiumDetail.scss'
|
||||
|
||||
@@ -145,7 +146,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
||||
setFormData({
|
||||
...formData,
|
||||
name: res.name,
|
||||
address: res.address,
|
||||
address: normalize_address(res.address || ''),
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
istance: null
|
||||
|
||||
@@ -14,10 +14,20 @@ export interface LocationInfo {
|
||||
name?: string
|
||||
}
|
||||
|
||||
/** 规范化地址:去掉类似“上海市上海市...”的重复前缀 */
|
||||
export const normalize_address = (address: string): string => {
|
||||
if (!address) return ''
|
||||
// 去空格(包含全角空格)
|
||||
const trimmed = address.replace(/[\s\u3000]+/g, '')
|
||||
// 处理 “xx市xx市...” / “xx省xx省...” 等连续重复
|
||||
// 例:上海市上海市静安区... -> 上海市静安区...
|
||||
return trimmed.replace(/^(.{2,6}?[市省])\1+/, '$1')
|
||||
}
|
||||
|
||||
// 获取当前位置
|
||||
export const getCurrentLocation = (): Promise<LocationInfo> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Taro.getLocation({
|
||||
;(Taro as any).getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
console.log('===获取地理位置', res)
|
||||
@@ -27,7 +37,7 @@ export const getCurrentLocation = (): Promise<LocationInfo> => {
|
||||
resolve({
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
address
|
||||
address: normalize_address(address)
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -48,12 +58,12 @@ export const getCurrentLocation = (): Promise<LocationInfo> => {
|
||||
// 选择地图位置
|
||||
export const chooseLocation = (): Promise<LocationInfo> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Taro.chooseLocation({
|
||||
;(Taro as any).chooseLocation({
|
||||
success: (res) => {
|
||||
resolve({
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
address: res.address,
|
||||
address: normalize_address(res.address),
|
||||
name: res.name
|
||||
})
|
||||
},
|
||||
@@ -66,7 +76,7 @@ export const chooseLocation = (): Promise<LocationInfo> => {
|
||||
|
||||
export const getLocation = (): Promise<Location> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Taro.getLocation({
|
||||
;(Taro as any).getLocation({
|
||||
success: (res) => {
|
||||
resolve({
|
||||
latitude: res.latitude,
|
||||
|
||||
Reference in New Issue
Block a user