上传小程序修改合入
This commit is contained in:
@@ -348,6 +348,14 @@
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.empty-subtitle {
|
||||
display: block;
|
||||
margin-top: 16px;
|
||||
font-size: 26px;
|
||||
line-height: 1.6;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.empty-btn {
|
||||
margin-top: 28px;
|
||||
height: 92px;
|
||||
@@ -378,3 +386,46 @@
|
||||
font-weight: 600;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.child-focus-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #FFFFFF;
|
||||
border-radius: 24px;
|
||||
margin: 0 24px 24px;
|
||||
padding: 28px 24px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.child-focus-avatar {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
border-radius: 50%;
|
||||
background: #FEF3E8;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.child-focus-icon {
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.child-focus-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.child-focus-name {
|
||||
display: block;
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.child-focus-desc {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 26px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import { View, Text, Switch, Slider, Image } from '@tarojs/components'
|
||||
import { useState } from 'react'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { getToken } from '@/services/auth'
|
||||
import { Binding, resolveActiveBinding } from '@/services/binding'
|
||||
import { Child, getChild } from '@/services/child'
|
||||
import { Binding, loadCurrentChildBindingContext } from '@/services/binding'
|
||||
import { Child } from '@/services/child'
|
||||
import './index.scss'
|
||||
|
||||
export default function Device() {
|
||||
@@ -25,20 +25,9 @@ export default function Device() {
|
||||
|
||||
setIsLoading(true)
|
||||
try {
|
||||
const activeBinding = await resolveActiveBinding()
|
||||
setBinding(activeBinding)
|
||||
|
||||
if (activeBinding?.child_id) {
|
||||
try {
|
||||
const currentChild = await getChild(activeBinding.child_id)
|
||||
setChild(currentChild)
|
||||
} catch (error) {
|
||||
console.error('[device] load child failed:', error)
|
||||
setChild(null)
|
||||
}
|
||||
} else {
|
||||
setChild(null)
|
||||
}
|
||||
const context = await loadCurrentChildBindingContext()
|
||||
setChild(context.currentChild)
|
||||
setBinding(context.currentBinding)
|
||||
} catch (error: any) {
|
||||
console.error('[device] load failed:', error)
|
||||
Taro.showToast({
|
||||
@@ -72,7 +61,7 @@ export default function Device() {
|
||||
)
|
||||
}
|
||||
|
||||
if (!binding) {
|
||||
if (!child) {
|
||||
return (
|
||||
<View className='device-page'>
|
||||
<View className='page-header'>
|
||||
@@ -83,7 +72,39 @@ export default function Device() {
|
||||
<View className='empty-robot'>
|
||||
<Image className='robot-img' src={require('../../assets/tab-icons/robot.png')} mode='aspectFit' />
|
||||
</View>
|
||||
<Text className='empty-title'>先绑定一台伴伴设备</Text>
|
||||
<Text className='empty-title'>先添加一个儿童资料</Text>
|
||||
<Text className='empty-subtitle'>添加后才能为孩子绑定专属设备并查看聊天和定位信息</Text>
|
||||
<View className='empty-btn' onClick={() => Taro.switchTab({ url: '/pages/sleep/index' })}>
|
||||
<Text className='empty-btn-text'>去添加孩子</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
if (!binding) {
|
||||
return (
|
||||
<View className='device-page'>
|
||||
<View className='page-header'>
|
||||
<Text className='page-title'>{child.child_name} 的伴伴</Text>
|
||||
</View>
|
||||
|
||||
<View className='child-focus-card'>
|
||||
<View className='child-focus-avatar'>
|
||||
<Text className='child-focus-icon'>🧒</Text>
|
||||
</View>
|
||||
<View className='child-focus-info'>
|
||||
<Text className='child-focus-name'>{child.child_name}</Text>
|
||||
<Text className='child-focus-desc'>当前孩子已选中,还没有绑定设备</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='empty-card'>
|
||||
<View className='empty-robot'>
|
||||
<Image className='robot-img' src={require('../../assets/tab-icons/robot.png')} mode='aspectFit' />
|
||||
</View>
|
||||
<Text className='empty-title'>给当前孩子绑定一台设备</Text>
|
||||
<Text className='empty-subtitle'>绑定后,这个孩子的聊天记录、定位和设备状态都会显示在首页</Text>
|
||||
<View className='empty-btn' onClick={() => Taro.navigateTo({ url: '/pages/bind/index' })}>
|
||||
<Text className='empty-btn-text'>去绑定设备</Text>
|
||||
</View>
|
||||
@@ -92,8 +113,8 @@ export default function Device() {
|
||||
)
|
||||
}
|
||||
|
||||
const childName = child?.child_name || '未设置'
|
||||
const pageTitle = child?.child_name ? `${child.child_name} 的伴伴` : '伴伴设备'
|
||||
const childName = child.child_name || '未设置'
|
||||
const pageTitle = `${childName} 的伴伴`
|
||||
const battery = 82
|
||||
const daysLeft = 4
|
||||
|
||||
@@ -106,7 +127,7 @@ export default function Device() {
|
||||
<View className='status-card'>
|
||||
<View className='status-badge'>
|
||||
<View className='status-dot'></View>
|
||||
<Text className='status-text'>{binding.child_id ? '已完成绑定' : '待关联儿童'}</Text>
|
||||
<Text className='status-text'>已完成绑定</Text>
|
||||
</View>
|
||||
<View className='battery-section'>
|
||||
<Text className='battery-percent'>
|
||||
@@ -124,12 +145,12 @@ export default function Device() {
|
||||
|
||||
<View className='detail-card'>
|
||||
<View className='detail-row'>
|
||||
<Text className='detail-label'>设备号</Text>
|
||||
<Text className='detail-value'>{binding.device_id}</Text>
|
||||
<Text className='detail-label'>当前儿童</Text>
|
||||
<Text className='detail-value'>{childName}</Text>
|
||||
</View>
|
||||
<View className='detail-row'>
|
||||
<Text className='detail-label'>儿童昵称</Text>
|
||||
<Text className='detail-value'>{childName}</Text>
|
||||
<Text className='detail-label'>当前设备</Text>
|
||||
<Text className='detail-value'>{binding.device_id}</Text>
|
||||
</View>
|
||||
<View className='detail-row'>
|
||||
<Text className='detail-label'>绑定时间</Text>
|
||||
@@ -195,12 +216,6 @@ export default function Device() {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{!binding.child_id && (
|
||||
<View className='helper-card' onClick={() => Taro.navigateTo({ url: '/pages/bind/index' })}>
|
||||
<Text className='helper-title'>继续完成儿童关联</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user