diff --git a/src/api/config.ts b/src/api/config.ts index 54fc800..f602ec3 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -32,7 +32,6 @@ const API_PATHS = { AUTH: { // 短信登录 LOGIN_SMS: { - v1: '/auth/login', v2: '/auth/login', }, // 获取短信验证码 @@ -41,7 +40,6 @@ const API_PATHS = { }, // 微信手机号登录 LOGIN_WECHAT: { - v1: '/api/login/use_wechat', v2: '/auth/wechat_login', }, // 登出 diff --git a/src/api/device.ts b/src/api/device.ts index fdaeec8..68ddf91 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -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}) } // 电流告警开关 开启或关闭 diff --git a/src/api/home.ts b/src/api/home.ts index 940cd70..d5d6f4e 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -1,10 +1,12 @@ import httpService from '@/utils/request' import API from './config' import Taro from '@tarojs/taro'; +import { useRootUserStore } from '@/store/index'; // 塘口模式1 export function getPond1() { - const userId = Taro.getStorageSync("UserId"); + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync("UserId"); return httpService.get(API.HOME.POND_LIST(), { params: { rootUserId: userId || undefined @@ -14,7 +16,8 @@ export function getPond1() { // 塘口模式2 export function getPond2(){ - const userId = Taro.getStorageSync("UserId"); + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync("UserId"); return httpService.get(API.HOME.POND_LIST_MODE2(), { params: { rootUserId: userId || undefined @@ -29,8 +32,9 @@ export function noticeList(){ // 即将到期设备列表 export function deviceDead(){ - const userId = Taro.getStorageSync("UserId"); - return httpService.get(API.HOME.DEVICE_DEAD(), { + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync("UserId"); + return httpService.get(API.HOME.DEVICE_DEAD(), { params: { rootUserId: userId || undefined } diff --git a/src/api/sub.ts b/src/api/sub.ts index 35e9add..6323bb1 100644 --- a/src/api/sub.ts +++ b/src/api/sub.ts @@ -8,7 +8,7 @@ export function list_user_child() { // 添加 export function add_user_child(mobilePhone) { - return httpService.post(API.SUB_ACCOUNT.ADD(), { mobilePhone }) + return httpService.post(API.SUB_ACCOUNT.ADD(), { data: { mobilePhone } }) } // 删除 diff --git a/src/components/custom-navigation-bar/index.vue b/src/components/custom-navigation-bar/index.vue index fe17d5b..10b223c 100644 --- a/src/components/custom-navigation-bar/index.vue +++ b/src/components/custom-navigation-bar/index.vue @@ -1,12 +1,15 @@