diff --git a/src/hooks/useLocation.js b/src/hooks/useLocation.js
index 9c42e782a..9fe4b32f8 100644
--- a/src/hooks/useLocation.js
+++ b/src/hooks/useLocation.js
@@ -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))
}
}
}
diff --git a/src/pages/custom/custom-page.js b/src/pages/custom/custom-page.js
index 210e41c18..6ab77ab6b 100644
--- a/src/pages/custom/custom-page.js
+++ b/src/pages/custom/custom-page.js
@@ -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()
diff --git a/src/pages/home/wgts/home-header.js b/src/pages/home/wgts/home-header.js
index b59386cb0..5f64e334c 100644
--- a/src/pages/home/wgts/home-header.js
+++ b/src/pages/home/wgts/home-header.js
@@ -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) {
}
}}
>
- {location?.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('') ||
+ '选择地区'}
+
)}
diff --git a/src/pages/index.js b/src/pages/index.js
index 4c13d983e..2833c645a 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -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,