Allow browsing before mini login
This commit is contained in:
@@ -135,6 +135,7 @@ export default function Location() {
|
||||
const [emptyState, setEmptyState] = useState<{ title: string; desc: string; actionText: string; actionUrl: string } | null>(
|
||||
null
|
||||
)
|
||||
const [isGuest, setIsGuest] = useState(false)
|
||||
|
||||
useDidShow(() => {
|
||||
void loadLocation(true)
|
||||
@@ -144,10 +145,18 @@ export default function Location() {
|
||||
const targetMode = nextMode || trajectoryMode
|
||||
|
||||
if (!getToken()) {
|
||||
Taro.reLaunch({ url: '/pages/login/index' })
|
||||
setDeviceLocation(null)
|
||||
setTrajectory([])
|
||||
setSelectedPoint(null)
|
||||
setCoordinates(DEFAULT_COORDINATES)
|
||||
setEmptyState(null)
|
||||
setLocationNotice(null)
|
||||
setIsGuest(true)
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
setIsGuest(false)
|
||||
if (showToast) {
|
||||
Taro.showLoading({ title: '刷新中...' })
|
||||
}
|
||||
@@ -372,7 +381,36 @@ export default function Location() {
|
||||
<Text className='page-title'>设备定位</Text>
|
||||
</View>
|
||||
|
||||
{emptyState ? (
|
||||
{isGuest ? (
|
||||
<>
|
||||
<View className='map-section guest-map-section'>
|
||||
<Map
|
||||
className='map'
|
||||
latitude={DEFAULT_COORDINATES.latitude}
|
||||
longitude={DEFAULT_COORDINATES.longitude}
|
||||
scale={11}
|
||||
onError={(event) => {
|
||||
console.error('[location] guest map error:', event.detail)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View className='location-empty-shell'>
|
||||
<View className='location-empty-card'>
|
||||
<Text className='location-empty-title'>设备定位与轨迹</Text>
|
||||
<Text className='location-empty-desc'>绑定设备后,可在这里查看孩子设备的位置、更新时间和定位精度。</Text>
|
||||
<View
|
||||
className='location-empty-action'
|
||||
onClick={() => {
|
||||
Taro.setStorageSync('postLoginRedirect', '/pages/location/index')
|
||||
Taro.navigateTo({ url: '/pages/login/index' })
|
||||
}}
|
||||
>
|
||||
<Text className='location-empty-action-text'>登录后查看</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
) : emptyState ? (
|
||||
<View className='location-empty-shell'>
|
||||
<View className='location-empty-card'>
|
||||
<Text className='location-empty-title'>{emptyState.title}</Text>
|
||||
|
||||
Reference in New Issue
Block a user