diff --git a/components.d.ts b/components.d.ts index b470025..87ef437 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,6 +7,7 @@ export {} declare module 'vue' { export interface GlobalComponents { + ChartFullscreen: typeof import('./src/components/other/chartFullscreen.vue')['default'] CustomNavigationBar: typeof import('./src/components/custom-navigation-bar/index.vue')['default'] Fish: typeof import('./src/components/other/fish.vue')['default'] NutBadge: typeof import('@nutui/nutui-taro')['Badge'] diff --git a/src/api/config.ts b/src/api/config.ts index 6692159..5889ff9 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -31,7 +31,6 @@ const API_PATHS = { }, // 获取短信验证码 SMS_CODE: { - v1: '/resource/sms/code', v2: '/resource/sms/code', }, // 微信手机号登录 @@ -50,23 +49,19 @@ const API_PATHS = { HOME: { // 塘口列表模式1 POND_LIST: { - v1: '/fishery/pond/list', v2: '/fishery/pond/list_mode1', }, // 塘口列表模式2 POND_LIST_MODE2: { - v1: '/api/pond/list_mode2', - v2: '/fishery/pond/list/mode2', + v2: '/fishery/pond/list_mode2', }, // 公告列表 NOTICE_LIST: { - v1: '/api/sys-notice/notice_list', - v2: '/fishery/notice/list', + v2: '/system/notice/list', }, // 即将到期设备列表 DEVICE_DEAD: { - v1: '/api/device/list_device_dead', - v2: '/fishery/device/expiring', + v2: '/fishery/device/list_device_dead', }, // 获取设备票据 DEVICE_TICKET: { @@ -99,12 +94,10 @@ const API_PATHS = { }, // 塘口下设备信息 DEVICE_INFO: { - v1: '/api/pond/pond_device_info', v2: '/fishery/pond/devices', }, // 将设备及开关绑定到塘口 BIND_DEVICE: { - v1: '/api/pond/select_device_switch', v2: '/fishery/pond/bind/device', }, // 夜间防误触 @@ -118,42 +111,34 @@ const API_PATHS = { DEVICE: { // 设备列表 LIST_ALL: { - v1: '/api/device/list_all_device', v2: '/fishery/device/list_all_device', }, // 设备详情 INFO: { - v1: '/api/device/one_device_info', - v2: '/fishery/device/info', + v2: '/fishery/device/one_device_info', }, // 解除绑定 UNBIND: { - v1: '/api/device/break_pond', - v2: '/fishery/device/unbind', + v2: '/fishery/device/break_pond', }, // 设备图表数据 HISTORY: { - v1: '/api/device/data_history', - v2: '/fishery/device/history', + v2: '/td/device/getHistoryData', }, // 修改设备名称 UPDATE_NAME: { - v1: '/api/device/update_name', - v2: '/fishery/device/name', + v2: '/fishery/device/update_name', }, // 修改设备关联塘口 UPDATE_POND: { - v1: '/api/device/update_pond', - v2: '/fishery/device/pond', + v2: '/fishery/pond/update_pond', }, // 修改设备接电方式 UPDATE_VOLTAGE: { - v1: '/api/device/update_voltage_type', - v2: '/fishery/device/voltage', + v2: '/iot/device/voltage_type', }, // 删除设备 DELETE: { - v1: '/api/device/delete', v2: '/fishery/device', }, // 扫描设备编码 @@ -167,13 +152,11 @@ const API_PATHS = { }, // 盐度设置 SET_SALINITY: { - v1: '/api/device/detector_salinitycompensation', - v2: '/fishery/device/salinity', + v2: '/iot/device/salinity-compensation', }, // 设备校准 CALIBRATE: { - v1: '/api/device/detector_calibrate', - v2: '/fishery/device/calibrate', + v2: '/iot/device/calibrate', }, // 添加水质检测仪 ADD_DETECTOR: { @@ -181,38 +164,31 @@ const API_PATHS = { }, // 设置溶解氧/水温告警 SET_WARN_CALL: { - v1: '/api/device/set_oxy_warn_call', - v2: '/fishery/device/warn/call', + v2: '/fishery/device/set_oxy_warn_call', }, // 设置溶解氧上下限 SET_OXY_WARN: { - v1: '/api/device/set_oxy_warn_value', - v2: '/fishery/device/warn/oxy', + v2: '/fishery/device/set_oxy_warn_value', }, // 设置温度上下限 SET_TEMP_WARN: { - v1: '/api/device/set_temp_warn_value', - v2: '/fishery/device/warn/temp', + v2: '/fishery/device/set_temp_warn_value', }, // 溶解氧饱和度 GET_SATURABILITY: { - v1: '/api/device/get_saturability', - v2: '/fishery/device/saturability', + v2: '/fishery/device/get_saturability', }, // 添加控制一体机 ADD_CONTROLLER: { - v1: '/api/device/add_device_controller', v2: '/iot/device/add_device_controller', }, // 启停溶解氧 SET_OXY_OPEN: { - v1: '/api/device/set_controller_oxy_open', - v2: '/fishery/device/oxy/switch', + v2: '/fishery/device/set_controller_oxy_open', }, // 电压告警开关 VOLTAGE_CHECK: { - v1: '/api/device/voltage_check_open', - v2: '/fishery/device/voltage/check', + v2: '/fishery/device/voltage_check_open', }, }, @@ -220,28 +196,23 @@ const API_PATHS = { LINKED_CTRL: { // 设备控制器列表 LIST: { - v1: '/api/linked-ctrl/fetch', - v2: '/fishery/linked-ctrl/list', + v2: '/fishery/linkedCtrl/fetch', }, // 添加联动控制 ADD: { - v1: '/api/linked-ctrl/add', - v2: '/fishery/linked-ctrl', + v2: '/fishery/linkedCtrl/add', }, // 修改联动控制 UPDATE: { - v1: '/api/linked-ctrl/update', - v2: '/fishery/linked-ctrl', + v2: '/fishery/linkedCtrl/update', }, // 删除联动控制 DELETE: { - v1: '/api/linked-ctrl/delete', - v2: '/fishery/linked-ctrl', + v2: '/fishery/linkedCtrl', }, // 设置联动控制上下限开关 SET_OPEN: { - v1: '/api/linked-ctrl/set_open', - v2: '/fishery/linked-ctrl/switch', + v2: '/fishery/linkedCtrl/set_open', }, }, @@ -249,48 +220,39 @@ const API_PATHS = { SWITCH: { // 开关列表 POND_LIST: { - v1: '/api/device-switch/get_pond_switch', - v2: '/fishery/switch/list', + v2: '/fishery/deviceSwitch/get_pond_switch', }, // 开关详情 INFO: { - v1: '/api/device-switch/one_switch_info', - v2: '/fishery/switch/info', + v2: '/fishery/deviceSwitch/one_switch_info', }, // 修改开关名称 UPDATE_NAME: { - v1: '/api/device-switch/update_name', - v2: '/fishery/switch/name', + v2: '/fishery/deviceSwitch/update_name', }, // 修改关联塘口 UPDATE_POND: { - v1: '/api/device-switch/update_pond', - v2: '/fishery/switch/pond', + v2: '/iot/switch/update_pond', }, // 修改接线方式 UPDATE_VOLTAGE: { - v1: '/api/device-switch/update_voltage_type', - v2: '/fishery/switch/voltage', + v2: '/iot/switch/update_voltage_type', }, // 单个开关启停 TURN: { - v1: '/api/device-switch/turn_switch', - v2: '/fishery/switch/turn', + v2: '/iot/switch/turn_switch', }, // 所有开关启停 TURN_POND: { - v1: '/api/device-switch/turn_pond_switch', - v2: '/fishery/switch/turn/all', + v2: '/iot/switch/turn_pond_switch', }, // 电流告警开关 ELECTRIC_CHECK: { - v1: '/api/device-switch/electric_check_open', - v2: '/fishery/switch/electric/check', + v2: '/fishery/deviceSwitch/electric_check_open', }, // 电流告警设置 ELECTRIC_SET: { - v1: '/api/device-switch/electric_set', - v2: '/fishery/switch/electric/set', + v2: '/iot/switch/electric_set', }, }, diff --git a/src/api/device.ts b/src/api/device.ts index fee626d..fdaeec8 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -1,5 +1,6 @@ import httpService from '@/utils/request' import API from './config' +import Taro from '@tarojs/taro' /** 设备相关接口---------------------------------------- */ // 设备列表 @@ -8,27 +9,31 @@ export function allDeviceList(params) { } // 设备详情 export function deviceInfo(data){ - return httpService.post(API.DEVICE.INFO(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.post(`${API.DEVICE.INFO()}?rootUserId=${userId}`, {data}) } // 解除绑定 export function deviceUnbind(data){ - return httpService.post(API.DEVICE.UNBIND(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.post(`${API.DEVICE.UNBIND()}?rootUserId=${userId}`, {data}) } // 将设备及开关绑定到塘口 export function bandDeviceToPond(data){ return httpService.put(API.POND.BIND_DEVICE(), {data}) } // 设备图表数据 -export function deviceHistory(data){ - return httpService.post(API.DEVICE.HISTORY(), {data}) +export function deviceHistory(params){ + return httpService.get(API.DEVICE.HISTORY(), {params}) } // 修改设备名称 export function deviceUpdateName(data){ - return httpService.put(API.DEVICE.UPDATE_NAME(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.put(`${API.DEVICE.UPDATE_NAME()}?rootUserId=${userId}`, {data}) } // 修改设备关联塘口 export function deviceUpdatePond(data){ - return httpService.put(API.DEVICE.UPDATE_POND(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.put(`${API.DEVICE.UPDATE_POND()}?rootUserId=${userId}`, {data}) } // 修改设备接电方式 export function deviceUpdateV(data){ @@ -36,7 +41,8 @@ export function deviceUpdateV(data){ } // 删除设备 export function deviceDel(data){ - return httpService.delete(API.DEVICE.DELETE(), {data}) + // 后端需要 /{ids} 路径参数,传入 ID 数组 + return httpService.delete(`${API.DEVICE.DELETE()}/${data.id}`) } // 扫描设备编码 export function deviceScan(params){ @@ -61,15 +67,18 @@ export function addDeviceDetector(data) { } // 设置溶解氧/水温告警 export function setWarnCall(data){ - return httpService.post(API.DEVICE.SET_WARN_CALL(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.post(`${API.DEVICE.SET_WARN_CALL()}?rootUserId=${userId}`, {data}) } // 设置溶解氧上下限 export function setOxyWarn(data){ - return httpService.put(API.DEVICE.SET_OXY_WARN(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.put(`${API.DEVICE.SET_OXY_WARN()}?rootUserId=${userId}`, {data}) } // 设置温度上下限 export function setTempWarn(data){ - return httpService.put(API.DEVICE.SET_TEMP_WARN(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.put(`${API.DEVICE.SET_TEMP_WARN()}?rootUserId=${userId}`, {data}) } // 溶解氧饱和度 export function getSaturability(data){ @@ -82,7 +91,8 @@ export function addDeviceController(data) { } // 启停溶解氧 export function setOxyOpen(data){ - return httpService.put(API.DEVICE.SET_OXY_OPEN(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.put(`${API.DEVICE.SET_OXY_OPEN()}?rootUserId=${userId}`, {data}) } /** 联动控制------------------------------------- */ // 设备控制器列表 @@ -99,7 +109,9 @@ export function updateLinkerCtrl(data){ } // 删除联动控制 export function delLinkerCtrl(data){ - return httpService.delete(API.LINKED_CTRL.DELETE(), {data}) + const userId = Taro.getStorageSync('UserId'); + // 后端需要 /{ids} 路径参数 + return httpService.delete(`${API.LINKED_CTRL.DELETE()}/${data.id}?rootUserId=${userId}`) } // 设置联动控制上下限开关 export function setLinkOpen(data){ @@ -137,7 +149,8 @@ export function turnPondSwitch(data){ // 电压告警开关 开启或关闭 export function voltageCheckOpen(data){ - return httpService.put(API.DEVICE.VOLTAGE_CHECK(), {data}) + const userId = Taro.getStorageSync('UserId'); + return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data}) } // 电流告警开关 开启或关闭 export function electricCheckOpen(data){ diff --git a/src/api/home.ts b/src/api/home.ts index b2a8c78..940cd70 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -14,7 +14,12 @@ export function getPond1() { // 塘口模式2 export function getPond2(){ - return httpService.get(API.HOME.POND_LIST_MODE2()) + const userId = Taro.getStorageSync("UserId"); + return httpService.get(API.HOME.POND_LIST_MODE2(), { + params: { + rootUserId: userId || undefined + } + }); } // 公告列表 @@ -24,7 +29,12 @@ export function noticeList(){ // 即将到期设备列表 export function deviceDead(){ - return httpService.get(API.HOME.DEVICE_DEAD()) + const userId = Taro.getStorageSync("UserId"); + return httpService.get(API.HOME.DEVICE_DEAD(), { + params: { + rootUserId: userId || undefined + } + }); } // 获取设备票据 diff --git a/src/app.config.ts b/src/app.config.ts index d81411a..bdf1ca3 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -5,6 +5,7 @@ export default defineAppConfig({ 'pages/main/home', 'pages/msg/index', 'pages/main/my', + 'components/other/chartFullscreen', ], requiredPrivateInfos: [ "getLocation", "chooseLocation" diff --git a/src/components/other/chartFullscreen.config.ts b/src/components/other/chartFullscreen.config.ts new file mode 100644 index 0000000..c8bc19c --- /dev/null +++ b/src/components/other/chartFullscreen.config.ts @@ -0,0 +1,5 @@ +export default definePageConfig({ + navigationBarTitleText: '曲线图', + navigationStyle: 'custom', + enablePullDownRefresh: false, +}) diff --git a/src/components/other/chartFullscreen.vue b/src/components/other/chartFullscreen.vue new file mode 100644 index 0000000..34d89d0 --- /dev/null +++ b/src/components/other/chartFullscreen.vue @@ -0,0 +1,388 @@ + + + + + diff --git a/src/components/other/index.vue b/src/components/other/index.vue index 18cf598..14ccbd2 100644 --- a/src/components/other/index.vue +++ b/src/components/other/index.vue @@ -92,7 +92,8 @@ 参数设置 @@ -267,8 +268,11 @@ 7天 - - {{ setTitle }} + + + 放大 + + {{ setTitle }} - - 上限 - - {{ - item.oxyUpperOpen - ? item.oxyUpperValue + "Mg/L" - : "-" - }} - - - - 下限 - - {{ - item.oxyLowerOpen - ? item.oxyLowerValue + "Mg/L" - : "-" - }} - - - - 开关 - - {{ formatName(item.listSwitch) }} + + + + + 联动{{ index + 1 }} + + + + + 上限 + + {{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }} + + + + + 下限 + + {{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }} + + + + + 开关 + + + + {{ sw.switchName }} + + + @@ -941,7 +929,7 @@ Taro.useDidShow(() => { // 查询塘口列表 function getPondList() { getPond2().then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { const arr = [{ id: 0, pondName: "无" }]; res.data.forEach((r) => { arr.push({ id: r.id, pondName: r.pondName }); @@ -953,9 +941,18 @@ function getPondList() { // 设备详情 function getDevInfo() { deviceInfo({ id }).then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { res.data.bindTime = formatDate(new Date(res.data.bindTime)); res.data.deadTime = formatDate(new Date(res.data.deadTime)); + + // 将后端返回的 0/1 转换为布尔值 + res.data.isOxygenUsed = res.data.isOxygenUsed === 1; + res.data.oxyWarnTelOpen = res.data.oxyWarnTelOpen === 1; + res.data.oxyWarnTelNoDis = res.data.oxyWarnTelNoDis === 1; + res.data.tempWarnTelOpen = res.data.tempWarnTelOpen === 1; + res.data.tempWarnTelNoDis = res.data.tempWarnTelNoDis === 1; + res.data.voltageWarnOpen = res.data.voltageWarnOpen === 1; + deviceInfoRes.value = res.data; pondId.value = res.data.pondInfo ? [res.data.pondInfo.id] : [0]; voltageType.value = res.data.inputVoltage; @@ -980,7 +977,7 @@ function unbind() { success: function (res) { if (res.confirm) { deviceDel({ id }).then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "解绑成功"; setTimeout(() => { @@ -1025,7 +1022,7 @@ function confirm({ selectedValue, selectedOptions }) { }; deviceUpdatePond(data) .then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1044,10 +1041,11 @@ function changeO2(value, event) { const data = { deviceId: id, type: 1, - isOpen: deviceInfoRes.value.oxyWarnTelOpen, + isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, + isNoDisturb: deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1059,10 +1057,11 @@ function changeTem(value, event) { const data = { deviceId: id, type: 2, - isOpen: deviceInfoRes.value.tempWarnTelOpen, + isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, + isNoDisturb: deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1086,7 +1085,7 @@ function setOxyEvent() { oxyWarnLower: oxy.value, }; setOxyWarn(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.oxyWarnLower = oxy.value; @@ -1101,7 +1100,7 @@ function setNameEvent() { newName: deviceName.value, }; deviceUpdateName(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.deviceName = deviceName.value; @@ -1122,7 +1121,7 @@ function setTempEvent() { tempWarnUpper: tempUp.value, }; setTempWarn(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.tempWarnUpper = tempUp.value; @@ -1156,7 +1155,7 @@ function setNameSwitchEvent() { newName: switchName.value, }; updateSwitchName(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; openSetNameSwitch.value = false; @@ -1204,9 +1203,10 @@ function setSalinity() { salinityCompensation: salinity.value, }; setSal(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; + deviceInfoRes.value.salinityCompensation = salinity.value; openSalinity.value = false; } }); @@ -1222,7 +1222,7 @@ function removeDev() { success: function (res) { if (res.confirm) { deviceUnbind({ id }).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { // alertRes.value = true state.show = true; state.msg = "移除成功"; @@ -1242,13 +1242,13 @@ function changeTemDis(value, event) { const data = { deviceId: id, type: 2, - isOpen: deviceInfoRes.value.tempWarnTelOpen, + isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, isNoDisturb: deviceInfoRes.value.tempWarnTelOpen - ? deviceInfoRes.value.tempWarnTelNoDis - : false, + ? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) + : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1265,10 +1265,10 @@ function changeIsOxygenUsed(value, event) { if (event) { const data = { id: id, - isOpen: deviceInfoRes.value.isOxygenUsed, + isOpen: deviceInfoRes.value.isOxygenUsed ? 1 : 0, }; setOxyOpen(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1277,11 +1277,11 @@ function changeIsOxygenUsed(value, event) { } function setTypeEvent() { const data = { - id: Number(id), + id: id, voltageType: voltageType.value, }; deviceUpdateV(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.inputVoltage = voltageType.value; @@ -1295,10 +1295,10 @@ function changeV(value, event) { if (event) { const data = { id: id, - isOpen: deviceInfoRes.value.voltageWarnOpen, + isOpen: deviceInfoRes.value.voltageWarnOpen ? 1 : 0, }; voltageCheckOpen(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1310,13 +1310,13 @@ function changeOxyDis(value, event) { const data = { deviceId: id, type: 1, - isOpen: deviceInfoRes.value.oxyWarnTelOpen, + isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen - ? deviceInfoRes.value.oxyWarnTelNoDis - : false, + ? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) + : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1448,4 +1448,82 @@ function changeOxyDis(value, event) { color: #17b4b2; font-size: 28px; } + +/* 联动控制表格优化样式 */ +.linked-table { + width: 100%; + border-radius: 8px; + overflow: hidden; + background: #fff; +} + +.table-row { + display: flex; + border-bottom: 1px solid #f0f0f0; + + &:last-child { + border-bottom: none; + } +} + +.table-header { + background: #f8f8f8; + font-weight: bold; + + .table-cell { + color: #666; + font-size: 26rpx; + } +} + +.table-cell { + flex: 1; + padding: 20rpx 10rpx; + text-align: center; + border-right: 1px solid #f0f0f0; + display: flex; + align-items: center; + justify-content: center; + min-height: 80rpx; + + &:last-child { + border-right: none; + } +} + +.table-label { + flex: 0 0 100rpx; + background: #fafafa; + font-size: 28rpx; + color: #333; + font-weight: 500; +} + +.table-value { + color: #17b4b2; + font-size: 28rpx; + font-weight: 500; +} + +.table-switch { + padding: 10rpx; +} + +.switch-names { + display: flex; + flex-direction: column; + gap: 8rpx; + width: 100%; +} + +.switch-name { + font-size: 24rpx; + color: #17b4b2; + padding: 6rpx 10rpx; + background: #f5f5f5; + border-radius: 4rpx; + line-height: 1.4; + word-break: break-all; + text-align: center; +} diff --git a/src/home/linkControl.vue b/src/home/linkControl.vue index 1fd8af8..03967fa 100644 --- a/src/home/linkControl.vue +++ b/src/home/linkControl.vue @@ -55,14 +55,13 @@ > {{ item.oxyUpperValue ? item.oxyUpperValue : "-" }}Mg/L - + + + @@ -85,14 +84,13 @@ > {{ item.oxyLowerValue ? item.oxyLowerValue : "-" }}Mg/L - + + + @@ -487,13 +485,6 @@ const themeVars = ref({ cellBorderRadius: "4px", cellBoxShadow: "0px", cellPadding: "26rpx 0px", - SwitchWidth: "112rpx", - SwitchHeight: "56rpx", - SwitchLineHeight: "56rpx", - SwitchInsideHeight: "40rpx", - SwitchInsideWidth: "40rpx", - SwitchInsideOpenTransform: "translateX(155%)", - SwitchInsideCloseTransform: "translateX(20%)", }); const themeVars2 = ref({ cellBoxShadow: "0px 0px 0px 0px", @@ -545,10 +536,18 @@ Taro.useDidShow(() => { // 查询联动控制 function getLinksList() { linkerCtrlList({ id }).then((res) => { - if (res.statusCode == 200) { + console.log('完整返回数据:', JSON.stringify(res, null, 2)); + if (res.code == 200) { if (res.data) { res.data.forEach((item, index) => { + console.log(`联动控制${index + 1}完整数据:`, JSON.stringify(item, null, 2)); item.name = "联动控制" + (index + 1); + // 调试:查看原始数据 + console.log('原始数据:', item.oxyUpperOpen, item.oxyLowerOpen, typeof item.oxyUpperOpen); + // 将后端返回的 0/1 转换为布尔类型 - 强制设置为 true 或 false + item.oxyUpperOpen = item.oxyUpperOpen === 1 ? true : false; + item.oxyLowerOpen = item.oxyLowerOpen === 1 ? true : false; + console.log('转换后:', item.oxyUpperOpen, item.oxyLowerOpen, typeof item.oxyUpperOpen); const switchName: any = []; if (item.listSwitch && item.listSwitch.length > 0) { item.listSwitch.forEach((r: any) => { @@ -559,13 +558,14 @@ function getLinksList() { }); } linkList.value = res.data || []; + console.log('最终linkList:', JSON.stringify(linkList.value, null, 2)); } }); } // 开关列表 function getSwitchList(type = undefined,id=undefined) { pondSwitchList({ id: pondId }).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { if (res.data.length > 0) { res.data.forEach((r) => { if (r.deviceType == 2) { @@ -639,7 +639,7 @@ function remove(name, id) { success: function (res) { if (res.confirm) { delLinkerCtrl({ id }).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "删除成功"; getLinksList(); @@ -715,7 +715,7 @@ function addHandler() { if (params.value.id) { updateLinkerCtrl(params.value) .then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "编辑成功"; getLinksList(); @@ -728,7 +728,7 @@ function addHandler() { } else { addLinkerCtrl(params.value) .then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "添加成功"; getLinksList(); @@ -808,7 +808,7 @@ function setUpSwitch({ value, event }, item: any) { const data = { id: item.id, openType: 1, - isOpen: item.oxyUpperOpen, + isOpen: item.oxyUpperOpen ? 1 : 0, // 布尔转数字 }; switchParams.value = data; if (item.oxyUpperOpen) { @@ -823,7 +823,7 @@ function setLoSwitch({ value, event }, item: any) { const data = { id: item.id, openType: 2, - isOpen: item.oxyLowerOpen, + isOpen: item.oxyLowerOpen ? 1 : 0, // 布尔转数字 }; switchParams.value = data; if (item.oxyLowerOpen) { @@ -845,12 +845,21 @@ function setSwitchOpenNone() { function setSwitchOpen(data) { setLinkOpen(data) .then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; const tag = data.isOpen ? "开启" : "关闭"; state.msg = tag + "成功"; + // 重新加载列表以同步状态 + getLinksList(); + } else { + // 失败时恢复开关状态 + getLinksList(); } }) + .catch(() => { + // 错误时恢复开关状态 + getLinksList(); + }) .finally(() => { openAlert.value = false; }); @@ -962,7 +971,7 @@ function updateOxy(item) { function upHandler() { updateLinkerCtrl(params.value) .then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "编辑成功"; getLinksList(); diff --git a/src/home/switch.vue b/src/home/switch.vue index 865ed0d..d41dfd2 100644 --- a/src/home/switch.vue +++ b/src/home/switch.vue @@ -325,7 +325,7 @@ import Taro from "@tarojs/taro"; import { imgUrl } from "@/utils/imgUrl"; const r_v = `${imgUrl}r_v.png`; const instance = Taro.getCurrentInstance(); -const id = Number(instance.router.params.id); +const id = (instance.router.params.id); // const id = 21; const name = instance.router.params.name; Taro.setNavigationBarTitle({ @@ -393,7 +393,7 @@ Taro.useDidShow(() => { // 查询塘口列表 function getPondList() { getPond2().then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { const arr = [{ id: 0, pondName: "无" }]; res.data.forEach((r) => { arr.push({ id: r.id, pondName: r.pondName }); @@ -405,7 +405,11 @@ function getPondList() { // 开关详情 function getSwitchInfo() { switchInfo({ id }).then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { + // 将后端返回的 0/1 转换为布尔值 + res.data.voltageWarnOpen = res.data.voltageWarnOpen === 1; + res.data.electricWarnOpen = res.data.electricWarnOpen === 1; + switchInfoRes.value = res.data; pondId.value = res.data.pondInfo ? [Number(res.data.pondInfo.id)] : []; voltageType.value = res.data.connectVoltageType ? res.data.connectVoltageType : 1; @@ -426,7 +430,7 @@ function confirm({ selectedValue, selectedOptions }) { }; updateSwitchPond(data) .then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -451,7 +455,7 @@ function setVEvent() { electric: Number(V.value), }; electricSet(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; switchInfoRes.value.rateElectricValue = V.value; @@ -474,7 +478,7 @@ function setTypeEvent() { voltageType: voltageType.value, }; updateSwitchType(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; switchInfoRes.value.connectVoltageType = voltageType.value; @@ -503,10 +507,10 @@ function changeV(value, event) { if (event) { const data = { id: id, - isOpen: switchInfoRes.value.voltageWarnOpen, + isOpen: switchInfoRes.value.voltageWarnOpen ? 1 : 0, // 布尔转数字 }; voltageCheckOpen(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -517,10 +521,10 @@ function changeE(value, event) { if (event) { const data = { id: id, - isOpen: switchInfoRes.value.electricWarnOpen, + isOpen: switchInfoRes.value.electricWarnOpen ? 1 : 0, // 布尔转数字 }; electricCheckOpen(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } diff --git a/src/home/wqm.vue b/src/home/wqm.vue index 830811a..ddf0350 100644 --- a/src/home/wqm.vue +++ b/src/home/wqm.vue @@ -261,62 +261,58 @@ > - - 上限 - - {{ item.oxyUpperOpen?item.oxyUpperValue+'Mg/L':'-' }} - - - - 下限 - - {{ item.oxyLowerOpen?item.oxyLowerValue+'Mg/L':'-' }} - - - - 开关 - - {{ formatName(item.listSwitch) }} + + + + + 联动{{ index + 1 }} + + + + + 上限 + + {{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }} + + + + + 下限 + + {{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }} + + + + + 开关 + + + + {{ sw.switchName }} + + + @@ -773,7 +769,7 @@ Taro.useDidShow(() => { // 查询塘口列表 function getPondList() { getPond2().then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { const arr = [{ id: 0, pondName: "无" }]; res.data.forEach(r=>{ arr.push({id:r.id,pondName:r.pondName}) @@ -785,9 +781,17 @@ function getPondList() { // 设备详情 function getDevInfo() { deviceInfo({ id }).then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { res.data.bindTime = formatDate(new Date(res.data.bindTime)); res.data.deadTime = formatDate(new Date(res.data.deadTime)); + + // 将数字类型转为布尔类型 + res.data.oxyWarnTelOpen = !!res.data.oxyWarnTelOpen; + res.data.oxyWarnTelNoDis = !!res.data.oxyWarnTelNoDis; + res.data.tempWarnTelOpen = !!res.data.tempWarnTelOpen; + res.data.tempWarnTelNoDis = !!res.data.tempWarnTelNoDis; + res.data.isOxygenUsed = !!res.data.isOxygenUsed; + deviceInfoRes.value = res.data; pondId.value = res.data.pondInfo ? [Number(res.data.pondInfo.id)] : [0]; } @@ -814,7 +818,7 @@ function unbind() { if (res.confirm) { b_isLoading.value = true deviceDel({ id }).then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "解绑成功"; setTimeout(() => { @@ -864,7 +868,7 @@ console.log(selectedValue) }; deviceUpdatePond(data) .then((res: any) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -883,13 +887,13 @@ function changeO2(value, event) { const data = { deviceId: id, type: 1, - isOpen: deviceInfoRes.value.oxyWarnTelOpen, + isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, // 布尔转数字 isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen - ? deviceInfoRes.value.oxyWarnTelNoDis - : false, + ? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) // 布尔转数字 + : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -901,13 +905,13 @@ function changeTem(value, event) { const data = { deviceId: id, type: 2, - isOpen: deviceInfoRes.value.tempWarnTelOpen, + isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, // 布尔转数字 isNoDisturb: deviceInfoRes.value.tempWarnTelOpen - ? deviceInfoRes.value.tempWarnTelNoDis - : false, + ? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) // 布尔转数字 + : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -942,7 +946,7 @@ function setOxyEvent() { oxyWarnLower: oxy.value, }; setOxyWarn(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.oxyWarnLower = oxy.value; @@ -957,11 +961,12 @@ function setNameEvent() { newName: deviceName.value, }; deviceUpdateName(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; - deviceInfoRes.value.deviceName = deviceName.value; openSetName.value = false; + // 重新加载设备信息 + getDevInfo(); } }); } @@ -995,7 +1000,7 @@ function setTempEvent() { tempWarnUpper: tempUp.value, }; setTempWarn(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.tempWarnUpper = tempUp.value; @@ -1035,7 +1040,7 @@ function setSalinity() { salinityCompensation: salinity.value ? Number(salinity.value) : 0, }; setSal(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; deviceInfoRes.value.salinityCompensation = salinity.value; @@ -1053,13 +1058,13 @@ function changeOxyDis(value, event) { const data = { deviceId: id, type: 1, - isOpen: deviceInfoRes.value.oxyWarnTelOpen, + isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, // 布尔转数字 isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen - ? deviceInfoRes.value.oxyWarnTelNoDis - : false, + ? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) // 布尔转数字 + : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } @@ -1072,46 +1077,19 @@ function changeTemDis(value, event) { const data = { deviceId: id, type: 2, - isOpen: deviceInfoRes.value.tempWarnTelOpen, + isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, // 布尔转数字 isNoDisturb: deviceInfoRes.value.tempWarnTelOpen - ? deviceInfoRes.value.tempWarnTelNoDis - : false, + ? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) // 布尔转数字 + : 0, }; setWarnCall(data).then((res) => { - if (res.statusCode == 200) { + if (res.code == 200) { state.show = true; state.msg = "设置成功"; } }); } } -// 移除设备 -function removeDev() { - Taro.showModal({ - title: "提示", - content: - "移除后会将设备从塘口移除,并和塘口内的其他设备解除关联关系。确认移除该设备?", - success: function (res) { - if (res.confirm) { - r_isLoading.value = true - deviceUnbind({ id }).then((res) => { - if (res.statusCode == 200) { - // alertRes.value = true - state.show = true; - state.msg = "移除成功"; - deviceInfoRes.value.pondInfo = { - id: 0, - pondName: "请绑定塘口", - }; - } - }).finally(() => { - r_isLoading.value = false - }) - } else if (res.cancel) { - } - }, - }); -} // 返回上一页 function onGoBack() { Taro.navigateBack({ delta: 1 }); @@ -1248,4 +1226,82 @@ function onblur() { color: #17b4b2; font-size: 28px; } + +/* 联动控制表格优化样式 */ +.linked-table { + width: 100%; + border-radius: 8px; + overflow: hidden; + background: #fff; +} + +.table-row { + display: flex; + border-bottom: 1px solid #f0f0f0; + + &:last-child { + border-bottom: none; + } +} + +.table-header { + background: #f8f8f8; + font-weight: bold; + + .table-cell { + color: #666; + font-size: 26rpx; + } +} + +.table-cell { + flex: 1; + padding: 20rpx 10rpx; + text-align: center; + border-right: 1px solid #f0f0f0; + display: flex; + align-items: center; + justify-content: center; + min-height: 80rpx; + + &:last-child { + border-right: none; + } +} + +.table-label { + flex: 0 0 100rpx; + background: #fafafa; + font-size: 28rpx; + color: #333; + font-weight: 500; +} + +.table-value { + color: #17b4b2; + font-size: 28rpx; + font-weight: 500; +} + +.table-switch { + padding: 10rpx; +} + +.switch-names { + display: flex; + flex-direction: column; + gap: 8rpx; + width: 100%; +} + +.switch-name { + font-size: 24rpx; + color: #17b4b2; + padding: 6rpx 10rpx; + background: #f5f5f5; + border-radius: 4rpx; + line-height: 1.4; + word-break: break-all; + text-align: center; +} diff --git a/src/my/deviceRecharge.vue b/src/my/deviceRecharge.vue index 6b91bc0..a4b6c68 100644 --- a/src/my/deviceRecharge.vue +++ b/src/my/deviceRecharge.vue @@ -397,8 +397,9 @@ function getPayItem() { } // 设备列表 function getDeviceList() { - allDeviceList({ type: 1 }).then((res: any) => { - if (res.statusCode == 200) { + const userId = Taro.getStorageSync("UserId"); + allDeviceList({ type: 1,rootUserId:userId }).then((res: any) => { + if (res.code == 200) { res.data.forEach((item: any) => { const deadDay = daysBeforeToday(formatDate(new Date(item.deadTime))); item.deadDay = deadDay diff --git a/src/pages/main/home.vue b/src/pages/main/home.vue index 89824f2..3544930 100644 --- a/src/pages/main/home.vue +++ b/src/pages/main/home.vue @@ -504,16 +504,16 @@ - {{ item.content }} + 发布时间:{{ formatDateString(item.createdTime, "yyyy-mm-dd") }}发布时间:{{ formatDateString(item.createTime, "yyyy-mm-dd") }} @@ -768,17 +768,17 @@ function getNotice(openType = 0) { noticeList().then((res) => { if (res.code == 200) { const nList: any = []; - noticeRows.value = res.data.sort(sortByField("priority", false)); + noticeRows.value = res.rows.sort(sortByField("priority", false)); if (noticeRows.value.length > 0) { noticeRows.value.forEach((item: AnalyserOptions) => { - const content: string = `${item.title}:${item.content}`; + const content: string = `${item.noticeTitle}:${item.noticeContent}`; nList.push(content); }); if (openType == 0) { notice.value = nList[0]; if (store.getNoticeRead == 0) { noticeOpen.value = true; - } else if (store.getNoticeRead != noticeRows.value[0]["createdTime"]) { + } else if (store.getNoticeRead != noticeRows.value[0]["createTime"]) { noticeOpen.value = true; } else { noticeOpen.value = false; @@ -1222,9 +1222,9 @@ function closeNotice() { noticeOpen.value = false; if (noticeRows.value.length > 0) { if (store.getNoticeRead == 0) { - store.updateNoticeRead(noticeRows.value[0]["createdTime"]); - } else if (store.getNoticeRead != noticeRows.value[0]["createdTime"]) { - store.updateNoticeRead(noticeRows.value[0]["createdTime"]); + store.updateNoticeRead(noticeRows.value[0]["createTime"]); + } else if (store.getNoticeRead != noticeRows.value[0]["createTime"]) { + store.updateNoticeRead(noticeRows.value[0]["createTime"]); } } else { store.updateNoticeRead(0); diff --git a/src/utils/request.ts b/src/utils/request.ts index 5f91724..8fbe6bf 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -8,7 +8,8 @@ const timeOutSeconds = 10000; const getBaseUrl = () => { let BASE_URL = '' if (process.env.TARO_ENV === 'h5') { - BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 + BASE_URL = 'https://www.qdintc.com/fishery-api' // 线上调试后端 + // BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 } else { BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名 // BASE_URL = 'https://dev.yuceyun.cn' //测试环境