fix: 后端接口对接,问题修复。

This commit is contained in:
tianyongbao
2026-01-12 18:48:03 +08:00
parent 2e9609292e
commit 6d1a6ded2d
8 changed files with 281 additions and 55 deletions

View File

@@ -386,7 +386,31 @@ definePageConfig({
const instance = Taro.getCurrentInstance();
const r = instance.router.params.params;
const page = instance.router.params.page;
const params = r ? JSON.parse(r) : undefined;
console.log('URL参数原始值', r);
let params: any = undefined;
try {
if (r) {
// URL解码后再解析JSON
const decodedParams = decodeURIComponent(r);
console.log('URL解码后', decodedParams);
params = JSON.parse(decodedParams);
console.log('解析后的参数', params);
} else {
console.error('未获取到params参数');
}
} catch (e) {
console.error('参数解析失败', e, '原始参数:', r);
// 参数解析失败,显示提示后返回
Taro.showModal({
title: '提示',
content: '参数错误,请重新进入',
showCancel: false,
success: () => {
Taro.navigateBack();
}
});
}
const check = `https://www.yuceyun.cn/wechat/check.png`;
const check_a = `https://www.yuceyun.cn/wechat/check_a.png`;
const r_v = `https://www.yuceyun.cn/wechat/r_v.png`;
@@ -434,14 +458,22 @@ const waterType = ref<number>(1);
/** ----------------metod start------------------ */
// 监测设备在线状态
function getCheckDevice() {
if (!params) {
console.error('params参数为空');
state.show = true;
state.msg = '参数错误';
return;
}
const data = {
devicetype: params.devType,
serialnum: params.devNum,
};
console.log('检查设备状态', data);
isLoading.value = true;
checkDeviceStatus(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
status.value = res.data;
if (status.value == 0) {
state.show = true;
@@ -454,6 +486,9 @@ function getCheckDevice() {
} else if (status.value == 8) {
state.show = true;
state.msg = "设备禁用";
} else {
state.show = true;
state.msg = "设备异常";
}
}
})
@@ -462,6 +497,12 @@ function getCheckDevice() {
});
}
function next() {
if (!params) {
state.show = true;
state.msg = '参数错误';
return;
}
const num = current.value;
if (num == 4) {
// 验证参数,发起添加设备请求
@@ -502,8 +543,9 @@ function next() {
listPutPondPartId: listPutPondPartId.value,
isOxygenUsed:isHave.value==1?true:false
};
console.log('添加设备数据', data);
addDeviceController(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
Taro.redirectTo({
url: "/my/addDevSuccess?name=添加测控一体机&page=" + page,
});