diff --git a/src/api/device.ts b/src/api/device.ts index 68ddf91..484628d 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -68,7 +68,9 @@ export function deviceCalibration(data){ /** 水质检测仪------------------------------------------------ */ // 添加-水质检测仪 export function addDeviceDetector(data) { - return httpService.post(API.DEVICE.ADD_DETECTOR(), {data}) + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); + return httpService.post(`${API.DEVICE.ADD_DETECTOR()}?rootUserId=${userId}`, {data}) } // 设置溶解氧/水温告警 export function setWarnCall(data){ @@ -95,7 +97,9 @@ export function getSaturability(data){ /** 控制一体机------------------------------------------------ */ // 添加-控制一体机 export function addDeviceController(data) { - return httpService.post(API.DEVICE.ADD_CONTROLLER(), {data}) + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); + return httpService.post(`${API.DEVICE.ADD_CONTROLLER()}?rootUserId=${userId}`, {data}) } // 启停溶解氧 export function setOxyOpen(data){ diff --git a/src/api/msg.ts b/src/api/msg.ts index 9085d33..20e0aca 100644 --- a/src/api/msg.ts +++ b/src/api/msg.ts @@ -1,20 +1,28 @@ import httpService from '@/utils/request' import API from './config' +import Taro from '@tarojs/taro' +import { useRootUserStore } from '@/store/index' // 查询充值记录 export function msgPay(data) { - return httpService.get(API.MESSAGE.PAY(), { params: data }) + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); + return httpService.get(API.MESSAGE.PAY(), { params: { ...data, rootUserId: userId } }) } // 查询报警记录 export function msgWarn(data) { + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); // 后端接口:GET /fishery/messageWarn/list,使用查询参数传递分页信息 - return httpService.get(API.MESSAGE.WARN(), { params: data }) + return httpService.get(API.MESSAGE.WARN(), { params: { ...data, rootUserId: userId } }) } // 查询开关记录 export function msgSwitch(data) { - return httpService.get(API.MESSAGE.SWITCH(), { params: data }) + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); + return httpService.get(API.MESSAGE.SWITCH(), { params: { ...data, rootUserId: userId } }) } // 已读一条消息 diff --git a/src/api/pond.ts b/src/api/pond.ts index e627c41..921eadb 100644 --- a/src/api/pond.ts +++ b/src/api/pond.ts @@ -1,5 +1,8 @@ import httpService from '@/utils/request' import API from './config' +import Taro from '@tarojs/taro' +import { useRootUserStore } from '@/store/index' + // 新增塘口 export function PondAdd(data) { return httpService.post(API.POND.ADD(), {data}) @@ -19,10 +22,14 @@ export function fishList(){ } // 塘口基本数据 export function pondBaseInfo(data){ - return httpService.get(API.POND.BASE_INFO() + '/' + data.id) + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); + return httpService.get(`${API.POND.BASE_INFO()}/${data.id}?rootUserId=${userId}`) } // 塘口下设备信息 export function pondDeviceInfo(data){ + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); // 后端接口:GET /devices/{pondId},使用路径参数 - return httpService.get(API.POND.DEVICE_INFO() + '/' + data.id) + return httpService.get(`${API.POND.DEVICE_INFO()}/${data.id}?rootUserId=${userId}`) } \ No newline at end of file diff --git a/src/home/timing.vue b/src/home/timing.vue index 41afacc..57ec38c 100644 --- a/src/home/timing.vue +++ b/src/home/timing.vue @@ -175,9 +175,16 @@ function setOpen({ value, event }, item: any) { state.show = true; state.msg = "设置成功"; }else{ + state.show = true; + state.msg = res.msg || "设置失败"; getTimingList(); } - }) + }).catch((error) => { + console.error('[定时开关设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + getTimingList(); + }); } } /** method end--------------------- */ diff --git a/src/pages/msg/index.vue b/src/pages/msg/index.vue index 710d548..5f62d7a 100644 --- a/src/pages/msg/index.vue +++ b/src/pages/msg/index.vue @@ -303,7 +303,8 @@ function changeVal(e) { } // 查询告警消息 function getWarnMsg() { - const userId = Taro.getStorageSync("UserId"); + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); const params = { ...warnParams.value, userId @@ -334,7 +335,8 @@ function getWarnMsg() { } // 查询开关消息 function getSwitchMsg() { - const userId = Taro.getStorageSync("UserId"); + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); const params = { ...switchParams.value, userId @@ -350,7 +352,8 @@ function getSwitchMsg() { } // 查询充值消息 function getPayMsg() { - const userId = Taro.getStorageSync("UserId"); + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); const params = { ...payParams.value, userId diff --git a/src/utils/request.ts b/src/utils/request.ts index ab7680e..7dfeb55 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -12,8 +12,8 @@ const getBaseUrl = () => { BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 } else { // BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名 - BASE_URL = 'https://api.yuceyun.cn/fishery-api' // 测试环境 - // BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 + // BASE_URL = 'https://api.yuceyun.cn/fishery-api' // 测试环境 + BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 // BASE_URL = 'http://47.102.210.182:6678' //测试环境 } return BASE_URL