From 220e4fab27b7f419b3e89e2f2d28ae789aac09d7 Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期四, 08 十月 2026 16:29:55 +0800
Subject: [PATCH] 5种场景模式家长端ok

---
 xiaozhi-esp32-server/main/manager-mobile/src/pages/device/index.vue |   77 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/xiaozhi-esp32-server/main/manager-mobile/src/pages/device/index.vue b/xiaozhi-esp32-server/main/manager-mobile/src/pages/device/index.vue
index ce08cab..79e3737 100644
--- a/xiaozhi-esp32-server/main/manager-mobile/src/pages/device/index.vue
+++ b/xiaozhi-esp32-server/main/manager-mobile/src/pages/device/index.vue
@@ -126,6 +126,14 @@
 }
 
 // 鑾峰彇璁惧绫诲瀷鍚嶇О
+function presenceState(device: Device): 'online' | 'offline' | 'unknown' {
+  if (device.online === true)
+    return 'online'
+  if (device.online === false)
+    return 'offline'
+  return 'unknown'
+}
+
 function getDeviceTypeName(boardKey: string): string {
   const firmwareType = firmwareTypes.value.find(type => type.key === boardKey)
   return firmwareType?.name || boardKey
@@ -209,6 +217,16 @@
     const errorMessage = error?.message || t('device.bindFailed')
     toast.error(errorMessage)
   }
+}
+
+function goToParentTasks(device: Device) {
+  if (!currentAgentId.value || !device?.macAddress) {
+    toast.warning(t('parentTask.bindDeviceFirst'))
+    return
+  }
+  uni.navigateTo({
+    url: `/pages/parent-task/index?agentId=${encodeURIComponent(currentAgentId.value)}&macAddress=${encodeURIComponent(device.macAddress)}`,
+  })
 }
 
 // 鎵撳紑缁戝畾璁惧瀵硅瘽妗�
@@ -397,9 +415,55 @@
             <view class="cursor-pointer bg-[#fbfbfb] p-[32rpx] transition-all duration-200 active:bg-[#f8f9fa]">
               <view class="flex items-start justify-between">
                 <view class="flex-1">
-                  <view class="mb-[16rpx] flex items-center justify-between">
-                    <text class="max-w-[60%] break-all text-[32rpx] text-[#232338] font-semibold">
+                  <view class="mb-[16rpx] flex items-start justify-between gap-[16rpx]">
+                    <text class="max-w-[52%] break-all text-[32rpx] text-[#232338] font-semibold">
                       {{ getDeviceTypeName(device.board) }}
+                    </text>
+                    <view
+                      class="shrink-0 rounded-[24rpx] px-[16rpx] py-[6rpx]"
+                      :class="{
+                        'bg-[#e8f8ef]': presenceState(device) === 'online',
+                        'bg-[#fff1f0]': presenceState(device) === 'offline',
+                        'bg-[#f5f7fb]': presenceState(device) === 'unknown',
+                      }"
+                    >
+                      <text
+                        class="text-[24rpx] font-bold"
+                        :class="{
+                          'text-[#146c36]': presenceState(device) === 'online',
+                          'text-[#d4380d]': presenceState(device) === 'offline',
+                          'text-[#65686f]': presenceState(device) === 'unknown',
+                        }"
+                      >
+                        {{ presenceState(device) === 'online' ? t('device.online') : (presenceState(device) === 'offline' ? t('device.offline') : t('device.checkingOnline')) }}
+                      </text>
+                    </view>
+                  </view>
+                  <view
+                    class="mb-[16rpx] flex items-start gap-[12rpx] rounded-[16rpx] p-[16rpx]"
+                    :class="{
+                      'bg-[#e8f8ef]': presenceState(device) === 'online',
+                      'bg-[#fff1f0]': presenceState(device) === 'offline',
+                      'bg-[#f5f7fb]': presenceState(device) === 'unknown',
+                    }"
+                  >
+                    <view
+                      class="mt-[8rpx] h-[16rpx] w-[16rpx] shrink-0 rounded-full"
+                      :class="{
+                        'bg-[#1aa34a]': presenceState(device) === 'online',
+                        'bg-[#d4380d]': presenceState(device) === 'offline',
+                        'bg-[#c0c4cc]': presenceState(device) === 'unknown',
+                      }"
+                    />
+                    <text
+                      class="text-[24rpx] leading-[1.45]"
+                      :class="{
+                        'text-[#2f6f45]': presenceState(device) === 'online',
+                        'text-[#a8071a]': presenceState(device) === 'offline',
+                        'text-[#65686f]': presenceState(device) === 'unknown',
+                      }"
+                    >
+                      {{ presenceState(device) === 'online' ? t('device.onlineHint') : (presenceState(device) === 'offline' ? t('device.offlineHint') : t('device.checkingOnline')) }}
                     </text>
                   </view>
 
@@ -425,6 +489,15 @@
                       @change="toggleAutoUpdate(device)"
                     />
                   </view>
+                  <view
+                    class="mt-[16rpx] flex items-center justify-between border-[1rpx] border-[#d6e4ff] rounded-[12rpx] bg-[#f5f8ff] p-[16rpx_20rpx]"
+                    @click.stop="goToParentTasks(device)"
+                  >
+                    <text class="text-[28rpx] text-[#336cff] font-medium">
+                      {{ t('parentTask.pageTitle') }}
+                    </text>
+                    <wd-icon name="arrow-right" size="16" color="#336cff" />
+                  </view>
                 </view>
               </view>
             </view>

--
Gitblit v1.9.1