fix: 主子账号功能完善。

This commit is contained in:
tianyongbao
2026-01-20 11:51:02 +08:00
parent b85b7ee550
commit 7a4ad91efa
7 changed files with 101 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
import httpService from '@/utils/request'
import API from './config'
import Taro from '@tarojs/taro'
import { useRootUserStore } from '@/store/index'
/** 设备相关接口---------------------------------------- */
// 设备列表
@@ -9,12 +10,14 @@ export function allDeviceList(params) {
}
// 设备详情
export function deviceInfo(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.INFO()}?rootUserId=${userId}`, {data})
}
// 解除绑定
export function deviceUnbind(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.UNBIND()}?rootUserId=${userId}`, {data})
}
// 将设备及开关绑定到塘口
@@ -27,13 +30,15 @@ export function deviceHistory(params){
}
// 修改设备名称
export function deviceUpdateName(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.UPDATE_NAME()}?rootUserId=${userId}`, {data})
}
// 修改设备关联塘口
export function deviceUpdatePond(data){
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.UPDATE_POND()}?rootUserId=${userId}`, {data})
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.UPDATE_POND()}?rootUserId=${userId}`, {data})
}
// 修改设备接电方式
export function deviceUpdateV(data){
@@ -67,17 +72,20 @@ export function addDeviceDetector(data) {
}
// 设置溶解氧/水温告警
export function setWarnCall(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.SET_WARN_CALL()}?rootUserId=${userId}`, {data})
}
// 设置溶解氧上下限
export function setOxyWarn(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_OXY_WARN()}?rootUserId=${userId}`, {data})
}
// 设置温度上下限
export function setTempWarn(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_TEMP_WARN()}?rootUserId=${userId}`, {data})
}
// 溶解氧饱和度
@@ -91,7 +99,8 @@ export function addDeviceController(data) {
}
// 启停溶解氧
export function setOxyOpen(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_OXY_OPEN()}?rootUserId=${userId}`, {data})
}
/** 联动控制------------------------------------- */
@@ -109,7 +118,8 @@ export function updateLinkerCtrl(data){
}
// 删除联动控制
export function delLinkerCtrl(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
// 后端需要 /{ids} 路径参数
return httpService.delete(`${API.LINKED_CTRL.DELETE()}/${data.id}?rootUserId=${userId}`)
}
@@ -149,7 +159,8 @@ export function turnPondSwitch(data){
// 电压告警开关 开启或关闭
export function voltageCheckOpen(data){
const userId = Taro.getStorageSync('UserId');
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data})
}
// 电流告警开关 开启或关闭