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: {
v2: '/iot/device/add_device_controller',
},
// 添加太阳能网控
ADD_SOLAR_DETECTOR: {
v2: '/iot/device/add_device_solar_detector',
},
// 启停溶解氧
SET_OXY_OPEN: {
v2: '/fishery/device/set_controller_oxy_open',
@@ -191,6 +195,10 @@ const API_PATHS = {
VOLTAGE_CHECK: {
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'),
GET_SATURABILITY: () => getApiPath('DEVICE', 'GET_SATURABILITY'),
ADD_CONTROLLER: () => getApiPath('DEVICE', 'ADD_CONTROLLER'),
ADD_SOLAR_DETECTOR: () => getApiPath('DEVICE', 'ADD_SOLAR_DETECTOR'),
SET_OXY_OPEN: () => getApiPath('DEVICE', 'SET_OXY_OPEN'),
VOLTAGE_CHECK: () => getApiPath('DEVICE', 'VOLTAGE_CHECK'),
SET_BATTERY_WARN: () => getApiPath('DEVICE', 'SET_BATTERY_WARN'),
},
// 联动控制
LINKED_CTRL: {

View File

@@ -103,6 +103,12 @@ export function addDeviceController(data) {
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
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){
const store = useRootUserStore();
@@ -169,6 +175,12 @@ export function voltageCheckOpen(data){
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
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){
return httpService.put(API.SWITCH.ELECTRIC_CHECK(), {data})

View File

@@ -30,5 +30,5 @@ export function loginWxToPhone(data) {
// 登出
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",
"updatePond",
"wqm",
"solar",
"ctr",
"switch",
"linkControl",
@@ -40,6 +41,7 @@ export default defineAppConfig({
"help",
"alarmPhone",
"addDetector",
"addSolarDetector",
"addController",
"addDevSuccess",
"subAccount",

View File

@@ -176,8 +176,8 @@ function wxLogin(e) {
? formatDate(new Date(res.data.createdTime))
: formatDate(new Date())
);
Taro.setStorageSync("UserName", res.data.nickName || loginForm.phonenumber);
Taro.setStorageSync("Phone", loginForm.phonenumber);
Taro.setStorageSync("UserName", res.data.nickName || res.data.phonenumber || "");
Taro.setStorageSync("Phone", res.data.phonenumber || "");
Taro.setStorageSync("LoginType", "1");
Taro.setStorageSync("UserId", res.data.userId || "");
Taro.setStorageSync("UnLogin", 2);
@@ -185,7 +185,7 @@ function wxLogin(e) {
store.updateUnLogin(2);
store.updateRootUserId(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.show = true;

View File

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

View File

@@ -12,7 +12,7 @@ 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 = 'https://api.yuceyun.cn/test-api' // 测试环境
// BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
// BASE_URL = 'http://47.102.210.182:6678' //测试环境
}