Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5ddf1e120 | ||
|
|
6d1a6ded2d | ||
|
|
2e9609292e | ||
|
|
b2f7f5fe1e |
@@ -4,7 +4,12 @@ module.exports = {
|
||||
presets: [
|
||||
['taro', {
|
||||
framework: 'vue3',
|
||||
ts: true
|
||||
ts: true,
|
||||
targets: {
|
||||
chrome: '60',
|
||||
ios: '10',
|
||||
android: '5'
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
|
||||
1
components.d.ts
vendored
1
components.d.ts
vendored
@@ -7,6 +7,7 @@ export {}
|
||||
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ChartFullscreen: typeof import('./src/components/other/chartFullscreen.vue')['default']
|
||||
CustomNavigationBar: typeof import('./src/components/custom-navigation-bar/index.vue')['default']
|
||||
Fish: typeof import('./src/components/other/fish.vue')['default']
|
||||
NutBadge: typeof import('@nutui/nutui-taro')['Badge']
|
||||
|
||||
@@ -36,6 +36,10 @@ const config = {
|
||||
outputRoot: 'dist',
|
||||
plugins: ['@tarojs/plugin-html'],
|
||||
defineConstants: {
|
||||
// Vue 3 特性标志
|
||||
__VUE_OPTIONS_API__: JSON.stringify(true),
|
||||
__VUE_PROD_DEVTOOLS__: JSON.stringify(false),
|
||||
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false)
|
||||
},
|
||||
copy: {
|
||||
patterns: [
|
||||
@@ -142,6 +146,39 @@ const config = {
|
||||
chain.plugin('unplugin-vue-components').use(Components({
|
||||
resolvers: [NutUIResolver()]
|
||||
}))
|
||||
chain.plugin('unplugin-auto-import').use(
|
||||
AutoImport({
|
||||
imports: ['vue'],
|
||||
dts: 'types/auto-imports.d.ts',
|
||||
dirs: ['src/utils', 'src/store'],
|
||||
vueTemplate: true
|
||||
})
|
||||
)
|
||||
},
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'https://api.yuceyun.cn',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/api': ''
|
||||
}
|
||||
},
|
||||
'/auth': {
|
||||
target: 'https://api.yuceyun.cn',
|
||||
changeOrigin: true
|
||||
},
|
||||
'/resource': {
|
||||
target: 'https://api.yuceyun.cn',
|
||||
changeOrigin: true
|
||||
}
|
||||
},
|
||||
client: {
|
||||
overlay: {
|
||||
errors: true,
|
||||
warnings: false
|
||||
}
|
||||
}
|
||||
},
|
||||
publicPath: '/',
|
||||
staticDirectory: 'static',
|
||||
|
||||
520
src/api/config.ts
Normal file
520
src/api/config.ts
Normal file
@@ -0,0 +1,520 @@
|
||||
/**
|
||||
* API接口配置文件
|
||||
* 集中管理所有接口路径,便于后端接口迁移和维护
|
||||
*
|
||||
* 使用说明:
|
||||
* 1. 当后端接口路径变化时,只需修改此文件中的URL
|
||||
* 2. 支持通过API_VERSION切换接口版本
|
||||
* 3. 所有接口路径统一管理,避免硬编码
|
||||
*/
|
||||
|
||||
// API版本控制
|
||||
export const API_VERSION = {
|
||||
V1: 'v1', // 原C#版本
|
||||
V2: 'v2', // 新Java版本
|
||||
}
|
||||
|
||||
// 当前使用的API版本,修改此处可快速切换版本
|
||||
export const CURRENT_VERSION = API_VERSION.V2
|
||||
|
||||
/**
|
||||
* 接口路径配置
|
||||
* 结构:{ v1: 'C#接口路径', v2: 'Java接口路径' }
|
||||
*/
|
||||
const API_PATHS = {
|
||||
// ==================== 认证相关 ====================
|
||||
AUTH: {
|
||||
// 短信登录
|
||||
LOGIN_SMS: {
|
||||
v1: '/auth/login',
|
||||
v2: '/auth/login',
|
||||
},
|
||||
// 获取短信验证码
|
||||
SMS_CODE: {
|
||||
v2: '/resource/sms/code',
|
||||
},
|
||||
// 微信手机号登录
|
||||
LOGIN_WECHAT: {
|
||||
v1: '/api/login/use_wechat',
|
||||
v2: '/fishery/login/wechat',
|
||||
},
|
||||
// 登出
|
||||
LOGOUT: {
|
||||
v1: '/api/user-center/logout',
|
||||
v2: '/fishery/auth/logout',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 首页相关 ====================
|
||||
HOME: {
|
||||
// 塘口列表模式1
|
||||
POND_LIST: {
|
||||
v2: '/fishery/pond/list_mode1',
|
||||
},
|
||||
// 塘口列表模式2
|
||||
POND_LIST_MODE2: {
|
||||
v2: '/fishery/pond/list_mode2',
|
||||
},
|
||||
// 公告列表
|
||||
NOTICE_LIST: {
|
||||
v2: '/system/notice/list',
|
||||
},
|
||||
// 即将到期设备列表
|
||||
DEVICE_DEAD: {
|
||||
v2: '/fishery/device/list_device_dead',
|
||||
},
|
||||
// 获取设备票据
|
||||
DEVICE_TICKET: {
|
||||
v1: '/api/user-center/getsnticket',
|
||||
v2: '/fishery/device/ticket',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 鱼塘管理 ====================
|
||||
POND: {
|
||||
// 新增塘口
|
||||
ADD: {
|
||||
v2: '/fishery/pond',
|
||||
},
|
||||
// 修改塘口
|
||||
UPDATE: {
|
||||
v2: '/fishery/pond',
|
||||
},
|
||||
// 删除塘口
|
||||
DELETE: {
|
||||
v2: '/fishery/pond',
|
||||
},
|
||||
// 鱼类列表
|
||||
FISH_LIST: {
|
||||
v2: '/fishery/fish/list',
|
||||
},
|
||||
// 塘口基本数据
|
||||
BASE_INFO: {
|
||||
v2: '/fishery/pond',
|
||||
},
|
||||
// 塘口下设备信息
|
||||
DEVICE_INFO: {
|
||||
v2: '/fishery/pond/devices',
|
||||
},
|
||||
// 将设备及开关绑定到塘口
|
||||
BIND_DEVICE: {
|
||||
v2: '/fishery/pond/bind/device',
|
||||
},
|
||||
// 夜间防误触
|
||||
KEEP_NIGHT_OPEN: {
|
||||
v1: '/api/pond/keep_night_open',
|
||||
v2: '/fishery/pond/night-protect',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 设备管理 ====================
|
||||
DEVICE: {
|
||||
// 设备列表
|
||||
LIST_ALL: {
|
||||
v2: '/fishery/device/list_all_device',
|
||||
},
|
||||
// 设备详情
|
||||
INFO: {
|
||||
v2: '/fishery/device/one_device_info',
|
||||
},
|
||||
// 解除绑定
|
||||
UNBIND: {
|
||||
v2: '/fishery/device/break_pond',
|
||||
},
|
||||
// 设备图表数据
|
||||
HISTORY: {
|
||||
v2: '/td/device/getHistoryData',
|
||||
},
|
||||
// 修改设备名称
|
||||
UPDATE_NAME: {
|
||||
v2: '/fishery/device/update_name',
|
||||
},
|
||||
// 修改设备关联塘口
|
||||
UPDATE_POND: {
|
||||
v2: '/fishery/pond/update_pond',
|
||||
},
|
||||
// 修改设备接电方式
|
||||
UPDATE_VOLTAGE: {
|
||||
v2: '/iot/device/voltage_type',
|
||||
},
|
||||
// 删除设备
|
||||
DELETE: {
|
||||
v2: '/fishery/device',
|
||||
},
|
||||
// 扫描设备编码
|
||||
SCAN: {
|
||||
v1: '/api/device/check_device_qrcode',
|
||||
v2: '/fishery/device/scan',
|
||||
},
|
||||
// 检测设备是否在线
|
||||
CHECK_STATUS: {
|
||||
v2: '/iot/device/status',
|
||||
},
|
||||
// 盐度设置
|
||||
SET_SALINITY: {
|
||||
v2: '/iot/device/salinity-compensation',
|
||||
},
|
||||
// 设备校准
|
||||
CALIBRATE: {
|
||||
v2: '/iot/device/calibrate',
|
||||
},
|
||||
// 添加水质检测仪
|
||||
ADD_DETECTOR: {
|
||||
v2: '/iot/device/add_device_detector',
|
||||
},
|
||||
// 设置溶解氧/水温告警
|
||||
SET_WARN_CALL: {
|
||||
v2: '/fishery/device/set_oxy_warn_call',
|
||||
},
|
||||
// 设置溶解氧上下限
|
||||
SET_OXY_WARN: {
|
||||
v2: '/fishery/device/set_oxy_warn_value',
|
||||
},
|
||||
// 设置温度上下限
|
||||
SET_TEMP_WARN: {
|
||||
v2: '/fishery/device/set_temp_warn_value',
|
||||
},
|
||||
// 溶解氧饱和度
|
||||
GET_SATURABILITY: {
|
||||
v2: '/fishery/device/get_saturability',
|
||||
},
|
||||
// 添加控制一体机
|
||||
ADD_CONTROLLER: {
|
||||
v2: '/iot/device/add_device_controller',
|
||||
},
|
||||
// 启停溶解氧
|
||||
SET_OXY_OPEN: {
|
||||
v2: '/fishery/device/set_controller_oxy_open',
|
||||
},
|
||||
// 电压告警开关
|
||||
VOLTAGE_CHECK: {
|
||||
v2: '/fishery/device/voltage_check_open',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 联动控制 ====================
|
||||
LINKED_CTRL: {
|
||||
// 设备控制器列表
|
||||
LIST: {
|
||||
v2: '/fishery/linkedCtrl/fetch',
|
||||
},
|
||||
// 添加联动控制
|
||||
ADD: {
|
||||
v2: '/fishery/linkedCtrl/add',
|
||||
},
|
||||
// 修改联动控制
|
||||
UPDATE: {
|
||||
v2: '/fishery/linkedCtrl/update',
|
||||
},
|
||||
// 删除联动控制
|
||||
DELETE: {
|
||||
v2: '/fishery/linkedCtrl',
|
||||
},
|
||||
// 设置联动控制上下限开关
|
||||
SET_OPEN: {
|
||||
v2: '/fishery/linkedCtrl/set_open',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 开关管理 ====================
|
||||
SWITCH: {
|
||||
// 开关列表
|
||||
POND_LIST: {
|
||||
v2: '/fishery/deviceSwitch/get_pond_switch',
|
||||
},
|
||||
// 开关详情
|
||||
INFO: {
|
||||
v2: '/fishery/deviceSwitch/one_switch_info',
|
||||
},
|
||||
// 修改开关名称
|
||||
UPDATE_NAME: {
|
||||
v2: '/fishery/deviceSwitch/update_name',
|
||||
},
|
||||
// 修改关联塘口
|
||||
UPDATE_POND: {
|
||||
v2: '/iot/switch/update_pond',
|
||||
},
|
||||
// 修改接线方式
|
||||
UPDATE_VOLTAGE: {
|
||||
v2: '/iot/switch/update_voltage_type',
|
||||
},
|
||||
// 单个开关启停
|
||||
TURN: {
|
||||
v2: '/iot/switch/turn_switch',
|
||||
},
|
||||
// 所有开关启停
|
||||
TURN_POND: {
|
||||
v2: '/iot/switch/turn_pond_switch',
|
||||
},
|
||||
// 电流告警开关
|
||||
ELECTRIC_CHECK: {
|
||||
v2: '/fishery/deviceSwitch/electric_check_open',
|
||||
},
|
||||
// 电流告警设置
|
||||
ELECTRIC_SET: {
|
||||
v2: '/iot/switch/electric_set',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 定时开关 ====================
|
||||
TIME_CTRL: {
|
||||
// 定时开关列表
|
||||
LIST: {
|
||||
v1: '/api/device-switch-time-ctrl/list',
|
||||
v2: '/fishery/time-ctrl/list',
|
||||
},
|
||||
// 添加定时开关
|
||||
ADD: {
|
||||
v1: '/api/device-switch-time-ctrl/add',
|
||||
v2: '/fishery/time-ctrl',
|
||||
},
|
||||
// 删除定时开关
|
||||
DELETE: {
|
||||
v1: '/api/device-switch-time-ctrl/delete',
|
||||
v2: '/fishery/time-ctrl',
|
||||
},
|
||||
// 更新定时开关
|
||||
UPDATE: {
|
||||
v1: '/api/device-switch-time-ctrl/update',
|
||||
v2: '/fishery/time-ctrl',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 消息中心 ====================
|
||||
MESSAGE: {
|
||||
// 充值记录
|
||||
PAY: {
|
||||
v2: '/fishery/payOrder/list',
|
||||
},
|
||||
// 报警记录
|
||||
WARN: {
|
||||
v2: '/fishery/messageWarn/list',
|
||||
},
|
||||
// 开关记录
|
||||
SWITCH: {
|
||||
v2: '/fishery/messageOpRecord/list',
|
||||
},
|
||||
// 已读一条消息
|
||||
READ_ONE: {
|
||||
v2: '/fishery/messageWarn/read',
|
||||
},
|
||||
// 已读全部
|
||||
READ_ALL: {
|
||||
v2: '/fishery/messageWarn/read/all',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 个人中心 ====================
|
||||
USER: {
|
||||
// 报警电话列表
|
||||
WARN_PHONE_LIST: {
|
||||
v1: '/api/user-center/list_warn_phone',
|
||||
v2: '/fishery/user/warn-phone/list',
|
||||
},
|
||||
// 修改报警电话
|
||||
UPDATE_WARN_PHONE: {
|
||||
v1: '/api/user-center/update_warn_phone',
|
||||
v2: '/fishery/user/warn-phone',
|
||||
},
|
||||
// 修改手机号码
|
||||
UPDATE_PHONE: {
|
||||
v1: '/api/user-center/update_mobile_phone',
|
||||
v2: '/fishery/user/phone',
|
||||
},
|
||||
// 验证验证码
|
||||
VERIFY_CODE: {
|
||||
v1: '/sms_code/verify',
|
||||
v2: '/fishery/sms/verify',
|
||||
},
|
||||
// 修改昵称
|
||||
UPDATE_NICKNAME: {
|
||||
v1: '/api/user-center/update_user_name',
|
||||
v2: '/fishery/user/nickname',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 子账户管理 ====================
|
||||
SUB_ACCOUNT: {
|
||||
// 获取子账号列表
|
||||
LIST: {
|
||||
v1: '/api/user-center/list_user_child',
|
||||
v2: '/fishery/user/child/list',
|
||||
},
|
||||
// 添加子账号
|
||||
ADD: {
|
||||
v1: '/api/user-center/add_user_child',
|
||||
v2: '/fishery/user/child',
|
||||
},
|
||||
// 删除子账号
|
||||
DELETE: {
|
||||
v1: '/api/user-center/delete_user_child',
|
||||
v2: '/fishery/user/child',
|
||||
},
|
||||
// 获取父级账号
|
||||
PARENT: {
|
||||
v1: '/api/user-center/list_user_parent',
|
||||
v2: '/fishery/user/parent',
|
||||
},
|
||||
},
|
||||
|
||||
// ==================== 支付相关 ====================
|
||||
PAY: {
|
||||
// 支付选项页面
|
||||
OPTIONS: {
|
||||
v1: '/api/tenpay/get_pay_item',
|
||||
v2: '/fishery/pay/options',
|
||||
},
|
||||
// 创建支付订单
|
||||
CREATE_ORDER: {
|
||||
v1: '/api/tenpay/create_order',
|
||||
v2: '/fishery/pay/order',
|
||||
},
|
||||
// 微信支付
|
||||
WECHAT_PAY: {
|
||||
v1: 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi',
|
||||
v2: 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi', // 微信官方接口不变
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API路径
|
||||
* @param category 接口分类 (如 'AUTH', 'HOME')
|
||||
* @param key 接口键名 (如 'LOGIN_SMS', 'POND_LIST')
|
||||
* @param version 版本号,默认使用 CURRENT_VERSION
|
||||
* @returns 接口路径
|
||||
*/
|
||||
export function getApiPath(category: string, key: string, version: string = CURRENT_VERSION): string {
|
||||
const categoryPaths = API_PATHS[category]
|
||||
if (!categoryPaths) {
|
||||
console.error(`[API配置] 未找到分类: ${category}`)
|
||||
return ''
|
||||
}
|
||||
|
||||
const apiPath = categoryPaths[key]
|
||||
if (!apiPath) {
|
||||
console.error(`[API配置] 未找到接口: ${category}.${key}`)
|
||||
return ''
|
||||
}
|
||||
|
||||
const path = apiPath[version]
|
||||
if (!path) {
|
||||
console.warn(`[API配置] ${category}.${key} 未配置版本 ${version},使用 v1`)
|
||||
return apiPath.v1
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
/**
|
||||
* 便捷导出:直接获取当前版本的API路径
|
||||
*/
|
||||
export const API = {
|
||||
// 认证相关
|
||||
AUTH: {
|
||||
LOGIN_SMS: () => getApiPath('AUTH', 'LOGIN_SMS'),
|
||||
SMS_CODE: () => getApiPath('AUTH', 'SMS_CODE'),
|
||||
LOGIN_WECHAT: () => getApiPath('AUTH', 'LOGIN_WECHAT'),
|
||||
LOGOUT: () => getApiPath('AUTH', 'LOGOUT'),
|
||||
},
|
||||
// 首页相关
|
||||
HOME: {
|
||||
POND_LIST: () => getApiPath('HOME', 'POND_LIST'),
|
||||
POND_LIST_MODE2: () => getApiPath('HOME', 'POND_LIST_MODE2'),
|
||||
NOTICE_LIST: () => getApiPath('HOME', 'NOTICE_LIST'),
|
||||
DEVICE_DEAD: () => getApiPath('HOME', 'DEVICE_DEAD'),
|
||||
DEVICE_TICKET: () => getApiPath('HOME', 'DEVICE_TICKET'),
|
||||
},
|
||||
// 鱼塘管理
|
||||
POND: {
|
||||
ADD: () => getApiPath('POND', 'ADD'),
|
||||
UPDATE: () => getApiPath('POND', 'UPDATE'),
|
||||
DELETE: () => getApiPath('POND', 'DELETE'),
|
||||
FISH_LIST: () => getApiPath('POND', 'FISH_LIST'),
|
||||
BASE_INFO: () => getApiPath('POND', 'BASE_INFO'),
|
||||
DEVICE_INFO: () => getApiPath('POND', 'DEVICE_INFO'),
|
||||
BIND_DEVICE: () => getApiPath('POND', 'BIND_DEVICE'),
|
||||
KEEP_NIGHT_OPEN: () => getApiPath('POND', 'KEEP_NIGHT_OPEN'),
|
||||
},
|
||||
// 设备管理
|
||||
DEVICE: {
|
||||
LIST_ALL: () => getApiPath('DEVICE', 'LIST_ALL'),
|
||||
INFO: () => getApiPath('DEVICE', 'INFO'),
|
||||
UNBIND: () => getApiPath('DEVICE', 'UNBIND'),
|
||||
HISTORY: () => getApiPath('DEVICE', 'HISTORY'),
|
||||
UPDATE_NAME: () => getApiPath('DEVICE', 'UPDATE_NAME'),
|
||||
UPDATE_POND: () => getApiPath('DEVICE', 'UPDATE_POND'),
|
||||
UPDATE_VOLTAGE: () => getApiPath('DEVICE', 'UPDATE_VOLTAGE'),
|
||||
DELETE: () => getApiPath('DEVICE', 'DELETE'),
|
||||
SCAN: () => getApiPath('DEVICE', 'SCAN'),
|
||||
CHECK_STATUS: () => getApiPath('DEVICE', 'CHECK_STATUS'),
|
||||
SET_SALINITY: () => getApiPath('DEVICE', 'SET_SALINITY'),
|
||||
CALIBRATE: () => getApiPath('DEVICE', 'CALIBRATE'),
|
||||
ADD_DETECTOR: () => getApiPath('DEVICE', 'ADD_DETECTOR'),
|
||||
SET_WARN_CALL: () => getApiPath('DEVICE', 'SET_WARN_CALL'),
|
||||
SET_OXY_WARN: () => getApiPath('DEVICE', 'SET_OXY_WARN'),
|
||||
SET_TEMP_WARN: () => getApiPath('DEVICE', 'SET_TEMP_WARN'),
|
||||
GET_SATURABILITY: () => getApiPath('DEVICE', 'GET_SATURABILITY'),
|
||||
ADD_CONTROLLER: () => getApiPath('DEVICE', 'ADD_CONTROLLER'),
|
||||
SET_OXY_OPEN: () => getApiPath('DEVICE', 'SET_OXY_OPEN'),
|
||||
VOLTAGE_CHECK: () => getApiPath('DEVICE', 'VOLTAGE_CHECK'),
|
||||
},
|
||||
// 联动控制
|
||||
LINKED_CTRL: {
|
||||
LIST: () => getApiPath('LINKED_CTRL', 'LIST'),
|
||||
ADD: () => getApiPath('LINKED_CTRL', 'ADD'),
|
||||
UPDATE: () => getApiPath('LINKED_CTRL', 'UPDATE'),
|
||||
DELETE: () => getApiPath('LINKED_CTRL', 'DELETE'),
|
||||
SET_OPEN: () => getApiPath('LINKED_CTRL', 'SET_OPEN'),
|
||||
},
|
||||
// 开关管理
|
||||
SWITCH: {
|
||||
POND_LIST: () => getApiPath('SWITCH', 'POND_LIST'),
|
||||
INFO: () => getApiPath('SWITCH', 'INFO'),
|
||||
UPDATE_NAME: () => getApiPath('SWITCH', 'UPDATE_NAME'),
|
||||
UPDATE_POND: () => getApiPath('SWITCH', 'UPDATE_POND'),
|
||||
UPDATE_VOLTAGE: () => getApiPath('SWITCH', 'UPDATE_VOLTAGE'),
|
||||
TURN: () => getApiPath('SWITCH', 'TURN'),
|
||||
TURN_POND: () => getApiPath('SWITCH', 'TURN_POND'),
|
||||
ELECTRIC_CHECK: () => getApiPath('SWITCH', 'ELECTRIC_CHECK'),
|
||||
ELECTRIC_SET: () => getApiPath('SWITCH', 'ELECTRIC_SET'),
|
||||
},
|
||||
// 定时开关
|
||||
TIME_CTRL: {
|
||||
LIST: () => getApiPath('TIME_CTRL', 'LIST'),
|
||||
ADD: () => getApiPath('TIME_CTRL', 'ADD'),
|
||||
DELETE: () => getApiPath('TIME_CTRL', 'DELETE'),
|
||||
UPDATE: () => getApiPath('TIME_CTRL', 'UPDATE'),
|
||||
},
|
||||
// 消息中心
|
||||
MESSAGE: {
|
||||
PAY: () => getApiPath('MESSAGE', 'PAY'),
|
||||
WARN: () => getApiPath('MESSAGE', 'WARN'),
|
||||
SWITCH: () => getApiPath('MESSAGE', 'SWITCH'),
|
||||
READ_ONE: () => getApiPath('MESSAGE', 'READ_ONE'),
|
||||
READ_ALL: () => getApiPath('MESSAGE', 'READ_ALL'),
|
||||
},
|
||||
// 个人中心
|
||||
USER: {
|
||||
WARN_PHONE_LIST: () => getApiPath('USER', 'WARN_PHONE_LIST'),
|
||||
UPDATE_WARN_PHONE: () => getApiPath('USER', 'UPDATE_WARN_PHONE'),
|
||||
UPDATE_PHONE: () => getApiPath('USER', 'UPDATE_PHONE'),
|
||||
VERIFY_CODE: () => getApiPath('USER', 'VERIFY_CODE'),
|
||||
UPDATE_NICKNAME: () => getApiPath('USER', 'UPDATE_NICKNAME'),
|
||||
},
|
||||
// 子账户管理
|
||||
SUB_ACCOUNT: {
|
||||
LIST: () => getApiPath('SUB_ACCOUNT', 'LIST'),
|
||||
ADD: () => getApiPath('SUB_ACCOUNT', 'ADD'),
|
||||
DELETE: () => getApiPath('SUB_ACCOUNT', 'DELETE'),
|
||||
PARENT: () => getApiPath('SUB_ACCOUNT', 'PARENT'),
|
||||
},
|
||||
// 支付相关
|
||||
PAY: {
|
||||
OPTIONS: () => getApiPath('PAY', 'OPTIONS'),
|
||||
CREATE_ORDER: () => getApiPath('PAY', 'CREATE_ORDER'),
|
||||
WECHAT_PAY: () => getApiPath('PAY', 'WECHAT_PAY'),
|
||||
},
|
||||
}
|
||||
|
||||
export default API
|
||||
@@ -1,176 +1,180 @@
|
||||
import httpService from '@/utils/request'
|
||||
import {useRootUserStore} from '@/store/index';
|
||||
import API from './config'
|
||||
import Taro from '@tarojs/taro'
|
||||
/** 设备相关接口---------------------------------------- */
|
||||
const store:any = useRootUserStore();
|
||||
|
||||
// 设备列表
|
||||
export function allDeviceList(params) {
|
||||
if(params){
|
||||
params.rootuserid = store.getRootUserId
|
||||
}
|
||||
return httpService.get(`/api/device/list_all_device`,{params})
|
||||
return httpService.get(API.DEVICE.LIST_ALL(), {params})
|
||||
}
|
||||
// 设备详情
|
||||
export function deviceInfo(data){
|
||||
return httpService.post(`/api/device/one_device_info?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.post(`${API.DEVICE.INFO()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 解除绑定
|
||||
export function deviceUnbind(data){
|
||||
return httpService.post(`/api/device/break_pond?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.post(`${API.DEVICE.UNBIND()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 将设备及开关绑定到塘口
|
||||
export function bandDeviceToPond(data){
|
||||
return httpService.put(`/api/pond/select_device_switch?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.POND.BIND_DEVICE(), {data})
|
||||
}
|
||||
// 设备图表数据
|
||||
export function deviceHistory(data){
|
||||
return httpService.post(`/api/device/data_history?rootuserid=${store.getRootUserId}`,{data})
|
||||
export function deviceHistory(params){
|
||||
return httpService.get(API.DEVICE.HISTORY(), {params})
|
||||
}
|
||||
// 修改设备名称
|
||||
export function deviceUpdateName(data){
|
||||
return httpService.put(`/api/device/update_name?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.put(`${API.DEVICE.UPDATE_NAME()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 修改设备关联塘口
|
||||
export function deviceUpdatePond(data){
|
||||
return httpService.put(`/api/device/update_pond?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.put(`${API.DEVICE.UPDATE_POND()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 修改设备接电方式
|
||||
export function deviceUpdateV(data){
|
||||
return httpService.put(`/api/device/update_voltage_type?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.DEVICE.UPDATE_VOLTAGE(), {data})
|
||||
}
|
||||
// 删除设备
|
||||
export function deviceDel(data){
|
||||
return httpService.delete(`/api/device/delete?rootuserid=${store.getRootUserId}`,{data})
|
||||
// 后端需要 /{ids} 路径参数,传入 ID 数组
|
||||
return httpService.delete(`${API.DEVICE.DELETE()}/${data.id}`)
|
||||
}
|
||||
// 扫描设备编码
|
||||
export function deviceScan(params){
|
||||
if(params){
|
||||
params.rootuserid = store.getRootUserId
|
||||
}
|
||||
return httpService.get(`/api/device/check_device_qrcode`,{params})
|
||||
return httpService.get(API.DEVICE.SCAN(), {params})
|
||||
}
|
||||
// 检测设备是否在线
|
||||
export function checkDeviceStatus(params){
|
||||
if(params){
|
||||
params.rootuserid = store.getRootUserId
|
||||
}
|
||||
return httpService.get(`/api/device/check_device_status`,{params})
|
||||
return httpService.get(API.DEVICE.CHECK_STATUS(), {params})
|
||||
}
|
||||
// 盐度设置
|
||||
export function setSal(data){
|
||||
return httpService.post(`/api/device/detector_salinitycompensation?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.DEVICE.SET_SALINITY(), {data})
|
||||
}
|
||||
// 设备校准
|
||||
export function deviceCalibration(data){
|
||||
return httpService.post(`/api/device/detector_calibrate?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.DEVICE.CALIBRATE(), {data})
|
||||
}
|
||||
/** 水质检测仪------------------------------------------------ */
|
||||
// 添加-水质检测仪
|
||||
export function addDeviceDetector(data) {
|
||||
return httpService.post(`/api/device/add_device_detector?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.DEVICE.ADD_DETECTOR(), {data})
|
||||
}
|
||||
// 设置溶解氧/水温告警
|
||||
export function setWarnCall(data){
|
||||
return httpService.post(`/api/device/set_oxy_warn_call?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.post(`${API.DEVICE.SET_WARN_CALL()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 设置溶解氧上下限
|
||||
export function setOxyWarn(data){
|
||||
return httpService.put(`/api/device/set_oxy_warn_value?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.put(`${API.DEVICE.SET_OXY_WARN()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 设置温度上下限
|
||||
export function setTempWarn(data){
|
||||
return httpService.put(`/api/device/set_temp_warn_value?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.put(`${API.DEVICE.SET_TEMP_WARN()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 溶解氧饱和度
|
||||
export function getSaturability(data){
|
||||
return httpService.post(`/api/device/get_saturability?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.DEVICE.GET_SATURABILITY(), {data})
|
||||
}
|
||||
/** 控制一体机------------------------------------------------ */
|
||||
// 添加-控制一体机
|
||||
export function addDeviceController(data) {
|
||||
return httpService.post(`/api/device/add_device_controller?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.DEVICE.ADD_CONTROLLER(), {data})
|
||||
}
|
||||
// 启停溶解氧
|
||||
export function setOxyOpen(data){
|
||||
return httpService.put(`/api/device/set_controller_oxy_open?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.put(`${API.DEVICE.SET_OXY_OPEN()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
/** 联动控制------------------------------------- */
|
||||
// 设备控制器列表
|
||||
export function linkerCtrlList(data){
|
||||
return httpService.post(`/api/linked-ctrl/fetch?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.LINKED_CTRL.LIST(), {data})
|
||||
}
|
||||
// 添加联动控制
|
||||
export function addLinkerCtrl(data){
|
||||
return httpService.post(`/api/linked-ctrl/add?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.LINKED_CTRL.ADD(), {data})
|
||||
}
|
||||
// 修改联动控制
|
||||
export function updateLinkerCtrl(data){
|
||||
return httpService.put(`/api/linked-ctrl/update?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.LINKED_CTRL.UPDATE(), {data})
|
||||
}
|
||||
// 删除联动控制
|
||||
export function delLinkerCtrl(data){
|
||||
return httpService.delete(`/api/linked-ctrl/delete?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
// 后端需要 /{ids} 路径参数
|
||||
return httpService.delete(`${API.LINKED_CTRL.DELETE()}/${data.id}?rootUserId=${userId}`)
|
||||
}
|
||||
// 设置联动控制上下限开关
|
||||
export function setLinkOpen(data){
|
||||
return httpService.put(`/api/linked-ctrl/set_open?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.LINKED_CTRL.SET_OPEN(), {data})
|
||||
}
|
||||
/** 开关------------------------------------------------ */
|
||||
// 开关列表
|
||||
export function pondSwitchList(data){
|
||||
return httpService.post(`/api/device-switch/get_pond_switch?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.SWITCH.POND_LIST(), {data})
|
||||
}
|
||||
// 开关详情
|
||||
export function switchInfo(data){
|
||||
return httpService.post(`/api/device-switch/one_switch_info?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.SWITCH.INFO(), {data})
|
||||
}
|
||||
// 修改开关名称
|
||||
export function updateSwitchName(data){
|
||||
return httpService.put(`/api/device-switch/update_name?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.UPDATE_NAME(), {data})
|
||||
}
|
||||
// 修改关联塘口
|
||||
export function updateSwitchPond(data){
|
||||
return httpService.put(`/api/device-switch/update_pond?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.UPDATE_POND(), {data})
|
||||
}
|
||||
// 修改接线方式
|
||||
export function updateSwitchType(data){
|
||||
return httpService.put(`/api/device-switch/update_voltage_type?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.UPDATE_VOLTAGE(), {data})
|
||||
}
|
||||
// 单个开关 启停
|
||||
export function turnSwitch(data){
|
||||
return httpService.put(`/api/device-switch/turn_switch?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.TURN(), {data})
|
||||
}
|
||||
// 所有开关 启停
|
||||
export function turnPondSwitch(data){
|
||||
return httpService.put(`/api/device-switch/turn_pond_switch?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.TURN_POND(), {data})
|
||||
}
|
||||
|
||||
// 电压告警开关 开启或关闭
|
||||
export function voltageCheckOpen(data){
|
||||
return httpService.put(`/api/device/voltage_check_open?rootuserid=${store.getRootUserId}`,{data})
|
||||
const userId = Taro.getStorageSync('UserId');
|
||||
return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data})
|
||||
}
|
||||
// 电流告警开关 开启或关闭
|
||||
export function electricCheckOpen(data){
|
||||
return httpService.put(`/api/device-switch/electric_check_open?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.ELECTRIC_CHECK(), {data})
|
||||
}
|
||||
// 电流告警开关 开启或关闭
|
||||
export function electricSet(data){
|
||||
return httpService.put(`/api/device-switch/electric_set?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.SWITCH.ELECTRIC_SET(), {data})
|
||||
}
|
||||
|
||||
// 定时开关列表
|
||||
export function timeCtrlList(data){
|
||||
return httpService.put(`/api/device-switch-time-ctrl/list?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.TIME_CTRL.LIST(), {data})
|
||||
}
|
||||
export function addTimeCtrl(data){
|
||||
return httpService.post(`/api/device-switch-time-ctrl/add?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.TIME_CTRL.ADD(), {data})
|
||||
}
|
||||
export function delTimeCtrl(data){
|
||||
return httpService.delete(`/api/device-switch-time-ctrl/delete?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.delete(API.TIME_CTRL.DELETE(), {data})
|
||||
}
|
||||
export function setTimeCtrlOpen(data){
|
||||
return httpService.post(`/api/device-switch-time-ctrl/update?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.TIME_CTRL.UPDATE(), {data})
|
||||
}
|
||||
// 夜间防误触
|
||||
export function setNightProtect(data){
|
||||
return httpService.put(`/api/pond/keep_night_open?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.POND.KEEP_NIGHT_OPEN(), {data})
|
||||
}
|
||||
@@ -1,23 +1,43 @@
|
||||
import httpService from '@/utils/request'
|
||||
import {useRootUserStore} from '@/store/index';
|
||||
const store:any = useRootUserStore();
|
||||
import API from './config'
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
// 塘口模式1
|
||||
export function getPond1() {
|
||||
return httpService.get(`/api/pond/list_mode1?rootuserid=${store.getRootUserId}`)
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
return httpService.get(API.HOME.POND_LIST(), {
|
||||
params: {
|
||||
rootUserId: userId || undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 塘口模式2
|
||||
export function getPond2(){
|
||||
return httpService.get(`/api/pond/list_mode2?rootuserid=${store.getRootUserId}`)
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
return httpService.get(API.HOME.POND_LIST_MODE2(), {
|
||||
params: {
|
||||
rootUserId: userId || undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 公告列表
|
||||
export function noticeList(){
|
||||
return httpService.get(`/api/sys-notice/notice_list?rootuserid=${store.getRootUserId}`)
|
||||
return httpService.get(API.HOME.NOTICE_LIST())
|
||||
}
|
||||
|
||||
// 即将到期设备列表
|
||||
export function deviceDead(){
|
||||
return httpService.get(`/api/device/list_device_dead?rootuserid=${store.getRootUserId}`)
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
return httpService.get(API.HOME.DEVICE_DEAD(), {
|
||||
params: {
|
||||
rootUserId: userId || undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取设备票据
|
||||
export function getDeviceTicket(){
|
||||
return httpService.get(`/api/user-center/getsnticket`)
|
||||
return httpService.get(API.HOME.DEVICE_TICKET())
|
||||
}
|
||||
@@ -1,23 +1,29 @@
|
||||
import httpService from '@/utils/request'
|
||||
import API from './config'
|
||||
|
||||
// 短信登录
|
||||
export function loginSms(phonenumber, code) {
|
||||
const data = {
|
||||
mobilePhone:phonenumber,
|
||||
phonenumber:phonenumber,
|
||||
smsCode:code,
|
||||
grantType:"sms",
|
||||
clientId:"428a8310cd442757ae699df5d894f051",
|
||||
tenantId:"111111",
|
||||
}
|
||||
return httpService.post(`/api/login/use_sms_code`, {
|
||||
data
|
||||
})
|
||||
return httpService.post(API.AUTH.LOGIN_SMS(), {data})
|
||||
}
|
||||
|
||||
// 获取短信验证码
|
||||
export function smsCode(phonenumber) {
|
||||
return httpService.get(`/sms_code/request?mobilePhone=` + phonenumber)
|
||||
return httpService.get(`${API.AUTH.SMS_CODE()}?phonenumber=${phonenumber}`)
|
||||
}
|
||||
|
||||
// 微信手机号登录
|
||||
export function loginWxToPhone(data) {
|
||||
return httpService.post(`/api/login/use_wechat` , {data})
|
||||
return httpService.post(API.AUTH.LOGIN_WECHAT(), {data})
|
||||
}
|
||||
|
||||
// 登出
|
||||
export function logoutFun() {
|
||||
return httpService.get(`/api/user-center/logout`)
|
||||
return httpService.get(API.AUTH.LOGOUT())
|
||||
}
|
||||
@@ -1,23 +1,28 @@
|
||||
import httpService from '@/utils/request'
|
||||
import {useRootUserStore} from '@/store/index';
|
||||
const store:any = useRootUserStore();
|
||||
import API from './config'
|
||||
|
||||
// 查询充值记录
|
||||
export function msgPay(data) {
|
||||
return httpService.post(`/api/message/page_pay?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.get(API.MESSAGE.PAY(), { params: data })
|
||||
}
|
||||
|
||||
// 查询报警记录
|
||||
export function msgWarn(data) {
|
||||
return httpService.post(`/api/message/page_warn?rootuserid=${store.getRootUserId}`,{data})
|
||||
// 后端接口:GET /fishery/messageWarn/list,使用查询参数传递分页信息
|
||||
return httpService.get(API.MESSAGE.WARN(), { params: data })
|
||||
}
|
||||
|
||||
// 查询开关记录
|
||||
export function msgSwitch(data) {
|
||||
return httpService.post(`/api/message/page_op_record?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.get(API.MESSAGE.SWITCH(), { params: data })
|
||||
}
|
||||
|
||||
// 已读一条消息
|
||||
export function msgRead(data) {
|
||||
return httpService.put(`/api/message/read_one_warn?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.MESSAGE.READ_ONE(), {data})
|
||||
}
|
||||
|
||||
// 已读全部
|
||||
export function msgReadAll(data) {
|
||||
return httpService.put(`/api/message/read_all_warn?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.MESSAGE.READ_ALL(), {data})
|
||||
}
|
||||
@@ -1,33 +1,42 @@
|
||||
import httpService from '@/utils/request'
|
||||
import API from './config'
|
||||
|
||||
// 报警电话列表
|
||||
export function warnPhoneList() {
|
||||
return httpService.get(`/api/user-center/list_warn_phone`)
|
||||
return httpService.get(API.USER.WARN_PHONE_LIST())
|
||||
}
|
||||
|
||||
// 修改报警电话
|
||||
export function updateWarnPhone(data) {
|
||||
return httpService.put(`/api/user-center/update_warn_phone`,{data})
|
||||
return httpService.put(API.USER.UPDATE_WARN_PHONE(), {data})
|
||||
}
|
||||
|
||||
// 修改手机号码
|
||||
export function updatePhone(data) {
|
||||
return httpService.put(`/api/user-center/update_mobile_phone`,{data})
|
||||
return httpService.put(API.USER.UPDATE_PHONE(), {data})
|
||||
}
|
||||
|
||||
// 验证验证码
|
||||
export function verifyCode(params) {
|
||||
return httpService.post(`/sms_code/verify`,{params})
|
||||
return httpService.post(API.USER.VERIFY_CODE(), {params})
|
||||
}
|
||||
|
||||
// 修改昵称
|
||||
export function updateNickName(data) {
|
||||
return httpService.put(`/api/user-center/update_user_name`,{data})
|
||||
return httpService.put(API.USER.UPDATE_NICKNAME(), {data})
|
||||
}
|
||||
|
||||
// 支付选项页面
|
||||
export function payOption() {
|
||||
return httpService.post(`/api/tenpay/get_pay_item`)
|
||||
return httpService.post(API.PAY.OPTIONS())
|
||||
}
|
||||
|
||||
// 创建支付订单
|
||||
export function createOrder(data) {
|
||||
return httpService.post(`/api/tenpay/create_order`,{data})
|
||||
return httpService.post(API.PAY.CREATE_ORDER(), {data})
|
||||
}
|
||||
|
||||
// 微信支付
|
||||
export function wxPayOrder(data) {
|
||||
return httpService.post(`https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi`,{data})
|
||||
return httpService.post(API.PAY.WECHAT_PAY(), {data})
|
||||
}
|
||||
@@ -1,27 +1,28 @@
|
||||
import httpService from '@/utils/request'
|
||||
import {useRootUserStore} from '@/store/index';
|
||||
const store:any = useRootUserStore();
|
||||
import API from './config'
|
||||
// 新增塘口
|
||||
export function PondAdd(data) {
|
||||
return httpService.post(`/api/pond/add?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.post(API.POND.ADD(), {data})
|
||||
}
|
||||
// 修改塘口
|
||||
export function PondUpdate(data){
|
||||
return httpService.put(`/api/pond/update?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.put(API.POND.UPDATE(), {data})
|
||||
}
|
||||
// 删除塘口
|
||||
export function PondDel(data){
|
||||
return httpService.delete(`/api/pond/delete?rootuserid=${store.getRootUserId}`,{data})
|
||||
// 后端接口:DELETE /{ids},参数拼接到URL路径
|
||||
return httpService.delete(API.POND.DELETE() + '/' + data.id)
|
||||
}
|
||||
// 鱼类列表
|
||||
export function fishList(){
|
||||
return httpService.post(`/api/fish/get`)
|
||||
return httpService.get(API.POND.FISH_LIST())
|
||||
}
|
||||
// 塘口基本数据
|
||||
export function pondBaseInfo(data){
|
||||
return httpService.post(`/api/pond/base_info?rootuserid=${store.getRootUserId}`,{data})
|
||||
return httpService.get(API.POND.BASE_INFO() + '/' + data.id)
|
||||
}
|
||||
// 塘口下设备信息
|
||||
export function pondDeviceInfo(data){
|
||||
return httpService.post(`/api/pond/pond_device_info?rootuserid=${store.getRootUserId}`,{data})
|
||||
// 后端接口:GET /devices/{pondId},使用路径参数
|
||||
return httpService.get(API.POND.DEVICE_INFO() + '/' + data.id)
|
||||
}
|
||||
@@ -1,17 +1,22 @@
|
||||
import httpService from '@/utils/request'
|
||||
import API from './config'
|
||||
|
||||
// 获取子账号列表
|
||||
export function list_user_child() {
|
||||
return httpService.get(`/api/user-center/list_user_child`)
|
||||
return httpService.get(API.SUB_ACCOUNT.LIST())
|
||||
}
|
||||
|
||||
// 添加
|
||||
export function add_user_child(data) {
|
||||
return httpService.post(`/api/user-center/add_user_child?mobilePhone=${data}`)
|
||||
return httpService.post(`${API.SUB_ACCOUNT.ADD()}?mobilePhone=${data}`)
|
||||
}
|
||||
|
||||
// 删除
|
||||
export function delete_user_child(data) {
|
||||
return httpService.delete(`/api/user-center/delete_user_child`,{data})
|
||||
return httpService.delete(API.SUB_ACCOUNT.DELETE(), {data})
|
||||
}
|
||||
|
||||
// 获取父级账号
|
||||
export function list_user_parent() {
|
||||
return httpService.get(`/api/user-center/list_user_parent`)
|
||||
return httpService.get(API.SUB_ACCOUNT.PARENT())
|
||||
}
|
||||
@@ -5,6 +5,7 @@ export default defineAppConfig({
|
||||
'pages/main/home',
|
||||
'pages/msg/index',
|
||||
'pages/main/my',
|
||||
'components/other/chartFullscreen',
|
||||
],
|
||||
requiredPrivateInfos: [
|
||||
"getLocation", "chooseLocation"
|
||||
|
||||
74
src/app.ts
74
src/app.ts
@@ -9,41 +9,45 @@ const App = createApp({
|
||||
})
|
||||
App.use(createPinia())
|
||||
App.provide('store', useRootUserStore());
|
||||
//判断目前微信版本是否支持自动更新
|
||||
if (Taro.canIUse("getUpdateManager")) {
|
||||
const update = Taro.getUpdateManager();
|
||||
update.onCheckForUpdate((res) => {
|
||||
//检测是否有新版本
|
||||
if (res.hasUpdate) {
|
||||
update.onUpdateReady(() => {
|
||||
// update.applyUpdate();
|
||||
//如果有新版本,给用户提示确认更新即可
|
||||
Taro.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
showCancel:false,
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启,如果想静默更新,直接在检测有新版本的时候调用此方法即可
|
||||
update.applyUpdate();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
//如果自动更新失败,给用户提示手动更新(有些小程序涉及到多ID使用,不更新会出现莫名的缓存bug,大部分小程序不用执行这一步)
|
||||
update.onUpdateFailed(() => {
|
||||
Taro.showModal({
|
||||
title: '已经有新版本了',
|
||||
content: '新版本已经上线,请您删除当前小程序,重新打开。'
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Taro.showModal({
|
||||
title: '提示',
|
||||
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
|
||||
})
|
||||
// 只在小程序环境执行更新检查
|
||||
if (process.env.TARO_ENV !== 'h5') {
|
||||
//判断目前微信版本是否支持自动更新
|
||||
if (Taro.canIUse("getUpdateManager")) {
|
||||
const update = Taro.getUpdateManager();
|
||||
update.onCheckForUpdate((res) => {
|
||||
//检测是否有新版本
|
||||
if (res.hasUpdate) {
|
||||
update.onUpdateReady(() => {
|
||||
// update.applyUpdate();
|
||||
//如果有新版本,给用户提示确认更新即可
|
||||
Taro.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
showCancel:false,
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启,如果想静默更新,直接在检测有新版本的时候调用此方法即可
|
||||
update.applyUpdate();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
//如果自动更新失败,给用户提示手动更新(有些小程序涉及到多ID使用,不更新会出现莫名的缓存bug,大部分小程序不用执行这一步)
|
||||
update.onUpdateFailed(() => {
|
||||
Taro.showModal({
|
||||
title: '已经有新版本了',
|
||||
content: '新版本已经上线,请您删除当前小程序,重新打开。'
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Taro.showModal({
|
||||
title: '提示',
|
||||
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
|
||||
})
|
||||
}
|
||||
}
|
||||
export default App
|
||||
|
||||
5
src/components/other/chartFullscreen.config.ts
Normal file
5
src/components/other/chartFullscreen.config.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '曲线图',
|
||||
navigationStyle: 'custom',
|
||||
enablePullDownRefresh: false,
|
||||
})
|
||||
388
src/components/other/chartFullscreen.vue
Normal file
388
src/components/other/chartFullscreen.vue
Normal file
@@ -0,0 +1,388 @@
|
||||
<template>
|
||||
<view class="chart-fullscreen-page">
|
||||
<!-- 顶部标题栏 -->
|
||||
<view class="header">
|
||||
<view class="back-btn" @click="goBack">
|
||||
<text class="icon">←</text>
|
||||
</view>
|
||||
<view class="title">{{ chartTitle }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 时间选择 -->
|
||||
<view class="time-selector">
|
||||
<view
|
||||
class="time-item"
|
||||
:class="{ active: dayType === 1 }"
|
||||
@click="changeDay(1)"
|
||||
>
|
||||
1天
|
||||
</view>
|
||||
<view
|
||||
class="time-item"
|
||||
:class="{ active: dayType === 3 }"
|
||||
@click="changeDay(3)"
|
||||
>
|
||||
3天
|
||||
</view>
|
||||
<view
|
||||
class="time-item"
|
||||
:class="{ active: dayType === 7 }"
|
||||
@click="changeDay(7)"
|
||||
>
|
||||
7天
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 图表容器 -->
|
||||
<view class="chart-container">
|
||||
<canvas
|
||||
class="chart-canvas"
|
||||
canvas-id="fullscreen-chart"
|
||||
id="fullscreen-chart"
|
||||
></canvas>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted } from 'vue';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { deviceHistory } from '@/api/device';
|
||||
import { formatDateMin } from '@/utils/tools';
|
||||
import uCharts from '@/utils/js-sdk/u-charts/u-charts.js';
|
||||
|
||||
const dayType = ref(1);
|
||||
const chartTitle = ref('溶解氧曲线图');
|
||||
const chartData = ref<any[]>([]);
|
||||
let chartInstance: any = null;
|
||||
|
||||
// 接收的参数
|
||||
const serialNum = ref('');
|
||||
const dataType = ref(1); // 1-溶解氧, 2-水温, 3-饱和度, 4-PH, 5-盐度
|
||||
|
||||
onMounted(() => {
|
||||
// 获取页面参数
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const params = instance.router?.params || {};
|
||||
|
||||
serialNum.value = params.serialNum || '';
|
||||
dataType.value = Number(params.dataType) || 1;
|
||||
dayType.value = Number(params.dayType) || 1;
|
||||
|
||||
// 设置标题
|
||||
const titles = ['', '溶解氧曲线图', '水温曲线图', '饱和度曲线图', 'PH曲线图', '盐度曲线图'];
|
||||
chartTitle.value = titles[dataType.value] || '曲线图';
|
||||
|
||||
// 初始化图表
|
||||
setTimeout(() => {
|
||||
initChart();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (chartInstance) {
|
||||
chartInstance = null;
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化图表
|
||||
function initChart() {
|
||||
// 横屏后的尺寸计算:
|
||||
// 页面宽度 = 屏幕高度(100vh)
|
||||
// 页面高度 = 屏幕宽度(100vw)
|
||||
// header(50px) + time-selector(50px) = 100px
|
||||
|
||||
const screenWidth = window.innerWidth; // 屏幕宽度
|
||||
const screenHeight = window.innerHeight; // 屏幕高度
|
||||
|
||||
// 横屏后:
|
||||
const cWidth = screenHeight - 40; // 页面宽度(100vh) - padding
|
||||
const cHeight = screenWidth - 120; // 页面高度(100vw) - header - time-selector - padding
|
||||
|
||||
console.log('📊 横屏图表尺寸计算:', {
|
||||
屏幕宽: screenWidth,
|
||||
屏幕高: screenHeight,
|
||||
图表宽: cWidth,
|
||||
图表高: cHeight
|
||||
});
|
||||
|
||||
// 加载数据
|
||||
loadChartData(cWidth, cHeight, 1);
|
||||
}
|
||||
|
||||
// 返回上一页
|
||||
function goBack() {
|
||||
Taro.navigateBack();
|
||||
}
|
||||
|
||||
// 返回首页
|
||||
function goHome() {
|
||||
Taro.switchTab({
|
||||
url: '/pages/main/home'
|
||||
});
|
||||
}
|
||||
|
||||
// 切换天数
|
||||
function changeDay(day: number) {
|
||||
dayType.value = day;
|
||||
|
||||
// 重新计算尺寸
|
||||
const screenWidth = window.innerWidth;
|
||||
const screenHeight = window.innerHeight;
|
||||
const cWidth = screenHeight - 40;
|
||||
const cHeight = screenWidth - 120;
|
||||
|
||||
loadChartData(cWidth, cHeight, 1);
|
||||
}
|
||||
|
||||
// 加载图表数据
|
||||
function loadChartData(cWidth: number, cHeight: number, pixelRatio: number) {
|
||||
if (!serialNum.value) return;
|
||||
|
||||
const now = new Date();
|
||||
const start = new Date(now.getTime() - dayType.value * 24 * 60 * 60 * 1000);
|
||||
|
||||
const params = {
|
||||
serialNum: serialNum.value,
|
||||
startTime: formatDateMin(start),
|
||||
endTime: formatDateMin(now),
|
||||
intervalType: dayType.value === 1 ? 1 : dayType.value === 3 ? 2 : 3,
|
||||
};
|
||||
|
||||
Taro.showLoading({ title: '加载中...' });
|
||||
|
||||
deviceHistory(params).then((res: any) => {
|
||||
Taro.hideLoading();
|
||||
|
||||
if (Array.isArray(res)) {
|
||||
chartData.value = res;
|
||||
} else if (res.code == 200) {
|
||||
chartData.value = res.data || [];
|
||||
}
|
||||
|
||||
// 绘制图表
|
||||
drawChart(cWidth, cHeight, pixelRatio);
|
||||
}).catch(() => {
|
||||
Taro.hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
// 绘制图表
|
||||
function drawChart(cWidth: number, cHeight: number, pixelRatio: number) {
|
||||
if (!chartData.value || chartData.value.length === 0) {
|
||||
console.log('❌ 数据为空');
|
||||
return;
|
||||
}
|
||||
|
||||
const fieldMap: any = {
|
||||
1: 'dissolvedOxygen',
|
||||
2: 'temperature',
|
||||
3: 'saturability',
|
||||
4: 'ph',
|
||||
5: 'salinity',
|
||||
};
|
||||
|
||||
const nameMap: any = {
|
||||
1: '溶解氧',
|
||||
2: '水温',
|
||||
3: '饱和度',
|
||||
4: 'PH',
|
||||
5: '盐度',
|
||||
};
|
||||
|
||||
const fieldName = fieldMap[dataType.value] || 'dissolvedOxygen';
|
||||
const seriesName = nameMap[dataType.value] || '溶解氧';
|
||||
|
||||
const xAxisData: string[] = [];
|
||||
const seriesData: number[] = [];
|
||||
|
||||
chartData.value.forEach((item: any) => {
|
||||
const timeStr = item.time || item.createTime || '';
|
||||
const timeParts = timeStr.split(' ');
|
||||
if (timeParts.length > 1) {
|
||||
const datePart = timeParts[0]; // YYYY-MM-DD
|
||||
const timePart = timeParts[1]; // HH:mm:ss.0
|
||||
|
||||
// 提取 MM-DD HH:mm
|
||||
const dateMatch = datePart.match(/\d{4}-(\d{2})-(\d{2})/);
|
||||
const monthDay = dateMatch ? `${dateMatch[1]}-${dateMatch[2]}` : '';
|
||||
const hourMin = timePart.substring(0, 5); // HH:mm
|
||||
|
||||
const formattedTime = `${monthDay} ${hourMin}`;
|
||||
xAxisData.push(formattedTime);
|
||||
}
|
||||
const value = item[fieldName];
|
||||
seriesData.push(value !== null && value !== undefined ? Number(value) : 0);
|
||||
});
|
||||
|
||||
// H5 环境,延迟获取 Canvas 确保 DOM 渲染完成
|
||||
setTimeout(() => {
|
||||
// Taro 在 H5 下会在容器内部生成 <canvas> 标签
|
||||
const canvasElement = document.querySelector('#fullscreen-chart canvas') as HTMLCanvasElement;
|
||||
|
||||
if (!canvasElement) {
|
||||
console.error('❌ Canvas 元素未找到');
|
||||
console.log('尝试查找所有 canvas...');
|
||||
const allCanvas = document.querySelectorAll('canvas');
|
||||
console.log('页面中所有 canvas:', allCanvas);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ 找到 Canvas 元素:', canvasElement);
|
||||
|
||||
const ctx = canvasElement.getContext('2d');
|
||||
if (!ctx) {
|
||||
console.error('❌ 无法获取 Canvas Context');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ 获取 Context 成功');
|
||||
|
||||
chartInstance = new uCharts({
|
||||
type: 'line',
|
||||
context: ctx,
|
||||
width: cWidth,
|
||||
height: cHeight,
|
||||
categories: xAxisData,
|
||||
series: [
|
||||
{
|
||||
name: seriesName,
|
||||
data: seriesData,
|
||||
}
|
||||
],
|
||||
pixelRatio: 1,
|
||||
dataPointShape: false,
|
||||
animation: true,
|
||||
background: '#FFFFFF',
|
||||
color: ['#1890FF'],
|
||||
padding: [15, 30, 35, 45],
|
||||
enableScroll: false,
|
||||
boundaryGap: 'justify',
|
||||
legend: {
|
||||
show: false
|
||||
},
|
||||
dataLabel: false,
|
||||
xAxis: {
|
||||
disableGrid: true,
|
||||
axisLine: true,
|
||||
type: 'grid',
|
||||
gridType: 'dash',
|
||||
itemCount: 0,
|
||||
scrollShow: false,
|
||||
scrollAlign: 'left',
|
||||
labelCount: 10,
|
||||
rotateLabel: true,
|
||||
rotateAngle: 25,
|
||||
},
|
||||
yAxis: {
|
||||
disableGrid: false,
|
||||
gridType: 'dash',
|
||||
tofix: 2,
|
||||
},
|
||||
extra: {
|
||||
line: {
|
||||
type: 'curve',
|
||||
width: 2,
|
||||
activeType: 'hollow',
|
||||
linearType: 'custom',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
console.log('✅ 图表绘制完成');
|
||||
}, 300);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.chart-fullscreen-page {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 100vh; // 横屏后的宽度 = 屏幕高度
|
||||
height: 100vw; // 横屏后的高度 = 屏幕宽度
|
||||
transform: translate(-50%, -50%) rotate(90deg);
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.header {
|
||||
height: 50px;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 15px;
|
||||
border-bottom: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
.back-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.icon {
|
||||
font-size: 28px;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.home-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.home-icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.time-selector {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
gap: 12px;
|
||||
background: #fff;
|
||||
flex-shrink: 0;
|
||||
height: 50px;
|
||||
|
||||
.time-item {
|
||||
padding: 8px 24px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 6px;
|
||||
font-size: 24px;
|
||||
color: #666;
|
||||
|
||||
&.active {
|
||||
background: #1890FF;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
padding: 10px;
|
||||
|
||||
.chart-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -102,8 +102,8 @@ onMounted(() => {
|
||||
// 鱼类列表
|
||||
function getFishList() {
|
||||
fishList().then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
fishArray.value = res.data;
|
||||
if (res.code == 200) {
|
||||
fishArray.value = res.rows || [];
|
||||
resTypeList();
|
||||
}
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -214,14 +214,33 @@ function cancelDate() {
|
||||
function save() {
|
||||
addRef.value?.validate().then(({ valid, errors }) => {
|
||||
if (valid) {
|
||||
isLoading.value = true
|
||||
PondAdd(formData).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
isLoading.value = true;
|
||||
|
||||
// 将fishKindIds数组转换为字符串格式 "[1,2]"
|
||||
let fishKindIdsStr = '';
|
||||
if (Array.isArray(formData.fishKindIds) && formData.fishKindIds.length > 0) {
|
||||
// 转换为数字数组,然后转JSON字符串
|
||||
const fishIds = formData.fishKindIds.map(id => Number(id));
|
||||
fishKindIdsStr = JSON.stringify(fishIds);
|
||||
}
|
||||
|
||||
// 转换数据格式以符合后端要求
|
||||
const requestData = {
|
||||
pondName: formData.pondName,
|
||||
fishKindIds: fishKindIdsStr, // 使用JSON字符串格式 "[1,2]"
|
||||
area: Number(formData.area) || 0,
|
||||
density: Number(formData.density) || 0,
|
||||
placeTime: formData.placeTime || null,
|
||||
};
|
||||
|
||||
console.log('添加塘口数据', requestData);
|
||||
PondAdd(requestData).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
saveRes.value = true;
|
||||
}
|
||||
}).finally(() => {
|
||||
isLoading.value = false
|
||||
})
|
||||
isLoading.value = false;
|
||||
});
|
||||
} else {
|
||||
console.warn("error:", errors);
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ function getBhd(){
|
||||
};
|
||||
getSaturability(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
const bhd = Number(res.data);
|
||||
saturability.value = bhd
|
||||
}
|
||||
|
||||
260
src/home/ctr.vue
260
src/home/ctr.vue
@@ -333,70 +333,58 @@
|
||||
>
|
||||
<!-- 绘制表格 -->
|
||||
<view class="m_t_15">
|
||||
<view
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
"
|
||||
class="tr"
|
||||
>
|
||||
<view class="tableTR tableTou"> 上限 </view>
|
||||
<view
|
||||
class="tableTR"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
{{
|
||||
item.oxyUpperOpen
|
||||
? item.oxyUpperValue + "Mg/L"
|
||||
: "-"
|
||||
}}
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
"
|
||||
class="tr"
|
||||
>
|
||||
<view class="tableTR tableTou"> 下限 </view>
|
||||
<view
|
||||
class="tableTR"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
{{
|
||||
item.oxyLowerOpen
|
||||
? item.oxyLowerValue + "Mg/L"
|
||||
: "-"
|
||||
}}
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
"
|
||||
class="tr"
|
||||
>
|
||||
<view class="tableTR tableTou"> 开关 </view>
|
||||
<view
|
||||
class="tableTR"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
<text
|
||||
class="truncate"
|
||||
:style="{
|
||||
maxWidth: '100rpx',
|
||||
textAlign: 'center',
|
||||
}"
|
||||
>{{ formatName(item.listSwitch) }}</text
|
||||
<view class="linked-table">
|
||||
<!-- 表头 -->
|
||||
<view class="table-row table-header">
|
||||
<view class="table-cell"></view>
|
||||
<view
|
||||
class="table-cell"
|
||||
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
联动{{ index + 1 }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上限行 -->
|
||||
<view class="table-row">
|
||||
<view class="table-cell table-label">上限</view>
|
||||
<view
|
||||
class="table-cell table-value"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="'up_' + item.id"
|
||||
>
|
||||
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 下限行 -->
|
||||
<view class="table-row">
|
||||
<view class="table-cell table-label">下限</view>
|
||||
<view
|
||||
class="table-cell table-value"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="'low_' + item.id"
|
||||
>
|
||||
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 开关行 -->
|
||||
<view class="table-row">
|
||||
<view class="table-cell table-label">开关</view>
|
||||
<view
|
||||
class="table-cell table-switch"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="'sw_' + item.id"
|
||||
>
|
||||
<view class="switch-names">
|
||||
<view
|
||||
class="switch-name"
|
||||
v-for="(sw, idx) in item.listSwitch"
|
||||
:key="sw.id"
|
||||
>
|
||||
{{ sw.switchName }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -941,7 +929,7 @@ Taro.useDidShow(() => {
|
||||
// 查询塘口列表
|
||||
function getPondList() {
|
||||
getPond2().then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
const arr = [{ id: 0, pondName: "无" }];
|
||||
res.data.forEach((r) => {
|
||||
arr.push({ id: r.id, pondName: r.pondName });
|
||||
@@ -953,9 +941,18 @@ function getPondList() {
|
||||
// 设备详情
|
||||
function getDevInfo() {
|
||||
deviceInfo({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
res.data.bindTime = formatDate(new Date(res.data.bindTime));
|
||||
res.data.deadTime = formatDate(new Date(res.data.deadTime));
|
||||
|
||||
// 将后端返回的 0/1 转换为布尔值
|
||||
res.data.isOxygenUsed = res.data.isOxygenUsed === 1;
|
||||
res.data.oxyWarnTelOpen = res.data.oxyWarnTelOpen === 1;
|
||||
res.data.oxyWarnTelNoDis = res.data.oxyWarnTelNoDis === 1;
|
||||
res.data.tempWarnTelOpen = res.data.tempWarnTelOpen === 1;
|
||||
res.data.tempWarnTelNoDis = res.data.tempWarnTelNoDis === 1;
|
||||
res.data.voltageWarnOpen = res.data.voltageWarnOpen === 1;
|
||||
|
||||
deviceInfoRes.value = res.data;
|
||||
pondId.value = res.data.pondInfo ? [res.data.pondInfo.id] : [0];
|
||||
voltageType.value = res.data.inputVoltage;
|
||||
@@ -980,7 +977,7 @@ function unbind() {
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
deviceDel({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "解绑成功";
|
||||
setTimeout(() => {
|
||||
@@ -1025,7 +1022,7 @@ function confirm({ selectedValue, selectedOptions }) {
|
||||
};
|
||||
deviceUpdatePond(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1044,10 +1041,11 @@ function changeO2(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 1,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0,
|
||||
isNoDisturb: deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1059,10 +1057,11 @@ function changeTem(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 2,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0,
|
||||
isNoDisturb: deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1086,7 +1085,7 @@ function setOxyEvent() {
|
||||
oxyWarnLower: oxy.value,
|
||||
};
|
||||
setOxyWarn(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.oxyWarnLower = oxy.value;
|
||||
@@ -1101,7 +1100,7 @@ function setNameEvent() {
|
||||
newName: deviceName.value,
|
||||
};
|
||||
deviceUpdateName(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.deviceName = deviceName.value;
|
||||
@@ -1122,7 +1121,7 @@ function setTempEvent() {
|
||||
tempWarnUpper: tempUp.value,
|
||||
};
|
||||
setTempWarn(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.tempWarnUpper = tempUp.value;
|
||||
@@ -1156,7 +1155,7 @@ function setNameSwitchEvent() {
|
||||
newName: switchName.value,
|
||||
};
|
||||
updateSwitchName(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
openSetNameSwitch.value = false;
|
||||
@@ -1204,9 +1203,10 @@ function setSalinity() {
|
||||
salinityCompensation: salinity.value,
|
||||
};
|
||||
setSal(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.salinityCompensation = salinity.value;
|
||||
openSalinity.value = false;
|
||||
}
|
||||
});
|
||||
@@ -1222,7 +1222,7 @@ function removeDev() {
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
deviceUnbind({ id }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
// alertRes.value = true
|
||||
state.show = true;
|
||||
state.msg = "移除成功";
|
||||
@@ -1242,13 +1242,13 @@ function changeTemDis(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 2,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0,
|
||||
isNoDisturb: deviceInfoRes.value.tempWarnTelOpen
|
||||
? deviceInfoRes.value.tempWarnTelNoDis
|
||||
: false,
|
||||
? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0)
|
||||
: 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1265,10 +1265,10 @@ function changeIsOxygenUsed(value, event) {
|
||||
if (event) {
|
||||
const data = {
|
||||
id: id,
|
||||
isOpen: deviceInfoRes.value.isOxygenUsed,
|
||||
isOpen: deviceInfoRes.value.isOxygenUsed ? 1 : 0,
|
||||
};
|
||||
setOxyOpen(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1277,11 +1277,11 @@ function changeIsOxygenUsed(value, event) {
|
||||
}
|
||||
function setTypeEvent() {
|
||||
const data = {
|
||||
id: Number(id),
|
||||
id: id,
|
||||
voltageType: voltageType.value,
|
||||
};
|
||||
deviceUpdateV(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.inputVoltage = voltageType.value;
|
||||
@@ -1295,10 +1295,10 @@ function changeV(value, event) {
|
||||
if (event) {
|
||||
const data = {
|
||||
id: id,
|
||||
isOpen: deviceInfoRes.value.voltageWarnOpen,
|
||||
isOpen: deviceInfoRes.value.voltageWarnOpen ? 1 : 0,
|
||||
};
|
||||
voltageCheckOpen(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1310,13 +1310,13 @@ function changeOxyDis(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 1,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0,
|
||||
isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen
|
||||
? deviceInfoRes.value.oxyWarnTelNoDis
|
||||
: false,
|
||||
? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0)
|
||||
: 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1448,4 +1448,82 @@ function changeOxyDis(value, event) {
|
||||
color: #17b4b2;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
/* 联动控制表格优化样式 */
|
||||
.linked-table {
|
||||
width: 100%;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: flex;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.table-header {
|
||||
background: #f8f8f8;
|
||||
font-weight: bold;
|
||||
|
||||
.table-cell {
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.table-cell {
|
||||
flex: 1;
|
||||
padding: 20rpx 10rpx;
|
||||
text-align: center;
|
||||
border-right: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 80rpx;
|
||||
|
||||
&:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
}
|
||||
|
||||
.table-label {
|
||||
flex: 0 0 100rpx;
|
||||
background: #fafafa;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.table-value {
|
||||
color: #17b4b2;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.table-switch {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.switch-names {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.switch-name {
|
||||
font-size: 24rpx;
|
||||
color: #17b4b2;
|
||||
padding: 6rpx 10rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 4rpx;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -55,14 +55,13 @@
|
||||
>
|
||||
{{ item.oxyUpperValue ? item.oxyUpperValue : "-" }}Mg/L
|
||||
</view>
|
||||
<nut-switch
|
||||
v-model="item.oxyUpperOpen"
|
||||
:ref="'up' + item.id"
|
||||
active-color="#04D98A"
|
||||
@change="
|
||||
(value, event) => setUpSwitch({ value, event }, item)
|
||||
"
|
||||
/>
|
||||
<view>
|
||||
<nut-switch
|
||||
v-model="item.oxyUpperOpen"
|
||||
active-color="#04D98A"
|
||||
@change="(value, event) => setUpSwitch({ value, event }, item)"
|
||||
/>
|
||||
</view>
|
||||
</nut-col>
|
||||
</nut-row>
|
||||
</nut-cell>
|
||||
@@ -85,14 +84,13 @@
|
||||
>
|
||||
{{ item.oxyLowerValue ? item.oxyLowerValue : "-" }}Mg/L
|
||||
</view>
|
||||
<nut-switch
|
||||
v-model="item.oxyLowerOpen"
|
||||
:ref="'lo' + item.id"
|
||||
active-color="#04D98A"
|
||||
@change="
|
||||
(value, event) => setLoSwitch({ value, event }, item)
|
||||
"
|
||||
/>
|
||||
<view>
|
||||
<nut-switch
|
||||
v-model="item.oxyLowerOpen"
|
||||
active-color="#04D98A"
|
||||
@change="(value, event) => setLoSwitch({ value, event }, item)"
|
||||
/>
|
||||
</view>
|
||||
</nut-col>
|
||||
</nut-row>
|
||||
</nut-cell>
|
||||
@@ -487,13 +485,6 @@ const themeVars = ref({
|
||||
cellBorderRadius: "4px",
|
||||
cellBoxShadow: "0px",
|
||||
cellPadding: "26rpx 0px",
|
||||
SwitchWidth: "112rpx",
|
||||
SwitchHeight: "56rpx",
|
||||
SwitchLineHeight: "56rpx",
|
||||
SwitchInsideHeight: "40rpx",
|
||||
SwitchInsideWidth: "40rpx",
|
||||
SwitchInsideOpenTransform: "translateX(155%)",
|
||||
SwitchInsideCloseTransform: "translateX(20%)",
|
||||
});
|
||||
const themeVars2 = ref({
|
||||
cellBoxShadow: "0px 0px 0px 0px",
|
||||
@@ -545,10 +536,18 @@ Taro.useDidShow(() => {
|
||||
// 查询联动控制
|
||||
function getLinksList() {
|
||||
linkerCtrlList({ id }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
console.log('完整返回数据:', JSON.stringify(res, null, 2));
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
res.data.forEach((item, index) => {
|
||||
console.log(`联动控制${index + 1}完整数据:`, JSON.stringify(item, null, 2));
|
||||
item.name = "联动控制" + (index + 1);
|
||||
// 调试:查看原始数据
|
||||
console.log('原始数据:', item.oxyUpperOpen, item.oxyLowerOpen, typeof item.oxyUpperOpen);
|
||||
// 将后端返回的 0/1 转换为布尔类型 - 强制设置为 true 或 false
|
||||
item.oxyUpperOpen = item.oxyUpperOpen === 1 ? true : false;
|
||||
item.oxyLowerOpen = item.oxyLowerOpen === 1 ? true : false;
|
||||
console.log('转换后:', item.oxyUpperOpen, item.oxyLowerOpen, typeof item.oxyUpperOpen);
|
||||
const switchName: any = [];
|
||||
if (item.listSwitch && item.listSwitch.length > 0) {
|
||||
item.listSwitch.forEach((r: any) => {
|
||||
@@ -559,13 +558,14 @@ function getLinksList() {
|
||||
});
|
||||
}
|
||||
linkList.value = res.data || [];
|
||||
console.log('最终linkList:', JSON.stringify(linkList.value, null, 2));
|
||||
}
|
||||
});
|
||||
}
|
||||
// 开关列表
|
||||
function getSwitchList(type = undefined,id=undefined) {
|
||||
pondSwitchList({ id: pondId }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
if (res.data.length > 0) {
|
||||
res.data.forEach((r) => {
|
||||
if (r.deviceType == 2) {
|
||||
@@ -639,7 +639,7 @@ function remove(name, id) {
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
delLinkerCtrl({ id }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "删除成功";
|
||||
getLinksList();
|
||||
@@ -715,7 +715,7 @@ function addHandler() {
|
||||
if (params.value.id) {
|
||||
updateLinkerCtrl(params.value)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "编辑成功";
|
||||
getLinksList();
|
||||
@@ -728,7 +728,7 @@ function addHandler() {
|
||||
} else {
|
||||
addLinkerCtrl(params.value)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "添加成功";
|
||||
getLinksList();
|
||||
@@ -808,7 +808,7 @@ function setUpSwitch({ value, event }, item: any) {
|
||||
const data = {
|
||||
id: item.id,
|
||||
openType: 1,
|
||||
isOpen: item.oxyUpperOpen,
|
||||
isOpen: item.oxyUpperOpen ? 1 : 0, // 布尔转数字
|
||||
};
|
||||
switchParams.value = data;
|
||||
if (item.oxyUpperOpen) {
|
||||
@@ -823,7 +823,7 @@ function setLoSwitch({ value, event }, item: any) {
|
||||
const data = {
|
||||
id: item.id,
|
||||
openType: 2,
|
||||
isOpen: item.oxyLowerOpen,
|
||||
isOpen: item.oxyLowerOpen ? 1 : 0, // 布尔转数字
|
||||
};
|
||||
switchParams.value = data;
|
||||
if (item.oxyLowerOpen) {
|
||||
@@ -845,12 +845,21 @@ function setSwitchOpenNone() {
|
||||
function setSwitchOpen(data) {
|
||||
setLinkOpen(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
const tag = data.isOpen ? "开启" : "关闭";
|
||||
state.msg = tag + "成功";
|
||||
// 重新加载列表以同步状态
|
||||
getLinksList();
|
||||
} else {
|
||||
// 失败时恢复开关状态
|
||||
getLinksList();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// 错误时恢复开关状态
|
||||
getLinksList();
|
||||
})
|
||||
.finally(() => {
|
||||
openAlert.value = false;
|
||||
});
|
||||
@@ -962,7 +971,7 @@ function updateOxy(item) {
|
||||
function upHandler() {
|
||||
updateLinkerCtrl(params.value)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "编辑成功";
|
||||
getLinksList();
|
||||
|
||||
@@ -325,7 +325,7 @@ import Taro from "@tarojs/taro";
|
||||
import { imgUrl } from "@/utils/imgUrl";
|
||||
const r_v = `${imgUrl}r_v.png`;
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const id = Number(instance.router.params.id);
|
||||
const id = (instance.router.params.id);
|
||||
// const id = 21;
|
||||
const name = instance.router.params.name;
|
||||
Taro.setNavigationBarTitle({
|
||||
@@ -393,7 +393,7 @@ Taro.useDidShow(() => {
|
||||
// 查询塘口列表
|
||||
function getPondList() {
|
||||
getPond2().then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
const arr = [{ id: 0, pondName: "无" }];
|
||||
res.data.forEach((r) => {
|
||||
arr.push({ id: r.id, pondName: r.pondName });
|
||||
@@ -405,7 +405,11 @@ function getPondList() {
|
||||
// 开关详情
|
||||
function getSwitchInfo() {
|
||||
switchInfo({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
// 将后端返回的 0/1 转换为布尔值
|
||||
res.data.voltageWarnOpen = res.data.voltageWarnOpen === 1;
|
||||
res.data.electricWarnOpen = res.data.electricWarnOpen === 1;
|
||||
|
||||
switchInfoRes.value = res.data;
|
||||
pondId.value = res.data.pondInfo ? [Number(res.data.pondInfo.id)] : [];
|
||||
voltageType.value = res.data.connectVoltageType ? res.data.connectVoltageType : 1;
|
||||
@@ -426,7 +430,7 @@ function confirm({ selectedValue, selectedOptions }) {
|
||||
};
|
||||
updateSwitchPond(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -451,7 +455,7 @@ function setVEvent() {
|
||||
electric: Number(V.value),
|
||||
};
|
||||
electricSet(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
switchInfoRes.value.rateElectricValue = V.value;
|
||||
@@ -474,7 +478,7 @@ function setTypeEvent() {
|
||||
voltageType: voltageType.value,
|
||||
};
|
||||
updateSwitchType(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
switchInfoRes.value.connectVoltageType = voltageType.value;
|
||||
@@ -503,10 +507,10 @@ function changeV(value, event) {
|
||||
if (event) {
|
||||
const data = {
|
||||
id: id,
|
||||
isOpen: switchInfoRes.value.voltageWarnOpen,
|
||||
isOpen: switchInfoRes.value.voltageWarnOpen ? 1 : 0, // 布尔转数字
|
||||
};
|
||||
voltageCheckOpen(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -517,10 +521,10 @@ function changeE(value, event) {
|
||||
if (event) {
|
||||
const data = {
|
||||
id: id,
|
||||
isOpen: switchInfoRes.value.electricWarnOpen,
|
||||
isOpen: switchInfoRes.value.electricWarnOpen ? 1 : 0, // 布尔转数字
|
||||
};
|
||||
electricCheckOpen(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
<script setup lang="ts" name="UpdatePond">
|
||||
import { UpdateFormType } from "./types";
|
||||
import Fish from "@/components/other/fish";
|
||||
import { PondUpdate, pondBaseInfo, pondDeviceInfo, PondDel } from "@/api/pond";
|
||||
import { PondUpdate, pondBaseInfo, pondDeviceInfo, PondDel, fishList } from "@/api/pond";
|
||||
import { allDeviceList, bandDeviceToPond } from "@/api/device";
|
||||
import { formatDate, sortByField } from "@/utils/tools";
|
||||
import Taro from "@tarojs/taro";
|
||||
@@ -285,6 +285,7 @@ const showFish = ref<boolean>(false);
|
||||
const isLoading = ref<boolean>(false);
|
||||
const d_isLoading = ref<boolean>(false);
|
||||
const fishListInfo = ref("");
|
||||
const allFishList = ref<any[]>([]);
|
||||
const detectorList = ref([]);
|
||||
const controlList = ref([]);
|
||||
const bandDevShow = ref(false);
|
||||
@@ -301,7 +302,10 @@ const Uid = Taro.getStorageSync("UserId");
|
||||
const rootuserid = ref(store.getRootUserId);
|
||||
/** -----------------method start----------------- */
|
||||
Taro.useDidShow(() => {
|
||||
info();
|
||||
// 先加载鱼类列表,然后再加载塔口信息
|
||||
getAllFishList().then(() => {
|
||||
info();
|
||||
});
|
||||
getDeviceList();
|
||||
getDevicesList();
|
||||
});
|
||||
@@ -337,20 +341,35 @@ function save() {
|
||||
updateRef.value?.validate().then(({ valid, errors }) => {
|
||||
if (valid) {
|
||||
if (formData.id) {
|
||||
// 将fishKindIds数组转换为字符串格式 "[1,2]"
|
||||
let fishKindIdsStr = '';
|
||||
if (Array.isArray(formData.fishKindIds) && formData.fishKindIds.length > 0) {
|
||||
// 转换为数字数组,然后转JSON字符串
|
||||
const fishIds = formData.fishKindIds.map(id => Number(id));
|
||||
fishKindIdsStr = JSON.stringify(fishIds);
|
||||
}
|
||||
|
||||
const data = {
|
||||
id: formData.id,
|
||||
pondName: formData.pondName,
|
||||
fishKindIds: formData.fishKindIds,
|
||||
fishKindIds: fishKindIdsStr, // 使用字符串格式
|
||||
area: formData.area,
|
||||
density: formData.density,
|
||||
placeTime: formData.placeTime ? formData.placeTime : null,
|
||||
};
|
||||
console.log('保存数据', data);
|
||||
isLoading.value = true;
|
||||
PondUpdate(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "保存成功";
|
||||
// 延迟返回首页,让用户看到成功提示
|
||||
setTimeout(() => {
|
||||
Taro.switchTab({
|
||||
url: "/pages/main/home",
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -362,6 +381,39 @@ function save() {
|
||||
}
|
||||
});
|
||||
}
|
||||
// 获取所有鱼类列表
|
||||
function getAllFishList() {
|
||||
return fishList().then((res: any) => {
|
||||
console.log('鱼类列表接口返回', res);
|
||||
// 处理不同的返回格式
|
||||
if (res.rows) {
|
||||
// 直接返回 {total, rows} 格式
|
||||
allFishList.value = res.rows || [];
|
||||
console.log('鱼类列表加载完成(rows)', allFishList.value);
|
||||
} else if (res.code == 200 && res.data) {
|
||||
allFishList.value = res.data || [];
|
||||
console.log('鱼类列表加载完成(code)', allFishList.value);
|
||||
} else if (res.statusCode == 200 && res.data) {
|
||||
allFishList.value = res.data || [];
|
||||
console.log('鱼类列表加载完成(statusCode)', allFishList.value);
|
||||
} else {
|
||||
console.error('鱼类列表加载失败', res);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 根据鱼类ID获取鱼类名称
|
||||
function getFishNames(fishIds: any[]) {
|
||||
const names: string[] = [];
|
||||
console.log('查找鱼类名称', { fishIds, allFishList: allFishList.value });
|
||||
fishIds.forEach((id: any) => {
|
||||
const fish = allFishList.value.find((f: any) => f.id == id || f.id == String(id));
|
||||
if (fish) {
|
||||
names.push(fish.fishName);
|
||||
}
|
||||
});
|
||||
console.log('鱼类名称结果', names.join(","));
|
||||
return names.join(",");
|
||||
}
|
||||
// 查看鱼塘详情
|
||||
function info() {
|
||||
if (!id) {
|
||||
@@ -371,25 +423,33 @@ function info() {
|
||||
return;
|
||||
}
|
||||
pondBaseInfo({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
formData.id = res.data.id;
|
||||
formData.pondName = res.data.pondName;
|
||||
formData.fishKindIds = res.data.fishKindIds;
|
||||
formData.area = res.data.area;
|
||||
formData.density = res.data.density;
|
||||
|
||||
// 鱼类列表格式化
|
||||
const fishArray: any = [];
|
||||
const fishNames: any = [];
|
||||
res.data.listFish.forEach((item: any) => {
|
||||
fishArray.push(String(item.id));
|
||||
fishNames.push(String(item.fishName));
|
||||
});
|
||||
formData.fishKindIds = fishArray;
|
||||
fishListInfo.value = fishNames.length > 0 ? fishNames.join(",") : "";
|
||||
// 解析fishKindIds(后端返回的是字符串)
|
||||
let fishIds = [];
|
||||
try {
|
||||
if (typeof res.data.fishKindIds === 'string') {
|
||||
fishIds = JSON.parse(res.data.fishKindIds);
|
||||
} else if (Array.isArray(res.data.fishKindIds)) {
|
||||
fishIds = res.data.fishKindIds;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析fishKindIds失败', e);
|
||||
}
|
||||
formData.fishKindIds = fishIds.map(id => String(id));
|
||||
|
||||
// 根据ID查找鱼类名称
|
||||
fishListInfo.value = getFishNames(fishIds);
|
||||
|
||||
// 时间日期格式化
|
||||
val.value = new Date(res.data.placeTime);
|
||||
formData.placeTime = res.data.placeTime ? formatDate(val.value) : "";
|
||||
if (res.data.placeTime) {
|
||||
val.value = new Date(res.data.placeTime);
|
||||
formData.placeTime = formatDate(val.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -412,7 +472,7 @@ function bandDevice() {
|
||||
function getDeviceList() {
|
||||
// 查询塘口下设备列表
|
||||
pondDeviceInfo({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
detectorList.value = res.data.listDetector;
|
||||
controlList.value = res.data.listController;
|
||||
}
|
||||
@@ -420,8 +480,9 @@ function getDeviceList() {
|
||||
}
|
||||
// 设备列表
|
||||
function getDevicesList() {
|
||||
allDeviceList({ type: 1 }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
allDeviceList({ type: 1,rootUserId:userId }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
res.data.forEach((r: any) => {
|
||||
r.open = true;
|
||||
r.disabled = false;
|
||||
@@ -516,7 +577,7 @@ function onconfirm(list) {
|
||||
};
|
||||
bandDeviceToPond(data)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "绑定成功";
|
||||
getDeviceList();
|
||||
@@ -549,7 +610,7 @@ function delPond() {
|
||||
d_isLoading.value = true;
|
||||
PondDel({ id })
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "删除成功";
|
||||
// 返回首页
|
||||
|
||||
270
src/home/wqm.vue
270
src/home/wqm.vue
@@ -261,62 +261,58 @@
|
||||
>
|
||||
<!-- 绘制表格 -->
|
||||
<view class="m_t_15">
|
||||
<view
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
"
|
||||
class="tr"
|
||||
>
|
||||
<view class="tableTR tableTou"> 上限 </view>
|
||||
<view
|
||||
class="tableTR"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
{{ item.oxyUpperOpen?item.oxyUpperValue+'Mg/L':'-' }}
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
"
|
||||
class="tr"
|
||||
>
|
||||
<view class="tableTR tableTou"> 下限 </view>
|
||||
<view
|
||||
class="tableTR"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
{{ item.oxyLowerOpen?item.oxyLowerValue+'Mg/L':'-' }}
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
"
|
||||
class="tr"
|
||||
>
|
||||
<view class="tableTR tableTou"> 开关 </view>
|
||||
<view
|
||||
class="tableTR"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
<text
|
||||
class="truncate"
|
||||
:style="{
|
||||
maxWidth: '100rpx',
|
||||
textAlign: 'center',
|
||||
}"
|
||||
>{{ formatName(item.listSwitch) }}</text
|
||||
<view class="linked-table">
|
||||
<!-- 表头 -->
|
||||
<view class="table-row table-header">
|
||||
<view class="table-cell"></view>
|
||||
<view
|
||||
class="table-cell"
|
||||
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
|
||||
:key="item.id"
|
||||
>
|
||||
联动{{ index + 1 }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上限行 -->
|
||||
<view class="table-row">
|
||||
<view class="table-cell table-label">上限</view>
|
||||
<view
|
||||
class="table-cell table-value"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="'up_' + item.id"
|
||||
>
|
||||
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 下限行 -->
|
||||
<view class="table-row">
|
||||
<view class="table-cell table-label">下限</view>
|
||||
<view
|
||||
class="table-cell table-value"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="'low_' + item.id"
|
||||
>
|
||||
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 开关行 -->
|
||||
<view class="table-row">
|
||||
<view class="table-cell table-label">开关</view>
|
||||
<view
|
||||
class="table-cell table-switch"
|
||||
v-for="item in deviceInfoRes.listLinkedCtr"
|
||||
:key="'sw_' + item.id"
|
||||
>
|
||||
<view class="switch-names">
|
||||
<view
|
||||
class="switch-name"
|
||||
v-for="(sw, idx) in item.listSwitch"
|
||||
:key="sw.id"
|
||||
>
|
||||
{{ sw.switchName }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -773,7 +769,7 @@ Taro.useDidShow(() => {
|
||||
// 查询塘口列表
|
||||
function getPondList() {
|
||||
getPond2().then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
const arr = [{ id: 0, pondName: "无" }];
|
||||
res.data.forEach(r=>{
|
||||
arr.push({id:r.id,pondName:r.pondName})
|
||||
@@ -785,9 +781,17 @@ function getPondList() {
|
||||
// 设备详情
|
||||
function getDevInfo() {
|
||||
deviceInfo({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
res.data.bindTime = formatDate(new Date(res.data.bindTime));
|
||||
res.data.deadTime = formatDate(new Date(res.data.deadTime));
|
||||
|
||||
// 将数字类型转为布尔类型
|
||||
res.data.oxyWarnTelOpen = !!res.data.oxyWarnTelOpen;
|
||||
res.data.oxyWarnTelNoDis = !!res.data.oxyWarnTelNoDis;
|
||||
res.data.tempWarnTelOpen = !!res.data.tempWarnTelOpen;
|
||||
res.data.tempWarnTelNoDis = !!res.data.tempWarnTelNoDis;
|
||||
res.data.isOxygenUsed = !!res.data.isOxygenUsed;
|
||||
|
||||
deviceInfoRes.value = res.data;
|
||||
pondId.value = res.data.pondInfo ? [Number(res.data.pondInfo.id)] : [0];
|
||||
}
|
||||
@@ -814,7 +818,7 @@ function unbind() {
|
||||
if (res.confirm) {
|
||||
b_isLoading.value = true
|
||||
deviceDel({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "解绑成功";
|
||||
setTimeout(() => {
|
||||
@@ -864,7 +868,7 @@ console.log(selectedValue)
|
||||
};
|
||||
deviceUpdatePond(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -883,13 +887,13 @@ function changeO2(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 1,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, // 布尔转数字
|
||||
isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen
|
||||
? deviceInfoRes.value.oxyWarnTelNoDis
|
||||
: false,
|
||||
? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) // 布尔转数字
|
||||
: 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -901,13 +905,13 @@ function changeTem(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 2,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, // 布尔转数字
|
||||
isNoDisturb: deviceInfoRes.value.tempWarnTelOpen
|
||||
? deviceInfoRes.value.tempWarnTelNoDis
|
||||
: false,
|
||||
? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) // 布尔转数字
|
||||
: 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -942,7 +946,7 @@ function setOxyEvent() {
|
||||
oxyWarnLower: oxy.value,
|
||||
};
|
||||
setOxyWarn(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.oxyWarnLower = oxy.value;
|
||||
@@ -957,11 +961,12 @@ function setNameEvent() {
|
||||
newName: deviceName.value,
|
||||
};
|
||||
deviceUpdateName(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.deviceName = deviceName.value;
|
||||
openSetName.value = false;
|
||||
// 重新加载设备信息
|
||||
getDevInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -995,7 +1000,7 @@ function setTempEvent() {
|
||||
tempWarnUpper: tempUp.value,
|
||||
};
|
||||
setTempWarn(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.tempWarnUpper = tempUp.value;
|
||||
@@ -1035,7 +1040,7 @@ function setSalinity() {
|
||||
salinityCompensation: salinity.value ? Number(salinity.value) : 0,
|
||||
};
|
||||
setSal(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
deviceInfoRes.value.salinityCompensation = salinity.value;
|
||||
@@ -1053,13 +1058,13 @@ function changeOxyDis(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 1,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, // 布尔转数字
|
||||
isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen
|
||||
? deviceInfoRes.value.oxyWarnTelNoDis
|
||||
: false,
|
||||
? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) // 布尔转数字
|
||||
: 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
@@ -1072,46 +1077,19 @@ function changeTemDis(value, event) {
|
||||
const data = {
|
||||
deviceId: id,
|
||||
type: 2,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen,
|
||||
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, // 布尔转数字
|
||||
isNoDisturb: deviceInfoRes.value.tempWarnTelOpen
|
||||
? deviceInfoRes.value.tempWarnTelNoDis
|
||||
: false,
|
||||
? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) // 布尔转数字
|
||||
: 0,
|
||||
};
|
||||
setWarnCall(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "设置成功";
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// 移除设备
|
||||
function removeDev() {
|
||||
Taro.showModal({
|
||||
title: "提示",
|
||||
content:
|
||||
"移除后会将设备从塘口移除,并和塘口内的其他设备解除关联关系。确认移除该设备?",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
r_isLoading.value = true
|
||||
deviceUnbind({ id }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
// alertRes.value = true
|
||||
state.show = true;
|
||||
state.msg = "移除成功";
|
||||
deviceInfoRes.value.pondInfo = {
|
||||
id: 0,
|
||||
pondName: "请绑定塘口",
|
||||
};
|
||||
}
|
||||
}).finally(() => {
|
||||
r_isLoading.value = false
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
// 返回上一页
|
||||
function onGoBack() {
|
||||
Taro.navigateBack({ delta: 1 });
|
||||
@@ -1248,4 +1226,82 @@ function onblur() {
|
||||
color: #17b4b2;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
/* 联动控制表格优化样式 */
|
||||
.linked-table {
|
||||
width: 100%;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: flex;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.table-header {
|
||||
background: #f8f8f8;
|
||||
font-weight: bold;
|
||||
|
||||
.table-cell {
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.table-cell {
|
||||
flex: 1;
|
||||
padding: 20rpx 10rpx;
|
||||
text-align: center;
|
||||
border-right: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 80rpx;
|
||||
|
||||
&:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
}
|
||||
|
||||
.table-label {
|
||||
flex: 0 0 100rpx;
|
||||
background: #fafafa;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.table-value {
|
||||
color: #17b4b2;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.table-switch {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.switch-names {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.switch-name {
|
||||
font-size: 24rpx;
|
||||
color: #17b4b2;
|
||||
padding: 6rpx 10rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 4rpx;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -386,7 +386,31 @@ definePageConfig({
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const r = instance.router.params.params;
|
||||
const page = instance.router.params.page;
|
||||
const params = r ? JSON.parse(r) : undefined;
|
||||
|
||||
console.log('URL参数原始值', r);
|
||||
let params: any = undefined;
|
||||
try {
|
||||
if (r) {
|
||||
// URL解码后再解析JSON
|
||||
const decodedParams = decodeURIComponent(r);
|
||||
console.log('URL解码后', decodedParams);
|
||||
params = JSON.parse(decodedParams);
|
||||
console.log('解析后的参数', params);
|
||||
} else {
|
||||
console.error('未获取到params参数');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('参数解析失败', e, '原始参数:', r);
|
||||
// 参数解析失败,显示提示后返回
|
||||
Taro.showModal({
|
||||
title: '提示',
|
||||
content: '参数错误,请重新进入',
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
Taro.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
const check = `https://www.yuceyun.cn/wechat/check.png`;
|
||||
const check_a = `https://www.yuceyun.cn/wechat/check_a.png`;
|
||||
const r_v = `https://www.yuceyun.cn/wechat/r_v.png`;
|
||||
@@ -434,14 +458,22 @@ const waterType = ref<number>(1);
|
||||
/** ----------------metod start------------------ */
|
||||
// 监测设备在线状态
|
||||
function getCheckDevice() {
|
||||
if (!params) {
|
||||
console.error('params参数为空');
|
||||
state.show = true;
|
||||
state.msg = '参数错误';
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
devicetype: params.devType,
|
||||
serialnum: params.devNum,
|
||||
};
|
||||
console.log('检查设备状态', data);
|
||||
isLoading.value = true;
|
||||
checkDeviceStatus(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
status.value = res.data;
|
||||
if (status.value == 0) {
|
||||
state.show = true;
|
||||
@@ -454,6 +486,9 @@ function getCheckDevice() {
|
||||
} else if (status.value == 8) {
|
||||
state.show = true;
|
||||
state.msg = "设备禁用";
|
||||
} else {
|
||||
state.show = true;
|
||||
state.msg = "设备异常";
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -462,6 +497,12 @@ function getCheckDevice() {
|
||||
});
|
||||
}
|
||||
function next() {
|
||||
if (!params) {
|
||||
state.show = true;
|
||||
state.msg = '参数错误';
|
||||
return;
|
||||
}
|
||||
|
||||
const num = current.value;
|
||||
if (num == 4) {
|
||||
// 验证参数,发起添加设备请求
|
||||
@@ -502,8 +543,9 @@ function next() {
|
||||
listPutPondPartId: listPutPondPartId.value,
|
||||
isOxygenUsed:isHave.value==1?true:false
|
||||
};
|
||||
console.log('添加设备数据', data);
|
||||
addDeviceController(data).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
Taro.redirectTo({
|
||||
url: "/my/addDevSuccess?name=添加测控一体机&page=" + page,
|
||||
});
|
||||
|
||||
@@ -284,7 +284,31 @@ const check_a = `https://www.yuceyun.cn/wechat/check_a.png`;
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const r = instance.router.params.params;
|
||||
const page = instance.router.params.page;
|
||||
const params = r ? JSON.parse(r) : undefined;
|
||||
|
||||
console.log('URL参数原始值', r);
|
||||
let params: any = undefined;
|
||||
try {
|
||||
if (r) {
|
||||
// URL解码后再解析JSON
|
||||
const decodedParams = decodeURIComponent(r);
|
||||
console.log('URL解码后', decodedParams);
|
||||
params = JSON.parse(decodedParams);
|
||||
console.log('解析后的参数', params);
|
||||
} else {
|
||||
console.error('未获取到params参数');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('参数解析失败', e, '原始参数:', r);
|
||||
// 参数解析失败,显示提示后返回
|
||||
Taro.showModal({
|
||||
title: '提示',
|
||||
content: '参数错误,请重新进入',
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
Taro.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
// 步骤
|
||||
const current = ref<number>(1);
|
||||
const themeVars = ref({
|
||||
@@ -314,14 +338,22 @@ const isLoading = ref<boolean>(false);
|
||||
/** ----------------metod start------------------ */
|
||||
// 监测设备在线状态
|
||||
function getCheckDevice() {
|
||||
if (!params) {
|
||||
console.error('params参数为空');
|
||||
state.show = true;
|
||||
state.msg = '参数错误';
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
devicetype: params.devType,
|
||||
serialnum: params.devNum,
|
||||
};
|
||||
console.log('检查设备状态', data);
|
||||
isLoading.value = true;
|
||||
checkDeviceStatus(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
status.value = res.data;
|
||||
if (status.value == 0) {
|
||||
state.show = true;
|
||||
@@ -345,6 +377,12 @@ function getCheckDevice() {
|
||||
});
|
||||
}
|
||||
function next() {
|
||||
if (!params) {
|
||||
state.show = true;
|
||||
state.msg = '参数错误';
|
||||
return;
|
||||
}
|
||||
|
||||
const num = current.value;
|
||||
if (num == 3) {
|
||||
isLoading.value = true;
|
||||
@@ -378,9 +416,10 @@ function next() {
|
||||
salinityCompensation: waterType.value == 1 ? 0 : Number(salt.value),
|
||||
oxyWarnLower: Number(alarm.value),
|
||||
};
|
||||
console.log('添加设备数据', data);
|
||||
addDeviceDetector(data)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
Taro.redirectTo({
|
||||
url: "/my/addDevSuccess?name=添加水质检测仪&page=" + page,
|
||||
});
|
||||
|
||||
@@ -397,8 +397,9 @@ function getPayItem() {
|
||||
}
|
||||
// 设备列表
|
||||
function getDeviceList() {
|
||||
allDeviceList({ type: 1 }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
allDeviceList({ type: 1,rootUserId:userId }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
res.data.forEach((item: any) => {
|
||||
const deadDay = daysBeforeToday(formatDate(new Date(item.deadTime)));
|
||||
item.deadDay = deadDay
|
||||
|
||||
@@ -141,12 +141,27 @@ function wxLoginCheck() {
|
||||
/** 微信登录 */
|
||||
function wxLogin(e) {
|
||||
isLoading.value = true;
|
||||
console.log('获取手机号返回:', e.detail);
|
||||
|
||||
// 用户拒绝授权
|
||||
if (!e.detail.code) {
|
||||
state.msg = "获取手机号失败,请允许授权";
|
||||
state.show = true;
|
||||
isLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.detail.code) {
|
||||
Taro.login({
|
||||
success: function (res) {
|
||||
console.log('微信登录返回:', res);
|
||||
if (res.code) {
|
||||
loginWxToPhone({ code: e.detail.code, js_code: res.code })
|
||||
const params = { code: e.detail.code, js_code: res.code };
|
||||
console.log('调用登录接口参数:', params);
|
||||
|
||||
loginWxToPhone(params)
|
||||
.then((res) => {
|
||||
console.log('登录接口返回:', res);
|
||||
if (res.statusCode == 200) {
|
||||
Taro.setStorageSync(
|
||||
"ReTime",
|
||||
@@ -169,27 +184,32 @@ function wxLogin(e) {
|
||||
url: "/pages/main/home",
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
state.msg = `登录失败:${res.data?.msg || '服务器返回异常'}`;
|
||||
state.show = true;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('登录接口错误:', err);
|
||||
state.msg = `登录失败:${err.data?.msg || err.errMsg || '网络错误'}`;
|
||||
state.show = true;
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false;
|
||||
});
|
||||
} else {
|
||||
state.msg = "登录失败";
|
||||
state.msg = "微信登录失败,请重试";
|
||||
state.show = true;
|
||||
isLoading.value = false;
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
state.msg = "登录失败";
|
||||
fail: function (err) {
|
||||
console.error('微信登录失败:', err);
|
||||
state.msg = `微信登录失败:${err.errMsg || '未知错误'}`;
|
||||
state.show = true;
|
||||
isLoading.value = false;
|
||||
},
|
||||
});
|
||||
} else {
|
||||
state.msg = "登录失败";
|
||||
state.show = true;
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
/** 查看用户协议 */
|
||||
|
||||
@@ -163,29 +163,38 @@ function login() {
|
||||
}
|
||||
isLoading.value = true
|
||||
loginSms(loginForm.phonenumber, loginForm.code).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
// 存储 token
|
||||
if (res.data.access_token) {
|
||||
Taro.setStorageSync("Access-Token", res.data.access_token);
|
||||
Taro.setStorageSync("X-Access-Token", res.data.access_token);
|
||||
}
|
||||
|
||||
Taro.setStorageSync(
|
||||
"ReTime",
|
||||
res.data.createdTime
|
||||
? formatDate(new Date(res.data.createdTime))
|
||||
: formatDate(new Date())
|
||||
);
|
||||
Taro.setStorageSync("UserName", res.data.userName);
|
||||
Taro.setStorageSync("Phone", res.data.mobilePhone);
|
||||
Taro.setStorageSync("UserName", res.data.userName || loginForm.phonenumber);
|
||||
Taro.setStorageSync("Phone", loginForm.phonenumber);
|
||||
Taro.setStorageSync("LoginType", "1");
|
||||
Taro.setStorageSync("UserId", res.data.id);
|
||||
Taro.setStorageSync("UserId", res.data.userId || "");
|
||||
Taro.setStorageSync("UnLogin", 2);
|
||||
store.updateLoginStatus(0);
|
||||
store.updateUnLogin(2);
|
||||
store.updateRootUserId(res.data.id);
|
||||
store.updateUserId(res.data.id);
|
||||
store.updateRootUserName(res.data.userName);
|
||||
store.updateRootUserId(res.data.userId || "");
|
||||
store.updateUserId(res.data.userId || "");
|
||||
store.updateRootUserName(res.data.userName || loginForm.phonenumber);
|
||||
state.msg = "登录成功";
|
||||
state.show = true;
|
||||
Taro.switchTab({
|
||||
url: "/pages/main/home",
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
state.msg = res.msg || "登录失败";
|
||||
state.show = true;
|
||||
}
|
||||
}).finally(()=>{
|
||||
isLoading.value = false
|
||||
|
||||
@@ -504,16 +504,16 @@
|
||||
<nut-tab-pane
|
||||
v-for="(item, index) in noticeRows"
|
||||
:key="index"
|
||||
:title="`${item.title}`"
|
||||
:title="`${item.noticeTitle}`"
|
||||
:pane-key="index"
|
||||
>
|
||||
<nut-row>
|
||||
<nut-col :span="24" :style="{ height: '200px' }">
|
||||
{{ item.content }}
|
||||
<view v-html="item.noticeContent"></view>
|
||||
</nut-col>
|
||||
<nut-col :span="24">
|
||||
<view :style="{ textAlign: 'right' }"
|
||||
>发布时间:{{ formatDateString(item.createdTime, "yyyy-mm-dd") }}</view
|
||||
>发布时间:{{ formatDateString(item.createTime, "yyyy-mm-dd") }}</view
|
||||
>
|
||||
<!-- <div>有效期至:{{formatDateMin(item.deadTime)}}</div> -->
|
||||
</nut-col>
|
||||
@@ -766,19 +766,19 @@ Taro.useUnload(() => {
|
||||
// 查询公告
|
||||
function getNotice(openType = 0) {
|
||||
noticeList().then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
const nList: any = [];
|
||||
noticeRows.value = res.data.sort(sortByField("priority", false));
|
||||
noticeRows.value = res.rows.sort(sortByField("priority", false));
|
||||
if (noticeRows.value.length > 0) {
|
||||
noticeRows.value.forEach((item: AnalyserOptions) => {
|
||||
const content: string = `${item.title}:${item.content}`;
|
||||
const content: string = `${item.noticeTitle}:${item.noticeContent}`;
|
||||
nList.push(content);
|
||||
});
|
||||
if (openType == 0) {
|
||||
notice.value = nList[0];
|
||||
if (store.getNoticeRead == 0) {
|
||||
noticeOpen.value = true;
|
||||
} else if (store.getNoticeRead != noticeRows.value[0]["createdTime"]) {
|
||||
} else if (store.getNoticeRead != noticeRows.value[0]["createTime"]) {
|
||||
noticeOpen.value = true;
|
||||
} else {
|
||||
noticeOpen.value = false;
|
||||
@@ -858,11 +858,12 @@ function resUsetInfo() {
|
||||
function getWarnMsg() {
|
||||
const warnParams = ref({
|
||||
pageSize: 10,
|
||||
curPage: 1,
|
||||
pageNum: 1,
|
||||
});
|
||||
msgWarn(warnParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
const unReadCount = Number(res.data.unReadCount);
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
msgWarn({ ...warnParams.value, userId }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const unReadCount = res.rows ? res.rows.filter(item => !item.isRead).length : 0;
|
||||
if (unReadCount) {
|
||||
Taro.setTabBarBadge({
|
||||
index: 1, // tabBar的位置,从0开始计数
|
||||
@@ -921,15 +922,17 @@ function changeMode() {
|
||||
}
|
||||
// 塘口模式1
|
||||
function pond1() {
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
getPond1().then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
const pondIds = [];
|
||||
res.data.forEach((item: any) => {
|
||||
const rows = res.data || [];
|
||||
rows.forEach((item: any) => {
|
||||
pondIds.push(item.id);
|
||||
let num = 3;
|
||||
const msg = item.warnCodeInfo.warnDescription;
|
||||
const showPh = !alarmJudgeCode(item.warnCodeInfo.warnCode, 1);
|
||||
const showSa = !alarmJudgeCode(item.warnCodeInfo.warnCode, 2);
|
||||
const msg = item.warnCodeInfo?.warnDescription || '';
|
||||
const showPh = !alarmJudgeCode(item.warnCodeInfo?.warnCode, 1);
|
||||
const showSa = !alarmJudgeCode(item.warnCodeInfo?.warnCode, 2);
|
||||
if (msg) {
|
||||
item.isPh = showPh;
|
||||
item.isSa = showSa;
|
||||
@@ -950,18 +953,18 @@ function pond1() {
|
||||
item.up = true;
|
||||
|
||||
});
|
||||
pondList.value = res.data;
|
||||
pondList.value = rows;
|
||||
setTimeout(() => {
|
||||
showTour.value = res.data.length == 0 ? true : false;
|
||||
showTour.value = rows.length == 0 ? true : false;
|
||||
}, 500);
|
||||
selPond.value = selPond.value
|
||||
? selPond.value
|
||||
: res.data.length > 0
|
||||
? Number(res.data[0]["id"])
|
||||
: rows.length > 0
|
||||
? Number(rows[0]["id"])
|
||||
: undefined;
|
||||
if (selPond.value) {
|
||||
if (!pondIds.includes(selPond.value)) {
|
||||
selPond.value = res.data.length > 0 ? Number(res.data[0]["id"]) : undefined;
|
||||
selPond.value = rows.length > 0 ? Number(rows[0]["id"]) : undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -987,9 +990,10 @@ function addDevice() {
|
||||
}
|
||||
// 加载设备列表
|
||||
function loadDeviceList() {
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
const pondId = mode.value == 1 ? selPond.value : selPond_2.value;
|
||||
allDeviceList({ type: 1 }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
allDeviceList({ type: 1 ,rootUserId:userId}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res.data.length > 0) {
|
||||
res.data.forEach((r) => {
|
||||
r.disabled = false;
|
||||
@@ -1092,7 +1096,7 @@ function onconfirm(list) {
|
||||
};
|
||||
bandDeviceToPond(data)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "操作成功";
|
||||
pond2();
|
||||
@@ -1128,7 +1132,7 @@ function goScan() {
|
||||
success: (res) => {
|
||||
const result = res.result;
|
||||
deviceScan({ qrcode: result }).then((v) => {
|
||||
if (v.statusCode == 200) {
|
||||
if (v.code == 200) {
|
||||
params.devType = String(v.data.deviceType);
|
||||
params.devNum = v.data.serialNum;
|
||||
|
||||
@@ -1194,7 +1198,7 @@ function toLogin() {
|
||||
// 查询设备到期
|
||||
function getDeviceDead() {
|
||||
deviceDead().then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
deadList.value = res.data;
|
||||
// if(res.data.length>0){
|
||||
// Taro.showModal({
|
||||
@@ -1218,9 +1222,9 @@ function closeNotice() {
|
||||
noticeOpen.value = false;
|
||||
if (noticeRows.value.length > 0) {
|
||||
if (store.getNoticeRead == 0) {
|
||||
store.updateNoticeRead(noticeRows.value[0]["createdTime"]);
|
||||
} else if (store.getNoticeRead != noticeRows.value[0]["createdTime"]) {
|
||||
store.updateNoticeRead(noticeRows.value[0]["createdTime"]);
|
||||
store.updateNoticeRead(noticeRows.value[0]["createTime"]);
|
||||
} else if (store.getNoticeRead != noticeRows.value[0]["createTime"]) {
|
||||
store.updateNoticeRead(noticeRows.value[0]["createTime"]);
|
||||
}
|
||||
} else {
|
||||
store.updateNoticeRead(0);
|
||||
|
||||
@@ -333,7 +333,7 @@ Taro.useUnload(() => {
|
||||
function getWarnMsg() {
|
||||
const warnParams = ref({
|
||||
pageSize: 10,
|
||||
curPage: 1,
|
||||
pageNum: 1,
|
||||
})
|
||||
msgWarn(warnParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
<scroll-view
|
||||
:scroll-y="true"
|
||||
style="height: 80vh"
|
||||
@scrolltolower="lower"
|
||||
:refresherEnabled="true"
|
||||
@RefresherRefresh="refData"
|
||||
refresherThreshold="50"
|
||||
@@ -93,7 +92,7 @@
|
||||
>
|
||||
<view class="title">{{ item.title }}</view>
|
||||
<view class="time">{{
|
||||
item.createdTime ? formatDateMin(item.createdTime) : ""
|
||||
item.createTime ? formatDateMin(item.createTime) : ""
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="view_f_between_2">
|
||||
@@ -146,10 +145,10 @@
|
||||
<view class="title">{{ item.title }}</view>
|
||||
|
||||
<view class="time">{{
|
||||
item.createdTime ? formatDateMin(item.createdTime) : ""
|
||||
item.createTime ? formatDateMin(item.createTime) : ""
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="content" v-show="item.opName">{{ '控制模式:'+item.opName }}</view>
|
||||
<view class="content" v-if="item.opUserName">操作人:{{ item.opUserName }}</view>
|
||||
<view class="content">{{ item.message }}</view>
|
||||
</nut-col>
|
||||
</nut-row>
|
||||
@@ -176,25 +175,24 @@
|
||||
</nut-col>
|
||||
<nut-col :span="14">
|
||||
<view :style="{ display: 'flex', alignItems: 'center' }">
|
||||
<view class="title">{{
|
||||
item.deviceType == 2 ? "测控一体机" : "水质检测仪"
|
||||
}}</view>
|
||||
<view class="title">充值订单</view>
|
||||
</view>
|
||||
<view :style="{ display: 'flex', alignItems: 'center',marginTop:'10rpx' }">
|
||||
<nut-tag class="tag" :style="{marginLeft:'0px !important'}"> {{ item.addMonth }}个月 </nut-tag>
|
||||
<nut-tag class="tag"> {{ item.payType==1?'用户充值':'后台续期' }} </nut-tag>
|
||||
<nut-tag class="tag" v-if="item.orderStatus == 2"> 已支付 </nut-tag>
|
||||
<nut-tag class="tag" v-else-if="item.orderStatus == 1"> 待支付 </nut-tag>
|
||||
</view>
|
||||
<view class="content" v-if="item.serialNum ">
|
||||
设备:{{ item.serialNum }}
|
||||
<view class="content">
|
||||
设备数量:{{ item.deviceCount }}台
|
||||
</view>
|
||||
<view class="time mt">
|
||||
续费日期:{{
|
||||
item.createdTime ? formatDateMin(item.createdTime) : ""
|
||||
下单时间:{{
|
||||
item.createTime ? formatDateMin(item.createTime) : ""
|
||||
}}
|
||||
</view>
|
||||
<view class="time mt">
|
||||
到期日期:{{
|
||||
item.deadTime ? formatDate_(item.deadTime) : ""
|
||||
<view class="time mt" v-if="item.successTime">
|
||||
支付时间:{{
|
||||
item.successTime ? formatDateMin(item.successTime) : ""
|
||||
}}
|
||||
</view>
|
||||
</nut-col>
|
||||
@@ -209,7 +207,7 @@
|
||||
}"
|
||||
>
|
||||
<text class="price" style="line-height: 1"
|
||||
>¥{{ Number(item.payAmount)/100 }}</text
|
||||
>¥{{ item.totalAmountYuan }}</text
|
||||
>
|
||||
</nut-col>
|
||||
</nut-row>
|
||||
@@ -251,7 +249,7 @@ const selectVal = ref(0);
|
||||
const warnList = ref([]);
|
||||
const warnParams = ref({
|
||||
pageSize: 10,
|
||||
curPage: 1
|
||||
pageNum: 1
|
||||
});
|
||||
const warnTotal = ref(0);
|
||||
const warnTotalPages = ref(1);
|
||||
@@ -259,7 +257,7 @@ const warnTotalPages = ref(1);
|
||||
const switchList = ref([]);
|
||||
const switchParams = ref({
|
||||
pageSize: 10,
|
||||
curPage: 1
|
||||
pageNum: 1
|
||||
});
|
||||
const switchTotal = ref(0);
|
||||
const switchTotalPages = ref(1);
|
||||
@@ -267,7 +265,7 @@ const switchTotalPages = ref(1);
|
||||
const payList = ref([]);
|
||||
const payParams = ref({
|
||||
pageSize: 10,
|
||||
curPage: 1
|
||||
pageNum: 1
|
||||
});
|
||||
const payTotal = ref(0);
|
||||
const payTotalPages = ref(1);
|
||||
@@ -293,25 +291,34 @@ function changeVal(e) {
|
||||
|
||||
selectVal.value = e;
|
||||
if (e == 0) {
|
||||
warnParams.value.curPage = 1;
|
||||
warnParams.value.pageNum = 1;
|
||||
getWarnMsg();
|
||||
} else if (e == 1) {
|
||||
switchParams.value.curPage = 1;
|
||||
switchParams.value.pageNum = 1;
|
||||
getSwitchMsg();
|
||||
} else if (e == 2) {
|
||||
payParams.value.curPage = 1;
|
||||
payParams.value.pageNum = 1;
|
||||
getPayMsg();
|
||||
}
|
||||
}
|
||||
// 查询告警消息
|
||||
function getWarnMsg() {
|
||||
msgWarn(warnParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
warnList.value = res.data.items;
|
||||
warnTotal.value = res.data.totalCount;
|
||||
warnTotalPages.value = res.data.totalPages;
|
||||
unReadCount.value = res.data.unReadCount;
|
||||
msgCount.value = res.data.totalCount;
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
const params = {
|
||||
...warnParams.value,
|
||||
userId
|
||||
};
|
||||
msgWarn(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
// 数据直接在 res 上,不是 res.data
|
||||
warnList.value = res.rows || [];
|
||||
warnTotal.value = res.total || 0;
|
||||
// 计算总页数
|
||||
warnTotalPages.value = Math.ceil(warnTotal.value / warnParams.value.pageSize);
|
||||
// 统计未读数量
|
||||
unReadCount.value = warnList.value.filter(item => !item.isRead).length;
|
||||
msgCount.value = warnTotal.value;
|
||||
|
||||
if (unReadCount.value) {
|
||||
Taro.setTabBarBadge({
|
||||
index: 1, // tabBar的位置,从0开始计数
|
||||
@@ -327,55 +334,81 @@ function getWarnMsg() {
|
||||
}
|
||||
// 查询开关消息
|
||||
function getSwitchMsg() {
|
||||
msgSwitch(switchParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
switchList.value = res.data.items;
|
||||
switchTotal.value = res.data.totalCount;
|
||||
switchTotalPages.value = res.data.totalPages;
|
||||
msgCount.value = res.data.totalCount;
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
const params = {
|
||||
...switchParams.value,
|
||||
userId
|
||||
};
|
||||
msgSwitch(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
switchList.value = res.rows || [];
|
||||
switchTotal.value = res.total || 0;
|
||||
switchTotalPages.value = Math.ceil(switchTotal.value / switchParams.value.pageSize);
|
||||
msgCount.value = switchTotal.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 查询充值消息
|
||||
function getPayMsg() {
|
||||
msgPay(payParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
payList.value = res.data.items;
|
||||
payTotal.value = res.data.totalCount;
|
||||
payTotalPages.value = res.data.totalPages;
|
||||
msgCount.value = res.data.totalCount;
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
const params = {
|
||||
...payParams.value,
|
||||
userId
|
||||
};
|
||||
msgPay(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
payList.value = res.rows || [];
|
||||
payTotal.value = res.total || 0;
|
||||
payTotalPages.value = Math.ceil(payTotal.value / payParams.value.pageSize);
|
||||
msgCount.value = payTotal.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
function lower() {
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
if (selectVal.value == 0) {
|
||||
if (warnParams.value.curPage < warnTotalPages.value) {
|
||||
warnParams.value.curPage = warnParams.value.curPage + 1;
|
||||
msgWarn(warnParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
res.data.items.forEach((r) => {
|
||||
if (warnParams.value.pageNum < warnTotalPages.value) {
|
||||
warnParams.value.pageNum = warnParams.value.pageNum + 1;
|
||||
const params = {
|
||||
...warnParams.value,
|
||||
userId
|
||||
};
|
||||
msgWarn(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const newRows = res.rows || [];
|
||||
newRows.forEach((r) => {
|
||||
warnList.value.push(r);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (selectVal.value == 1) {
|
||||
if (switchParams.value.curPage < switchTotalPages.value) {
|
||||
switchParams.value.curPage = switchParams.value.curPage + 1;
|
||||
msgSwitch(switchParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
res.data.items.forEach((r) => {
|
||||
if (switchParams.value.pageNum < switchTotalPages.value) {
|
||||
switchParams.value.pageNum = switchParams.value.pageNum + 1;
|
||||
const params = {
|
||||
...switchParams.value,
|
||||
userId
|
||||
};
|
||||
msgSwitch(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const newRows = res.rows || [];
|
||||
newRows.forEach((r) => {
|
||||
switchList.value.push(r);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (selectVal.value == 2) {
|
||||
if (payParams.value.curPage < payTotalPages.value) {
|
||||
payParams.value.curPage = payParams.value.curPage + 1;
|
||||
msgPay(payParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
res.data.items.forEach((r) => {
|
||||
if (payParams.value.pageNum < payTotalPages.value) {
|
||||
payParams.value.pageNum = payParams.value.pageNum + 1;
|
||||
const params = {
|
||||
...payParams.value,
|
||||
userId
|
||||
};
|
||||
msgPay(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const newRows = res.rows || [];
|
||||
newRows.forEach((r) => {
|
||||
payList.value.push(r);
|
||||
});
|
||||
}
|
||||
@@ -385,34 +418,50 @@ function lower() {
|
||||
}
|
||||
/** 上拉触底分页 */
|
||||
Taro.useReachBottom(() => {
|
||||
const userId = Taro.getStorageSync("UserId");
|
||||
if (selectVal.value == 0) {
|
||||
if (warnParams.value.curPage < warnTotalPages.value) {
|
||||
warnParams.value.curPage = warnParams.value.curPage + 1;
|
||||
msgWarn(warnParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
res.data.items.forEach((r) => {
|
||||
if (warnParams.value.pageNum < warnTotalPages.value) {
|
||||
warnParams.value.pageNum = warnParams.value.pageNum + 1;
|
||||
const params = {
|
||||
...warnParams.value,
|
||||
userId
|
||||
};
|
||||
msgWarn(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const newRows = res.rows || [];
|
||||
newRows.forEach((r) => {
|
||||
warnList.value.push(r);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (selectVal.value == 1) {
|
||||
if (switchParams.value.curPage < switchTotalPages.value) {
|
||||
switchParams.value.curPage = switchParams.value.curPage + 1;
|
||||
msgSwitch(switchParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
res.data.items.forEach((r) => {
|
||||
if (switchParams.value.pageNum < switchTotalPages.value) {
|
||||
switchParams.value.pageNum = switchParams.value.pageNum + 1;
|
||||
const params = {
|
||||
...switchParams.value,
|
||||
userId
|
||||
};
|
||||
msgSwitch(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const newRows = res.rows || [];
|
||||
newRows.forEach((r) => {
|
||||
switchList.value.push(r);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (selectVal.value == 2) {
|
||||
if (payParams.value.curPage < payTotalPages.value) {
|
||||
payParams.value.curPage = payParams.value.curPage + 1;
|
||||
msgPay(payParams.value).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
res.data.items.forEach((r) => {
|
||||
if (payParams.value.pageNum < payTotalPages.value) {
|
||||
payParams.value.pageNum = payParams.value.pageNum + 1;
|
||||
const params = {
|
||||
...payParams.value,
|
||||
userId
|
||||
};
|
||||
msgPay(params).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
const newRows = res.rows || [];
|
||||
newRows.forEach((r) => {
|
||||
payList.value.push(r);
|
||||
});
|
||||
}
|
||||
@@ -423,7 +472,7 @@ Taro.useReachBottom(() => {
|
||||
// 已读
|
||||
function read(id) {
|
||||
msgRead({ id }).then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
getWarnMsg();
|
||||
}
|
||||
});
|
||||
@@ -434,7 +483,7 @@ function readAll() {
|
||||
id:0
|
||||
}
|
||||
msgReadAll().then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
getWarnMsg();
|
||||
}
|
||||
});
|
||||
|
||||
186
src/utils/api-helper.ts
Normal file
186
src/utils/api-helper.ts
Normal file
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* API辅助工具
|
||||
* 提供统一的参数处理和响应适配
|
||||
*/
|
||||
|
||||
/**
|
||||
* 构建请求URL
|
||||
* 根据新接口规范,不再需要拼接rootuserid参数
|
||||
* @param url 基础URL
|
||||
* @param params 查询参数对象(可选)
|
||||
* @returns 完整的URL
|
||||
*/
|
||||
export function buildUrl(url: string, params?: Record<string, any>): string {
|
||||
// 新版Java接口不需要拼接rootuserid
|
||||
// 认证信息通过header传递
|
||||
if (!params || Object.keys(params).length === 0) {
|
||||
return url
|
||||
}
|
||||
|
||||
const queryString = Object.entries(params)
|
||||
.filter(([_, value]) => value !== undefined && value !== null)
|
||||
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
||||
.join('&')
|
||||
|
||||
return queryString ? `${url}?${queryString}` : url
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应数据适配器
|
||||
* 处理C#和Java后端返回格式的差异
|
||||
*/
|
||||
export class ResponseAdapter {
|
||||
/**
|
||||
* 适配响应数据
|
||||
* @param response 原始响应数据
|
||||
* @returns 标准化后的响应数据
|
||||
*/
|
||||
static adapt(response: any): any {
|
||||
if (!response) return response
|
||||
|
||||
// 如果已经是标准格式,直接返回
|
||||
if (this.isStandardFormat(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
// 处理可能的格式差异
|
||||
// Java后端可能使用 code 而不是 statusCode
|
||||
if (response.code !== undefined && response.statusCode === undefined) {
|
||||
response.statusCode = response.code
|
||||
}
|
||||
|
||||
// Java后端可能使用 message 而不是 errors
|
||||
if (response.message !== undefined && response.errors === undefined) {
|
||||
response.errors = response.message
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为标准格式
|
||||
* @param response 响应数据
|
||||
* @returns 是否为标准格式
|
||||
*/
|
||||
private static isStandardFormat(response: any): boolean {
|
||||
return response.statusCode !== undefined && response.data !== undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断响应是否成功
|
||||
* @param response 响应数据
|
||||
* @returns 是否成功
|
||||
*/
|
||||
static isSuccess(response: any): boolean {
|
||||
const adapted = this.adapt(response)
|
||||
return adapted.statusCode === 200 || adapted.code === 200
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取响应数据
|
||||
* @param response 响应数据
|
||||
* @returns 数据内容
|
||||
*/
|
||||
static getData(response: any): any {
|
||||
const adapted = this.adapt(response)
|
||||
return adapted.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错误信息
|
||||
* @param response 响应数据
|
||||
* @returns 错误信息
|
||||
*/
|
||||
static getError(response: any): string {
|
||||
const adapted = this.adapt(response)
|
||||
return adapted.errors || adapted.message || '系统异常'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求参数构建器
|
||||
* 简化API调用时的参数构建
|
||||
*/
|
||||
export class ParamsBuilder {
|
||||
private params: Record<string, any> = {}
|
||||
|
||||
/**
|
||||
* 添加参数
|
||||
* @param key 参数名
|
||||
* @param value 参数值
|
||||
* @returns this
|
||||
*/
|
||||
add(key: string, value: any): this {
|
||||
if (value !== undefined && value !== null) {
|
||||
this.params[key] = value
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加参数
|
||||
* @param params 参数对象
|
||||
* @returns this
|
||||
*/
|
||||
addAll(params: Record<string, any>): this {
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
this.add(key, value)
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建最终参数对象
|
||||
* @returns 参数对象
|
||||
*/
|
||||
build(): Record<string, any> {
|
||||
return { ...this.params }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API路径生成器
|
||||
* 用于处理RESTful风格的路径参数
|
||||
*/
|
||||
export class PathBuilder {
|
||||
private path: string
|
||||
|
||||
constructor(basePath: string) {
|
||||
this.path = basePath
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加路径段
|
||||
* @param segment 路径段
|
||||
* @returns this
|
||||
*/
|
||||
append(segment: string | number): this {
|
||||
this.path = `${this.path}/${segment}`
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加多个路径段
|
||||
* @param segments 路径段数组
|
||||
* @returns this
|
||||
*/
|
||||
appendAll(...segments: (string | number)[]): this {
|
||||
segments.forEach(segment => this.append(segment))
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建最终路径
|
||||
* @returns 路径字符串
|
||||
*/
|
||||
build(): string {
|
||||
return this.path
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
buildUrl,
|
||||
ResponseAdapter,
|
||||
ParamsBuilder,
|
||||
PathBuilder,
|
||||
}
|
||||
@@ -8,7 +8,8 @@ const timeOutSeconds = 10000;
|
||||
const getBaseUrl = () => {
|
||||
let BASE_URL = ''
|
||||
if (process.env.TARO_ENV === 'h5') {
|
||||
BASE_URL = '/api' //填写你的请求域名
|
||||
BASE_URL = 'https://www.qdintc.com/fishery-api' // 线上调试后端
|
||||
// BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
|
||||
} else {
|
||||
BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名
|
||||
// BASE_URL = 'https://dev.yuceyun.cn' //测试环境
|
||||
@@ -75,6 +76,10 @@ const request = async (method, url, params) => {
|
||||
timeout: timeOutSeconds,
|
||||
header: {
|
||||
'content-type': contentType,
|
||||
'Authorization': Taro.getStorageSync('Access-Token') || '',
|
||||
'clientid': '428a8310cd442757ae699df5d894f051',
|
||||
'access-token': Taro.getStorageSync('Access-Token'),
|
||||
'x-access-token': Taro.getStorageSync('X-Access-Token'),
|
||||
},
|
||||
success(res) {
|
||||
if (res.header["access-token"] && res.header["x-access-token"]) {
|
||||
|
||||
15
types/auto-imports.d.ts
vendored
15
types/auto-imports.d.ts
vendored
@@ -7,9 +7,14 @@ export {}
|
||||
declare global {
|
||||
const BASE_URL: typeof import('../src/utils/request')['BASE_URL']
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const ParamsBuilder: typeof import('../src/utils/api-helper')['ParamsBuilder']
|
||||
const PathBuilder: typeof import('../src/utils/api-helper')['PathBuilder']
|
||||
const ResponseAdapter: typeof import('../src/utils/api-helper')['ResponseAdapter']
|
||||
const alarmJudge: typeof import('../src/utils/tools')['alarmJudge']
|
||||
const alarmJudgeCode: typeof import('../src/utils/tools')['alarmJudgeCode']
|
||||
const apiHelper: typeof import('../src/utils/api-helper')['default']
|
||||
const asd: typeof import('../src/utils/tools')['asd']
|
||||
const buildUrl: typeof import('../src/utils/api-helper')['buildUrl']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
@@ -103,7 +108,12 @@ declare module 'vue' {
|
||||
interface ComponentCustomProperties {
|
||||
readonly BASE_URL: UnwrapRef<typeof import('../src/utils/request')['BASE_URL']>
|
||||
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
|
||||
readonly ParamsBuilder: UnwrapRef<typeof import('../src/utils/api-helper')['ParamsBuilder']>
|
||||
readonly PathBuilder: UnwrapRef<typeof import('../src/utils/api-helper')['PathBuilder']>
|
||||
readonly ResponseAdapter: UnwrapRef<typeof import('../src/utils/api-helper')['ResponseAdapter']>
|
||||
readonly alarmJudgeCode: UnwrapRef<typeof import('../src/utils/tools')['alarmJudgeCode']>
|
||||
readonly apiHelper: UnwrapRef<typeof import('../src/utils/api-helper')['default']>
|
||||
readonly buildUrl: UnwrapRef<typeof import('../src/utils/api-helper')['buildUrl']>
|
||||
readonly computed: UnwrapRef<typeof import('vue')['computed']>
|
||||
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
|
||||
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
|
||||
@@ -189,7 +199,12 @@ declare module '@vue/runtime-core' {
|
||||
interface ComponentCustomProperties {
|
||||
readonly BASE_URL: UnwrapRef<typeof import('../src/utils/request')['BASE_URL']>
|
||||
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
|
||||
readonly ParamsBuilder: UnwrapRef<typeof import('../src/utils/api-helper')['ParamsBuilder']>
|
||||
readonly PathBuilder: UnwrapRef<typeof import('../src/utils/api-helper')['PathBuilder']>
|
||||
readonly ResponseAdapter: UnwrapRef<typeof import('../src/utils/api-helper')['ResponseAdapter']>
|
||||
readonly alarmJudgeCode: UnwrapRef<typeof import('../src/utils/tools')['alarmJudgeCode']>
|
||||
readonly apiHelper: UnwrapRef<typeof import('../src/utils/api-helper')['default']>
|
||||
readonly buildUrl: UnwrapRef<typeof import('../src/utils/api-helper')['buildUrl']>
|
||||
readonly computed: UnwrapRef<typeof import('vue')['computed']>
|
||||
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
|
||||
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
|
||||
|
||||
Reference in New Issue
Block a user