1
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"miniprogramRoot": "dist/",
|
"miniprogramRoot": "dist/",
|
||||||
"projectname": "playBallTogether",
|
"projectname": "playBallTogether",
|
||||||
"description": "playBallTogether",
|
"description": "playBallTogether",
|
||||||
"appid": "wx815b533167eb7b53",
|
"appid": "wx915ecf6c01bea4ec",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": true,
|
"urlCheck": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import img from '@/config/images';
|
|||||||
import { FormFieldConfig } from '@/config/formSchema/publishBallFormSchema';
|
import { FormFieldConfig } from '@/config/formSchema/publishBallFormSchema';
|
||||||
import SelectStadium from '../SelectStadium/SelectStadium'
|
import SelectStadium from '../SelectStadium/SelectStadium'
|
||||||
import { Stadium } from '../SelectStadium/StadiumDetail'
|
import { Stadium } from '../SelectStadium/StadiumDetail'
|
||||||
|
import { normalize_address } from '@/utils/locationUtils'
|
||||||
import './FormBasicInfo.scss'
|
import './FormBasicInfo.scss'
|
||||||
|
|
||||||
type PlayGame = {
|
type PlayGame = {
|
||||||
@@ -54,7 +55,7 @@ const FormBasicInfo: React.FC<FormBasicInfoProps> = ({
|
|||||||
onChange({...value,
|
onChange({...value,
|
||||||
venue_id,
|
venue_id,
|
||||||
location_name: name,
|
location_name: name,
|
||||||
location: address,
|
location: normalize_address(address || ''),
|
||||||
latitude,
|
latitude,
|
||||||
longitude,
|
longitude,
|
||||||
court_type,
|
court_type,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import Taro from '@tarojs/taro'
|
|||||||
import { Loading } from '@nutui/nutui-react-taro'
|
import { Loading } from '@nutui/nutui-react-taro'
|
||||||
import StadiumDetail, { StadiumDetailRef } from './StadiumDetail'
|
import StadiumDetail, { StadiumDetailRef } from './StadiumDetail'
|
||||||
import { CommonPopup, CustomPopup } from '../../../../components'
|
import { CommonPopup, CustomPopup } from '../../../../components'
|
||||||
import { getLocation } from '@/utils/locationUtils'
|
import { getLocation, normalize_address } from '@/utils/locationUtils'
|
||||||
import PublishService from '@/services/publishService'
|
import PublishService from '@/services/publishService'
|
||||||
import images from '@/config/images'
|
import images from '@/config/images'
|
||||||
import './SelectStadium.scss'
|
import './SelectStadium.scss'
|
||||||
@@ -100,7 +100,7 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
setSelectedStadium({
|
setSelectedStadium({
|
||||||
name: res.name,
|
name: res.name,
|
||||||
address: res.address,
|
address: normalize_address(res.address || ''),
|
||||||
longitude: res.longitude,
|
longitude: res.longitude,
|
||||||
latitude: res.latitude
|
latitude: res.latitude
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import TextareaTag from '@/components/TextareaTag'
|
|||||||
import UploadCover, { type CoverImageValue } from '@/components/UploadCover'
|
import UploadCover, { type CoverImageValue } from '@/components/UploadCover'
|
||||||
import { useKeyboardHeight } from '@/store/keyboardStore'
|
import { useKeyboardHeight } from '@/store/keyboardStore'
|
||||||
import { useDictionaryActions } from '@/store/dictionaryStore'
|
import { useDictionaryActions } from '@/store/dictionaryStore'
|
||||||
|
import { normalize_address } from '@/utils/locationUtils'
|
||||||
|
|
||||||
import './StadiumDetail.scss'
|
import './StadiumDetail.scss'
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
setFormData({
|
setFormData({
|
||||||
...formData,
|
...formData,
|
||||||
name: res.name,
|
name: res.name,
|
||||||
address: res.address,
|
address: normalize_address(res.address || ''),
|
||||||
latitude: res.latitude,
|
latitude: res.latitude,
|
||||||
longitude: res.longitude,
|
longitude: res.longitude,
|
||||||
istance: null
|
istance: null
|
||||||
|
|||||||
@@ -14,10 +14,20 @@ export interface LocationInfo {
|
|||||||
name?: string
|
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> => {
|
export const getCurrentLocation = (): Promise<LocationInfo> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Taro.getLocation({
|
;(Taro as any).getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('===获取地理位置', res)
|
console.log('===获取地理位置', res)
|
||||||
@@ -27,7 +37,7 @@ export const getCurrentLocation = (): Promise<LocationInfo> => {
|
|||||||
resolve({
|
resolve({
|
||||||
latitude: res.latitude,
|
latitude: res.latitude,
|
||||||
longitude: res.longitude,
|
longitude: res.longitude,
|
||||||
address
|
address: normalize_address(address)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -48,12 +58,12 @@ export const getCurrentLocation = (): Promise<LocationInfo> => {
|
|||||||
// 选择地图位置
|
// 选择地图位置
|
||||||
export const chooseLocation = (): Promise<LocationInfo> => {
|
export const chooseLocation = (): Promise<LocationInfo> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Taro.chooseLocation({
|
;(Taro as any).chooseLocation({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve({
|
resolve({
|
||||||
latitude: res.latitude,
|
latitude: res.latitude,
|
||||||
longitude: res.longitude,
|
longitude: res.longitude,
|
||||||
address: res.address,
|
address: normalize_address(res.address),
|
||||||
name: res.name
|
name: res.name
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -66,7 +76,7 @@ export const chooseLocation = (): Promise<LocationInfo> => {
|
|||||||
|
|
||||||
export const getLocation = (): Promise<Location> => {
|
export const getLocation = (): Promise<Location> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Taro.getLocation({
|
;(Taro as any).getLocation({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve({
|
resolve({
|
||||||
latitude: res.latitude,
|
latitude: res.latitude,
|
||||||
|
|||||||
Reference in New Issue
Block a user