wui-components-v2 1.2.44 → 1.2.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/wui-user/wui-user.vue +12 -24
- package/package.json +1 -1
|
@@ -145,24 +145,17 @@ const listenDuration = ref(2) // 单次听音时长,默认2秒
|
|
|
145
145
|
const sensor = ref(0) // 传感器在线状态 1:在线 0:离线
|
|
146
146
|
// 传感器编号:优先外部传入 prop,其次本地缓存 sensorCode,再尝试从 userInfo 缓存读取
|
|
147
147
|
const sensorCode = ref(
|
|
148
|
-
props.sensorCode ||
|
|
149
|
-
uni.getStorageSync('sensorCode') ||
|
|
150
|
-
uni.getStorageSync('userInfo')?.sensorCode ||
|
|
151
|
-
''
|
|
148
|
+
props.sensorCode || uni.getStorageSync('sensorCode') || uni.getStorageSync('userInfo')?.sensorCode || ''
|
|
152
149
|
)
|
|
153
150
|
|
|
154
151
|
onShow(() => {
|
|
155
152
|
// 组件内部获取用户信息(租户名称等),保持独立
|
|
156
153
|
fetchUserInfo()
|
|
157
154
|
if (!props.sensorCode) {
|
|
158
|
-
sensorCode.value =
|
|
159
|
-
uni.getStorageSync('sensorCode') ||
|
|
160
|
-
uni.getStorageSync('userInfo')?.sensorCode ||
|
|
161
|
-
''
|
|
162
|
-
}
|
|
163
|
-
if (props.showSensorStatus) {
|
|
164
|
-
getSensorInfo()
|
|
155
|
+
sensorCode.value = uni.getStorageSync('sensorCode') || uni.getStorageSync('userInfo')?.sensorCode || ''
|
|
165
156
|
}
|
|
157
|
+
// 进入页面时查询传感器在线状态
|
|
158
|
+
getSensorInfo()
|
|
166
159
|
})
|
|
167
160
|
|
|
168
161
|
// 从返回结果中提取在线状态(兼容 1/0、true/false、嵌套 data 等结构)
|
|
@@ -172,7 +165,7 @@ function resolveSensorStatus(res: any): number {
|
|
|
172
165
|
return Number(value) ? 1 : 0
|
|
173
166
|
}
|
|
174
167
|
|
|
175
|
-
//
|
|
168
|
+
// 获取传感器在线信息:组件内置调用 /data/sensorOnline 接口(req 自动拼接 /Device 前缀)
|
|
176
169
|
async function getSensorInfo(cli?: string) {
|
|
177
170
|
let code = sensorCode.value
|
|
178
171
|
let newCode = code ? code.slice(3) : ''
|
|
@@ -181,17 +174,12 @@ async function getSensorInfo(cli?: string) {
|
|
|
181
174
|
toast.show({ msg: '传感器状态更新中' })
|
|
182
175
|
}
|
|
183
176
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
method: 'GET',
|
|
191
|
-
data: { sensorCode: newCode },
|
|
192
|
-
})
|
|
193
|
-
sensor.value = resolveSensorStatus(res)
|
|
194
|
-
}
|
|
177
|
+
const res = await req({
|
|
178
|
+
url: `/data/sensorOnline`,
|
|
179
|
+
method: 'POST',
|
|
180
|
+
data: { sensorCode: newCode },
|
|
181
|
+
})
|
|
182
|
+
sensor.value = resolveSensorStatus(res)
|
|
195
183
|
if (cli) {
|
|
196
184
|
toast.success({ msg: '传感器状态更新成功' })
|
|
197
185
|
}
|
|
@@ -296,7 +284,7 @@ function saveSensorConfig() {
|
|
|
296
284
|
</view>
|
|
297
285
|
|
|
298
286
|
<!-- 传感器状态卡片 -->
|
|
299
|
-
<view v-if="
|
|
287
|
+
<view v-if="isYunyin" class="card-box">
|
|
300
288
|
<view class="card" :class="{ 'card-dark': isDark }">
|
|
301
289
|
<view class="item">
|
|
302
290
|
<text class="label">租户名称</text>
|