wui-components-v2 1.2.44 → 1.2.45
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.
|
@@ -160,9 +160,8 @@ onShow(() => {
|
|
|
160
160
|
uni.getStorageSync('userInfo')?.sensorCode ||
|
|
161
161
|
''
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
163
|
+
// 进入页面时查询传感器在线状态
|
|
164
|
+
getSensorInfo()
|
|
166
165
|
})
|
|
167
166
|
|
|
168
167
|
// 从返回结果中提取在线状态(兼容 1/0、true/false、嵌套 data 等结构)
|
|
@@ -172,7 +171,7 @@ function resolveSensorStatus(res: any): number {
|
|
|
172
171
|
return Number(value) ? 1 : 0
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
//
|
|
174
|
+
// 获取传感器在线信息:组件内置调用 /data/sensorOnline 接口(req 自动拼接 /Device 前缀)
|
|
176
175
|
async function getSensorInfo(cli?: string) {
|
|
177
176
|
let code = sensorCode.value
|
|
178
177
|
let newCode = code ? code.slice(3) : ''
|
|
@@ -181,17 +180,12 @@ async function getSensorInfo(cli?: string) {
|
|
|
181
180
|
toast.show({ msg: '传感器状态更新中' })
|
|
182
181
|
}
|
|
183
182
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
method: 'GET',
|
|
191
|
-
data: { sensorCode: newCode },
|
|
192
|
-
})
|
|
193
|
-
sensor.value = resolveSensorStatus(res)
|
|
194
|
-
}
|
|
183
|
+
const res = await req({
|
|
184
|
+
url: `/data/sensorOnline`,
|
|
185
|
+
method: 'POST',
|
|
186
|
+
data: { sensorCode: newCode },
|
|
187
|
+
})
|
|
188
|
+
sensor.value = resolveSensorStatus(res)
|
|
195
189
|
if (cli) {
|
|
196
190
|
toast.success({ msg: '传感器状态更新成功' })
|
|
197
191
|
}
|