114 lines
4.1 KiB
Plaintext
114 lines
4.1 KiB
Plaintext
<!-- 设备详情页(纯视图,实时数据来自网关) -->
|
|
<view class="container">
|
|
<!-- 设备信息 -->
|
|
<view class="device-info card">
|
|
<view class="info-row">
|
|
<text class="info-label">设备名称</text>
|
|
<text class="info-value">{{device.name || '-'}}</text>
|
|
</view>
|
|
<view class="info-row">
|
|
<text class="info-label">设备编号</text>
|
|
<text class="info-value">{{device.serialNumber || '-'}}</text>
|
|
</view>
|
|
<view class="info-row">
|
|
<text class="info-label">产品ID</text>
|
|
<text class="info-value">{{device.productId || '-'}}</text>
|
|
</view>
|
|
<view class="info-row">
|
|
<text class="info-label">BLE 地址</text>
|
|
<text class="info-value">{{device.deviceId || '-'}}</text>
|
|
</view>
|
|
<view class="info-row">
|
|
<text class="info-label">BLE 状态</text>
|
|
<view class="status-tag {{bleConnected ? 'online' : 'offline'}}">
|
|
{{bleConnected ? '已连接' : '未连接'}}
|
|
</view>
|
|
</view>
|
|
<view class="info-row">
|
|
<text class="info-label">MQTT 状态</text>
|
|
<view class="status-tag {{mqttConnected ? 'online' : 'offline'}}">
|
|
{{mqttConnected ? '已连接' : '未连接'}}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 采集控制 -->
|
|
<view class="collect-control card">
|
|
<view class="collect-row">
|
|
<view class="collect-text">
|
|
<view class="collect-title">启用网关采集</view>
|
|
<view class="collect-sub">开启后自动连接本设备并透传上报;同一时间仅一个设备启用</view>
|
|
</view>
|
|
<switch checked="{{enabled}}" color="#1890ff" bindchange="handleEnableToggle" />
|
|
</view>
|
|
|
|
<view class="collect-status">
|
|
<text class="status-label">采集状态</text>
|
|
<view class="status-tag {{running ? 'online' : 'offline'}}">{{running ? '采集中' : phaseText}}</view>
|
|
</view>
|
|
<view class="collect-meta">
|
|
<text>BLE {{bleConnected ? '已连接' : '未连接'}}</text>
|
|
<text class="dot">·</text>
|
|
<text>MQTT {{mqttConnected ? '已连接' : '未连接'}}</text>
|
|
</view>
|
|
|
|
<view wx:if="{{enabled && !isActive && activeSn}}" class="notice-text">
|
|
网关当前正采集 {{activeSn}},启用本设备后将自动切换
|
|
</view>
|
|
<view wx:if="{{lastError}}" class="notice-text error">{{lastError}}</view>
|
|
</view>
|
|
|
|
<!-- 实时数据 -->
|
|
<view class="data-section">
|
|
<view class="section-header">
|
|
<text class="section-title">实时数据</text>
|
|
</view>
|
|
|
|
<view class="data-list card" wx:if="{{dataList.length > 0}}">
|
|
<view class="data-item" wx:for="{{dataList}}" wx:key="id">
|
|
<view class="data-time">{{item.time}}</view>
|
|
<view class="data-hex">{{item.hex}}</view>
|
|
<view class="data-flag" wx:if="{{item.uploaded}}">
|
|
<text class="uploaded">已上报</text>
|
|
</view>
|
|
<view class="data-flag" wx:else>
|
|
<text class="pending">待上报</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="empty-compact" wx:else>
|
|
<text class="empty-text">{{enabled ? '等待设备上报数据…' : '启用网关采集后可查看实时数据'}}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 统计信息 -->
|
|
<view class="stats-section card">
|
|
<view class="stat-item">
|
|
<text class="stat-value">{{stats.received}}</text>
|
|
<text class="stat-label">接收</text>
|
|
</view>
|
|
<view class="stat-item">
|
|
<text class="stat-value">{{stats.uploaded}}</text>
|
|
<text class="stat-label">已上报</text>
|
|
</view>
|
|
<view class="stat-item">
|
|
<text class="stat-value">{{stats.failed}}</text>
|
|
<text class="stat-label">失败</text>
|
|
</view>
|
|
<view class="stat-item">
|
|
<text class="stat-value">{{offlineCount}}</text>
|
|
<text class="stat-label">离线</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 操作 -->
|
|
<view class="action-group">
|
|
<button class="btn-command" bindtap="handleSendCommand">发送命令</button>
|
|
<button class="btn-flush" bindtap="handleFlushOffline" disabled="{{!mqttConnected || offlineCount === 0}}">
|
|
上传离线({{offlineCount}})
|
|
</button>
|
|
<button class="btn-clear" bindtap="handleClearData">清空数据</button>
|
|
</view>
|
|
</view>
|