fix: 登录接口,设备接口,测试问题修复。

This commit is contained in:
tianyongbao
2026-04-04 19:14:38 +08:00
parent 3835b910ee
commit d1133a5857
7 changed files with 61 additions and 17 deletions

View File

@@ -183,6 +183,10 @@ const API_PATHS = {
ADD_CONTROLLER: { ADD_CONTROLLER: {
v2: '/iot/device/add_device_controller', v2: '/iot/device/add_device_controller',
}, },
// 添加太阳能网控
ADD_SOLAR_DETECTOR: {
v2: '/iot/device/add_device_solar_detector',
},
// 启停溶解氧 // 启停溶解氧
SET_OXY_OPEN: { SET_OXY_OPEN: {
v2: '/fishery/device/set_controller_oxy_open', v2: '/fishery/device/set_controller_oxy_open',
@@ -191,6 +195,10 @@ const API_PATHS = {
VOLTAGE_CHECK: { VOLTAGE_CHECK: {
v2: '/fishery/device/voltage_check_open', v2: '/fishery/device/voltage_check_open',
}, },
// 设置电量告警下限
SET_BATTERY_WARN: {
v2: '/fishery/device/set_battery_warn_value',
},
}, },
// ==================== 联动控制 ==================== // ==================== 联动控制 ====================
@@ -442,8 +450,10 @@ export const API = {
SET_TEMP_WARN: () => getApiPath('DEVICE', 'SET_TEMP_WARN'), SET_TEMP_WARN: () => getApiPath('DEVICE', 'SET_TEMP_WARN'),
GET_SATURABILITY: () => getApiPath('DEVICE', 'GET_SATURABILITY'), GET_SATURABILITY: () => getApiPath('DEVICE', 'GET_SATURABILITY'),
ADD_CONTROLLER: () => getApiPath('DEVICE', 'ADD_CONTROLLER'), ADD_CONTROLLER: () => getApiPath('DEVICE', 'ADD_CONTROLLER'),
ADD_SOLAR_DETECTOR: () => getApiPath('DEVICE', 'ADD_SOLAR_DETECTOR'),
SET_OXY_OPEN: () => getApiPath('DEVICE', 'SET_OXY_OPEN'), SET_OXY_OPEN: () => getApiPath('DEVICE', 'SET_OXY_OPEN'),
VOLTAGE_CHECK: () => getApiPath('DEVICE', 'VOLTAGE_CHECK'), VOLTAGE_CHECK: () => getApiPath('DEVICE', 'VOLTAGE_CHECK'),
SET_BATTERY_WARN: () => getApiPath('DEVICE', 'SET_BATTERY_WARN'),
}, },
// 联动控制 // 联动控制
LINKED_CTRL: { LINKED_CTRL: {

View File

@@ -103,6 +103,12 @@ export function addDeviceController(data) {
const userId = store.getRootUserId || Taro.getStorageSync('UserId'); const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.ADD_CONTROLLER()}?rootUserId=${userId}`, {data}) return httpService.post(`${API.DEVICE.ADD_CONTROLLER()}?rootUserId=${userId}`, {data})
} }
// 添加-太阳能网控
export function addDeviceSolarDetector(data) {
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.ADD_SOLAR_DETECTOR()}?rootUserId=${userId}`, {data})
}
// 启停溶解氧 // 启停溶解氧
export function setOxyOpen(data){ export function setOxyOpen(data){
const store = useRootUserStore(); const store = useRootUserStore();
@@ -169,6 +175,12 @@ export function voltageCheckOpen(data){
const userId = store.getRootUserId || Taro.getStorageSync('UserId'); const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data}) return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data})
} }
// 设置电量告警下限
export function setBatteryWarn(data){
const store = useRootUserStore();
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_BATTERY_WARN()}?rootUserId=${userId}`, {data})
}
// 电流告警开关 开启或关闭 // 电流告警开关 开启或关闭
export function electricCheckOpen(data){ export function electricCheckOpen(data){
return httpService.put(API.SWITCH.ELECTRIC_CHECK(), {data}) return httpService.put(API.SWITCH.ELECTRIC_CHECK(), {data})

View File

@@ -30,5 +30,5 @@ export function loginWxToPhone(data) {
// 登出 // 登出
export function logoutFun() { export function logoutFun() {
return httpService.get(API.AUTH.LOGOUT()) return httpService.post(API.AUTH.LOGOUT(), {})
} }

View File

@@ -23,6 +23,7 @@ export default defineAppConfig({
"addPond", "addPond",
"updatePond", "updatePond",
"wqm", "wqm",
"solar",
"ctr", "ctr",
"switch", "switch",
"linkControl", "linkControl",
@@ -40,6 +41,7 @@ export default defineAppConfig({
"help", "help",
"alarmPhone", "alarmPhone",
"addDetector", "addDetector",
"addSolarDetector",
"addController", "addController",
"addDevSuccess", "addDevSuccess",
"subAccount", "subAccount",

View File

@@ -176,8 +176,8 @@ function wxLogin(e) {
? formatDate(new Date(res.data.createdTime)) ? formatDate(new Date(res.data.createdTime))
: formatDate(new Date()) : formatDate(new Date())
); );
Taro.setStorageSync("UserName", res.data.nickName || loginForm.phonenumber); Taro.setStorageSync("UserName", res.data.nickName || res.data.phonenumber || "");
Taro.setStorageSync("Phone", loginForm.phonenumber); Taro.setStorageSync("Phone", res.data.phonenumber || "");
Taro.setStorageSync("LoginType", "1"); Taro.setStorageSync("LoginType", "1");
Taro.setStorageSync("UserId", res.data.userId || ""); Taro.setStorageSync("UserId", res.data.userId || "");
Taro.setStorageSync("UnLogin", 2); Taro.setStorageSync("UnLogin", 2);
@@ -185,7 +185,7 @@ function wxLogin(e) {
store.updateUnLogin(2); store.updateUnLogin(2);
store.updateRootUserId(res.data.userId || ""); store.updateRootUserId(res.data.userId || "");
store.updateUserId(res.data.userId || ""); store.updateUserId(res.data.userId || "");
store.updateRootUserName(res.data.nickName || loginForm.phonenumber); store.updateRootUserName(res.data.nickName || res.data.phonenumber || "");
state.msg = "登录成功"; state.msg = "登录成功";
state.msg = "登录成功"; state.msg = "登录成功";
state.show = true; state.show = true;

View File

@@ -128,7 +128,7 @@
<view class="d_body" :style="{ paddingBottom: '0px' }"> <view class="d_body" :style="{ paddingBottom: '0px' }">
<nut-row> <nut-row>
<nut-col :span="24"> <nut-col :span="24">
<view class="d_title">请设手机号码</view> <view class="d_title">请设手机号码</view>
</nut-col> </nut-col>
<nut-col :span="24"> <nut-col :span="24">
<nut-divider class="divider" /> <nut-divider class="divider" />
@@ -136,7 +136,7 @@
<nut-col :span="24" class="view_f"> <nut-col :span="24" class="view_f">
<view :style="{ width: '30%' }" class="font_32 c_444">原手机号</view> <view :style="{ width: '30%' }" class="font_32 c_444">原手机号</view>
<view :style="{ width: '70%' }"> <view :style="{ width: '70%' }">
<nut-input type="number" v-model="phonenumber" :border="false" input-align="right" readonly /> <nut-input type="text" v-model="phonenumber" :border="false" input-align="right" readonly />
</view> </view>
</nut-col> </nut-col>
<nut-col :span="24"> <nut-col :span="24">
@@ -177,7 +177,7 @@
<view class="d_body" :style="{ paddingBottom: '0px' }"> <view class="d_body" :style="{ paddingBottom: '0px' }">
<nut-row> <nut-row>
<nut-col :span="24"> <nut-col :span="24">
<view class="d_title">请设昵称</view> <view class="d_title">请设昵称</view>
</nut-col> </nut-col>
<nut-col :span="24"> <nut-col :span="24">
<nut-divider class="divider" /> <nut-divider class="divider" />
@@ -425,6 +425,7 @@ function goContact() {
} }
// 修改手机号码 // 修改手机号码
function setPhoneNumber() { function setPhoneNumber() {
phonenumber.value = Taro.getStorageSync("Phone") || "-"
setPhoneShow.value = true setPhoneShow.value = true
} }
/** 验证码读秒 */ /** 验证码读秒 */
@@ -445,7 +446,7 @@ function setTime() {
} }
/** 获取验证码 */ /** 获取验证码 */
function getCode() { function getCode() {
const v_phone_res = validatePhone(phonenumber.value) const v_phone_res = validatePhone(newPhone.value)
if (v_phone_res == 1) { if (v_phone_res == 1) {
state.msg = "手机号不能为空" state.msg = "手机号不能为空"
state.show = true state.show = true
@@ -453,7 +454,7 @@ function getCode() {
state.msg = "手机号格式不正确" state.msg = "手机号格式不正确"
state.show = true state.show = true
} else { } else {
smsCode(phonenumber.value).then((res: any) => { smsCode(newPhone.value).then((res: any) => {
state.msg = "发送成功" state.msg = "发送成功"
state.show = true state.show = true
setTime() setTime()
@@ -503,6 +504,9 @@ function toSetPhone() {
Taro.setStorageSync("Phone", newPhone.value) Taro.setStorageSync("Phone", newPhone.value)
phonenumber.value = newPhone.value phonenumber.value = newPhone.value
setPhoneShow.value = false setPhoneShow.value = false
} else {
state.msg = res.msg || "修改失败"
state.show = true
} }
}) })
// verifyCode({ MobilePhone: phonenumber.value, SmsCode: code.value }).then(res => { // verifyCode({ MobilePhone: phonenumber.value, SmsCode: code.value }).then(res => {
@@ -573,13 +577,23 @@ function logOut() {
content: "确认注销当前账号?", content: "确认注销当前账号?",
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
logoutFun() logoutFun().then(() => {
Taro.clearStorageSync() Taro.clearStorageSync()
Taro.clearStorage() Taro.clearStorage()
store.updateRootUserId(null) store.updateRootUserId(null)
store.updateRootUserName(null) store.updateRootUserName(null)
Taro.redirectTo({ Taro.redirectTo({
url: "/pages/login/index", url: "/pages/login/index",
})
}).catch(() => {
// 即使接口失败也执行本地清理和跳转
Taro.clearStorageSync()
Taro.clearStorage()
store.updateRootUserId(null)
store.updateRootUserName(null)
Taro.redirectTo({
url: "/pages/login/index",
})
}) })
} }
}, },
@@ -728,6 +742,7 @@ function toLogin() {
.nut-dialog { .nut-dialog {
padding: 0; padding: 0;
z-index: 2000;
} }
.nut-dialog__content { .nut-dialog__content {
@@ -735,6 +750,11 @@ function toLogin() {
max-height: 100%; max-height: 100%;
} }
scroll-view {
position: relative;
z-index: 1;
}
.code { .code {
color: #09b8c2; color: #09b8c2;
} }

View File

@@ -12,7 +12,7 @@ const getBaseUrl = () => {
BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
} else { } else {
// BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名 // BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名
BASE_URL = 'https://api.yuceyun.cn/fishery-api' // 测试环境 BASE_URL = 'https://api.yuceyun.cn/test-api' // 测试环境
// BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址 // BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
// BASE_URL = 'http://47.102.210.182:6678' //测试环境 // BASE_URL = 'http://47.102.210.182:6678' //测试环境
} }