mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-05 20:35:50 +08:00
fix(location): 无 GPS 时收货地址不再写入 location;导航文案按 adrdetail 分流
- useLocation:登录且未拿到定位时仅 updateChooseAddress(默认地址),避免收货地址混入 Redux location - 首页/自定义页 nearbyText:有 adrdetail 优先 address,否则优先 LBS 再退回 address.city - home-header:同上规则展示地区;去掉硬编码昌平默认 - index:移除未使用的 shopInfo、locationKeyRef Made-with: Cursor
This commit is contained in:
@@ -6,7 +6,7 @@ import Taro from '@tarojs/taro'
|
||||
import api from '@/api'
|
||||
import entryLaunch from '@/utils/entryLaunch'
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { updateLocation } from '@/store/slices/user'
|
||||
import { updateLocation, updateChooseAddress } from '@/store/slices/user'
|
||||
import S from '@/spx'
|
||||
|
||||
export default (props) => {
|
||||
@@ -146,9 +146,10 @@ export default (props) => {
|
||||
dispatch(updateLocation(res1))
|
||||
}
|
||||
} else {
|
||||
// 未拿到 GPS:不要把收货地址写进 location,否则首页「定位」会与收货地址混淆
|
||||
if (arr.length > 0) {
|
||||
const arr1 = await processingAddress([list.find((obj) => obj.is_def === true) || list[0]])
|
||||
dispatch(updateLocation(arr1[0]))
|
||||
const defAddr = list.find((obj) => obj.is_def === true) || list[0]
|
||||
dispatch(updateChooseAddress(defAddr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,9 @@ function CustomPage(props) {
|
||||
const loginRef = useRef()
|
||||
const router = useRouter()
|
||||
const { location, address } = useSelector((state) => state.user)
|
||||
const nearbyText = address?.city || location?.city || ''
|
||||
const nearbyText = address?.adrdetail
|
||||
? address?.city || address?.province || ''
|
||||
: location?.city || location?.province || address?.city || ''
|
||||
|
||||
useEffect(() => {
|
||||
fetch()
|
||||
|
||||
@@ -12,7 +12,7 @@ import './home-header.scss'
|
||||
|
||||
function WgtHomeHeader(props) {
|
||||
const { children, jump = true, isSetHight } = props
|
||||
const { location = {} } = useSelector((state) => state.user)
|
||||
const { location = {}, address } = useSelector((state) => state.user)
|
||||
const { openScanQrcode, entryStoreByLBS, openWechatappLocation } = useSelector(
|
||||
(state) => state.sys
|
||||
)
|
||||
@@ -46,7 +46,18 @@ function WgtHomeHeader(props) {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View className='address'>{location?.address || '北京市北京市昌平区'}</View>
|
||||
<View className='address'>
|
||||
{address?.adrdetail
|
||||
? [address.province, address.city, address.county, address.adrdetail]
|
||||
.filter(Boolean)
|
||||
.join('') ||
|
||||
address.city ||
|
||||
address.province ||
|
||||
'选择地区'
|
||||
: location?.address ||
|
||||
[location?.province, location?.city, location?.district].filter(Boolean).join('') ||
|
||||
'选择地区'}
|
||||
</View>
|
||||
<Text className='iconfont icon-qianwang-01'></Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -86,14 +86,14 @@ function Home() {
|
||||
|
||||
const { openRecommend, appName, openScanQrcode, entryStoreByLBS, openWechatappLocation } =
|
||||
useSelector((state) => state.sys)
|
||||
const { shopInfo } = useSelector((state) => state.shop)
|
||||
|
||||
const showAdv = useSelector((member) => member.user.showAdv)
|
||||
const { location, address } = useSelector((state) => state.user)
|
||||
const nearbyText = address?.city || location?.city || ''
|
||||
const nearbyText = address?.adrdetail
|
||||
? address?.city || address?.province || ''
|
||||
: location?.city || location?.province || address?.city || ''
|
||||
const { setNavigationBarTitle } = useNavigation()
|
||||
const { updateAddress } = useLocation()
|
||||
const locationKeyRef = useRef('')
|
||||
const {
|
||||
wgts,
|
||||
pageData,
|
||||
|
||||
Reference in New Issue
Block a user