diff --git a/src/assets/device/eb15.jpg b/src/assets/device/eb15.jpg new file mode 100644 index 0000000..c1d3413 Binary files /dev/null and b/src/assets/device/eb15.jpg differ diff --git a/src/assets/device/ed713.png b/src/assets/device/ed713.png new file mode 100644 index 0000000..844e67b Binary files /dev/null and b/src/assets/device/ed713.png differ diff --git a/src/assets/device/ed719.png b/src/assets/device/ed719.png new file mode 100644 index 0000000..c8a0447 Binary files /dev/null and b/src/assets/device/ed719.png differ diff --git a/src/pages/device/index.module.scss b/src/pages/device/index.module.scss index 5bd42b0..0999987 100644 --- a/src/pages/device/index.module.scss +++ b/src/pages/device/index.module.scss @@ -165,12 +165,14 @@ .icon { width: 108px; height: 108px; + padding: 14px; border-radius: $radius-circle; background: $color-primary-grad; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; + box-sizing: border-box; } .iconOffline { background: $color-bg-disabled; } @@ -182,6 +184,13 @@ .iconOffline .iconText { color: $color-text-tertiary; } +.iconImg { + width: 80px; + height: 80px; +} + +.iconOffline .iconImg { opacity: 0.5; } + .name { max-width: 100%; font-size: 28px; diff --git a/src/pages/device/index.tsx b/src/pages/device/index.tsx index b25f6ac..650c802 100644 --- a/src/pages/device/index.tsx +++ b/src/pages/device/index.tsx @@ -1,7 +1,7 @@ import { useState, useCallback } from 'react' import { useDidShow } from '@tarojs/taro' import Taro from '@tarojs/taro' -import { View, Text } from '@tarojs/components' +import { View, Text, Image } from '@tarojs/components' import { Navbar } from '@/components/navbar' import { Loading } from '@/components/loading' import { StateView } from '@/components/state-view' @@ -12,10 +12,31 @@ import { getHomeList, type HomeInfo } from '@/api/home' import { resolveCurrentHome, setCurrentHomeId } from '@/store/currentHome' import { ROUTES } from '@/constants/routes' import { navigateTo } from '@/utils/navigation' +import ed713Icon from '@/assets/device/ed713.png' +import ed719Icon from '@/assets/device/ed719.png' +import eb15Icon from '@/assets/device/eb15.jpg' import styles from './index.module.scss' const FALLBACK_ICON = '⌂' +// 设备型号 → 产品图:sub-device 优先(EB15 是 EP832 网关下的子设备, +// 在 deviceModel 中没有对应值,需要走 subDeviceType 分支)。后端有时把型号 +// 放在 deviceModel、有时放 subDeviceType,所以两个字段都查一遍 +const pickDeviceIcon = (device: HomeDevice): string | null => { + const model = device.subDeviceType ?? device.deviceModel + if (model === 'EB15') return eb15Icon + if (model === 'ED713') return ed713Icon + if (model === 'ED719') return ed719Icon + // 调试:未匹配时打印设备型号字段,方便核对后端实际值(确认后移除) + console.log('[ICON] no match', { + installId: device.installId, + deviceModel: device.deviceModel, + subDeviceType: device.subDeviceType, + name: device.name + }) + return null +} + // 设备显示名:优先 name,未命名回落序列号 const deviceLabel = (device: HomeDevice): string => device.name || device.deviceName @@ -207,7 +228,14 @@ export default function DeviceList() { goDetail(device)}> - {FALLBACK_ICON} + {(() => { + const src = pickDeviceIcon(device) + return src ? ( + + ) : ( + {FALLBACK_ICON} + ) + })()} {deviceLabel(device)}