Allow browsing before mini login
This commit is contained in:
@@ -18,6 +18,119 @@
|
||||
}
|
||||
}
|
||||
|
||||
.guest-hero {
|
||||
padding: 88px 40px 32px;
|
||||
background: #FFFFFF;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.guest-device-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 132px;
|
||||
height: 132px;
|
||||
margin: 0 auto 24px;
|
||||
border-radius: 32px;
|
||||
background: #FEF3E8;
|
||||
|
||||
.robot-img {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
}
|
||||
}
|
||||
|
||||
.guest-title {
|
||||
display: block;
|
||||
font-size: 44px;
|
||||
line-height: 1.2;
|
||||
font-weight: 700;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.guest-subtitle {
|
||||
display: block;
|
||||
margin-top: 18px;
|
||||
font-size: 28px;
|
||||
line-height: 1.6;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.guest-feature-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 18px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.guest-feature-card {
|
||||
min-height: 204px;
|
||||
padding: 26px 22px;
|
||||
border-radius: 20px;
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.guest-feature-icon {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.guest-feature-title {
|
||||
display: block;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.guest-feature-desc {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
font-size: 24px;
|
||||
line-height: 1.45;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.guest-action-card {
|
||||
margin: 0 24px 24px;
|
||||
padding: 30px 26px;
|
||||
border-radius: 20px;
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.guest-action-title {
|
||||
display: block;
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.guest-action-desc {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
font-size: 25px;
|
||||
line-height: 1.5;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.guest-primary-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 88px;
|
||||
margin-top: 24px;
|
||||
border-radius: 16px;
|
||||
background: #07C160;
|
||||
}
|
||||
|
||||
.guest-primary-btn-text {
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.status-card {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -62,6 +62,11 @@ function formatSleepRange(status: DeviceStatus | null): string {
|
||||
return `${start}-${end}`
|
||||
}
|
||||
|
||||
function goLoginWithRedirect(url = '/pages/device/index') {
|
||||
Taro.setStorageSync('postLoginRedirect', url)
|
||||
Taro.navigateTo({ url: '/pages/login/index' })
|
||||
}
|
||||
|
||||
function formatAlarmTime(value?: string | null): string {
|
||||
if (!value) return '--'
|
||||
const date = new Date(value)
|
||||
@@ -129,6 +134,7 @@ export default function Device() {
|
||||
const [isSavingVolume, setIsSavingVolume] = useState(false)
|
||||
const [sleepWakePending, setSleepWakePending] = useState<'on' | 'off' | null>(null)
|
||||
const [volumeValue, setVolumeValue] = useState(0)
|
||||
const [isGuest, setIsGuest] = useState(false)
|
||||
const volumeCommandInFlightRef = useRef(false)
|
||||
|
||||
useDidShow(() => {
|
||||
@@ -137,11 +143,18 @@ export default function Device() {
|
||||
|
||||
const loadDeviceInfo = async () => {
|
||||
if (!getToken()) {
|
||||
Taro.reLaunch({ url: '/pages/login/index' })
|
||||
setBinding(null)
|
||||
setChild(null)
|
||||
setDeviceStatus(null)
|
||||
setDeviceAlarms([])
|
||||
setVolumeValue(0)
|
||||
setIsGuest(true)
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
setIsLoading(true)
|
||||
setIsGuest(false)
|
||||
try {
|
||||
const context = await loadCurrentChildBindingContext()
|
||||
setChild(context.currentChild)
|
||||
@@ -264,6 +277,52 @@ export default function Device() {
|
||||
)
|
||||
}
|
||||
|
||||
if (isGuest) {
|
||||
return (
|
||||
<View className='device-page'>
|
||||
<View className='guest-hero'>
|
||||
<View className='guest-device-icon'>
|
||||
<Image className='robot-img' src={require('../../assets/tab-icons/robot.png')} mode='aspectFit' />
|
||||
</View>
|
||||
<Text className='guest-title'>伴伴儿童陪伴设备</Text>
|
||||
<Text className='guest-subtitle'>查看设备状态、定位轨迹、亲子消息和休眠管理。浏览功能后,可在需要绑定设备时登录。</Text>
|
||||
</View>
|
||||
|
||||
<View className='guest-feature-grid'>
|
||||
<View className='guest-feature-card'>
|
||||
<Image className='guest-feature-icon' src={require('../../assets/tab-icons/device-icon.png')} mode='aspectFit' />
|
||||
<Text className='guest-feature-title'>设备状态</Text>
|
||||
<Text className='guest-feature-desc'>查看电量、信号、版本和告警记录。</Text>
|
||||
</View>
|
||||
<View className='guest-feature-card'>
|
||||
<Image className='guest-feature-icon' src={require('../../assets/tab-icons/location-icon.png')} mode='aspectFit' />
|
||||
<Text className='guest-feature-title'>定位展示</Text>
|
||||
<Text className='guest-feature-desc'>绑定后可查看设备当前位置。</Text>
|
||||
</View>
|
||||
<View className='guest-feature-card'>
|
||||
<Image className='guest-feature-icon' src={require('../../assets/tab-icons/chat-icon.png')} mode='aspectFit' />
|
||||
<Text className='guest-feature-title'>亲子互动</Text>
|
||||
<Text className='guest-feature-desc'>查看孩子和设备的消息会话。</Text>
|
||||
</View>
|
||||
<View className='guest-feature-card'>
|
||||
<Image className='guest-feature-icon' src={require('../../assets/tab-icons/manage-icon.png')} mode='aspectFit' />
|
||||
<Text className='guest-feature-title'>设备管理</Text>
|
||||
<Text className='guest-feature-desc'>管理孩子资料、绑定设备和休眠设置。</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='guest-action-card'>
|
||||
<Text className='guest-action-title'>准备绑定或管理设备</Text>
|
||||
<Text className='guest-action-desc'>登录后可创建孩子资料、绑定设备并开启完整功能。</Text>
|
||||
<View className='guest-primary-btn' onClick={() => goLoginWithRedirect('/pages/device/index')}>
|
||||
<Text className='guest-primary-btn-text'>登录后继续</Text>
|
||||
</View>
|
||||
</View>
|
||||
{systemBanner}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
if (!child) {
|
||||
return (
|
||||
<View className='device-page'>
|
||||
|
||||
Reference in New Issue
Block a user