Compare commits

...

2 Commits

Author SHA1 Message Date
tianyongbao
2e9609292e fix: 配置接口文件修改,bug修复。 2026-01-12 00:38:39 +08:00
tianyongbao
b2f7f5fe1e fix: 后端接口改为java,联调接口修改。 2026-01-12 00:36:05 +08:00
22 changed files with 1118 additions and 260 deletions

View File

@@ -4,7 +4,12 @@ module.exports = {
presets: [
['taro', {
framework: 'vue3',
ts: true
ts: true,
targets: {
chrome: '60',
ios: '10',
android: '5'
}
}]
]
}

View File

@@ -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',

568
src/api/config.ts Normal file
View File

@@ -0,0 +1,568 @@
/**
* 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: {
v1: '/resource/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: {
v1: '/fishery/pond/list',
v2: '/fishery/pond/list',
},
// 塘口列表模式2
POND_LIST_MODE2: {
v1: '/api/pond/list_mode2',
v2: '/fishery/pond/list/mode2',
},
// 公告列表
NOTICE_LIST: {
v1: '/api/sys-notice/notice_list',
v2: '/fishery/notice/list',
},
// 即将到期设备列表
DEVICE_DEAD: {
v1: '/api/device/list_device_dead',
v2: '/fishery/device/expiring',
},
// 获取设备票据
DEVICE_TICKET: {
v1: '/api/user-center/getsnticket',
v2: '/fishery/device/ticket',
},
},
// ==================== 鱼塘管理 ====================
POND: {
// 新增塘口
ADD: {
v1: '/fishery/pond',
v2: '/fishery/pond',
},
// 修改塘口
UPDATE: {
v1: '/api/pond/update',
v2: '/fishery/pond',
},
// 删除塘口
DELETE: {
v1: '/api/pond/delete',
v2: '/fishery/pond',
},
// 鱼类列表
FISH_LIST: {
v1: '/fishery/fish/list',
v2: '/fishery/fish/list',
},
// 塘口基本数据
BASE_INFO: {
v1: '/api/pond/base_info',
v2: '/fishery/pond',
},
// 塘口下设备信息
DEVICE_INFO: {
v1: '/api/pond/pond_device_info',
v2: '/fishery/pond/devices',
},
// 将设备及开关绑定到塘口
BIND_DEVICE: {
v1: '/api/pond/select_device_switch',
v2: '/fishery/pond/bind/device',
},
// 夜间防误触
KEEP_NIGHT_OPEN: {
v1: '/api/pond/keep_night_open',
v2: '/fishery/pond/night-protect',
},
},
// ==================== 设备管理 ====================
DEVICE: {
// 设备列表
LIST_ALL: {
v1: '/api/device/list_all_device',
v2: '/fishery/device/list',
},
// 设备详情
INFO: {
v1: '/api/device/one_device_info',
v2: '/fishery/device/info',
},
// 解除绑定
UNBIND: {
v1: '/api/device/break_pond',
v2: '/fishery/device/unbind',
},
// 设备图表数据
HISTORY: {
v1: '/api/device/data_history',
v2: '/fishery/device/history',
},
// 修改设备名称
UPDATE_NAME: {
v1: '/api/device/update_name',
v2: '/fishery/device/name',
},
// 修改设备关联塘口
UPDATE_POND: {
v1: '/api/device/update_pond',
v2: '/fishery/device/pond',
},
// 修改设备接电方式
UPDATE_VOLTAGE: {
v1: '/api/device/update_voltage_type',
v2: '/fishery/device/voltage',
},
// 删除设备
DELETE: {
v1: '/api/device/delete',
v2: '/fishery/device',
},
// 扫描设备编码
SCAN: {
v1: '/api/device/check_device_qrcode',
v2: '/fishery/device/scan',
},
// 检测设备是否在线
CHECK_STATUS: {
v1: '/api/device/check_device_status',
v2: '/iot/device/status',
},
// 盐度设置
SET_SALINITY: {
v1: '/api/device/detector_salinitycompensation',
v2: '/fishery/device/salinity',
},
// 设备校准
CALIBRATE: {
v1: '/api/device/detector_calibrate',
v2: '/fishery/device/calibrate',
},
// 添加水质检测仪
ADD_DETECTOR: {
v1: '/api/device/add_device_detector',
v2: '/iot/device/add_device_detector',
},
// 设置溶解氧/水温告警
SET_WARN_CALL: {
v1: '/api/device/set_oxy_warn_call',
v2: '/fishery/device/warn/call',
},
// 设置溶解氧上下限
SET_OXY_WARN: {
v1: '/api/device/set_oxy_warn_value',
v2: '/fishery/device/warn/oxy',
},
// 设置温度上下限
SET_TEMP_WARN: {
v1: '/api/device/set_temp_warn_value',
v2: '/fishery/device/warn/temp',
},
// 溶解氧饱和度
GET_SATURABILITY: {
v1: '/api/device/get_saturability',
v2: '/fishery/device/saturability',
},
// 添加控制一体机
ADD_CONTROLLER: {
v1: '/api/device/add_device_controller',
v2: '/fishery/device/controller',
},
// 启停溶解氧
SET_OXY_OPEN: {
v1: '/api/device/set_controller_oxy_open',
v2: '/fishery/device/oxy/switch',
},
// 电压告警开关
VOLTAGE_CHECK: {
v1: '/api/device/voltage_check_open',
v2: '/fishery/device/voltage/check',
},
},
// ==================== 联动控制 ====================
LINKED_CTRL: {
// 设备控制器列表
LIST: {
v1: '/api/linked-ctrl/fetch',
v2: '/fishery/linked-ctrl/list',
},
// 添加联动控制
ADD: {
v1: '/api/linked-ctrl/add',
v2: '/fishery/linked-ctrl',
},
// 修改联动控制
UPDATE: {
v1: '/api/linked-ctrl/update',
v2: '/fishery/linked-ctrl',
},
// 删除联动控制
DELETE: {
v1: '/api/linked-ctrl/delete',
v2: '/fishery/linked-ctrl',
},
// 设置联动控制上下限开关
SET_OPEN: {
v1: '/api/linked-ctrl/set_open',
v2: '/fishery/linked-ctrl/switch',
},
},
// ==================== 开关管理 ====================
SWITCH: {
// 开关列表
POND_LIST: {
v1: '/api/device-switch/get_pond_switch',
v2: '/fishery/switch/list',
},
// 开关详情
INFO: {
v1: '/api/device-switch/one_switch_info',
v2: '/fishery/switch/info',
},
// 修改开关名称
UPDATE_NAME: {
v1: '/api/device-switch/update_name',
v2: '/fishery/switch/name',
},
// 修改关联塘口
UPDATE_POND: {
v1: '/api/device-switch/update_pond',
v2: '/fishery/switch/pond',
},
// 修改接线方式
UPDATE_VOLTAGE: {
v1: '/api/device-switch/update_voltage_type',
v2: '/fishery/switch/voltage',
},
// 单个开关启停
TURN: {
v1: '/api/device-switch/turn_switch',
v2: '/fishery/switch/turn',
},
// 所有开关启停
TURN_POND: {
v1: '/api/device-switch/turn_pond_switch',
v2: '/fishery/switch/turn/all',
},
// 电流告警开关
ELECTRIC_CHECK: {
v1: '/api/device-switch/electric_check_open',
v2: '/fishery/switch/electric/check',
},
// 电流告警设置
ELECTRIC_SET: {
v1: '/api/device-switch/electric_set',
v2: '/fishery/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: {
v1: '/api/message/page_pay',
v2: '/fishery/payOrder/list',
},
// 报警记录
WARN: {
v1: '/api/message/page_warn',
v2: '/fishery/messageWarn/list',
},
// 开关记录
SWITCH: {
v1: '/api/message/page_op_record',
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

View File

@@ -1,176 +1,167 @@
import httpService from '@/utils/request'
import {useRootUserStore} from '@/store/index';
import API from './config'
/** 设备相关接口---------------------------------------- */
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})
return httpService.post(API.DEVICE.INFO(), {data})
}
// 解除绑定
export function deviceUnbind(data){
return httpService.post(`/api/device/break_pond?rootuserid=${store.getRootUserId}`,{data})
return httpService.post(API.DEVICE.UNBIND(), {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})
return httpService.post(API.DEVICE.HISTORY(), {data})
}
// 修改设备名称
export function deviceUpdateName(data){
return httpService.put(`/api/device/update_name?rootuserid=${store.getRootUserId}`,{data})
return httpService.put(API.DEVICE.UPDATE_NAME(), {data})
}
// 修改设备关联塘口
export function deviceUpdatePond(data){
return httpService.put(`/api/device/update_pond?rootuserid=${store.getRootUserId}`,{data})
return httpService.put(API.DEVICE.UPDATE_POND(), {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})
return httpService.delete(API.DEVICE.DELETE(), {data})
}
// 扫描设备编码
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})
return httpService.post(API.DEVICE.SET_WARN_CALL(), {data})
}
// 设置溶解氧上下限
export function setOxyWarn(data){
return httpService.put(`/api/device/set_oxy_warn_value?rootuserid=${store.getRootUserId}`,{data})
return httpService.put(API.DEVICE.SET_OXY_WARN(), {data})
}
// 设置温度上下限
export function setTempWarn(data){
return httpService.put(`/api/device/set_temp_warn_value?rootuserid=${store.getRootUserId}`,{data})
return httpService.put(API.DEVICE.SET_TEMP_WARN(), {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})
return httpService.put(API.DEVICE.SET_OXY_OPEN(), {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})
return httpService.delete(API.LINKED_CTRL.DELETE(), {data})
}
// 设置联动控制上下限开关
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})
return httpService.put(API.DEVICE.VOLTAGE_CHECK(), {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})
}

View File

@@ -1,23 +1,35 @@
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 userKeyword = Taro.getStorageSync('Phone');
const queryParams = {
params: {
userKeyword: userKeyword || undefined
}
};
return httpService.get(API.HOME.POND_LIST(), { params: queryParams });
}
// 塘口模式2
export function getPond2(){
return httpService.get(`/api/pond/list_mode2?rootuserid=${store.getRootUserId}`)
return httpService.get(API.HOME.POND_LIST_MODE2())
}
// 公告列表
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}`)
return httpService.get(API.HOME.DEVICE_DEAD())
}
// 获取设备票据
export function getDeviceTicket(){
return httpService.get(`/api/user-center/getsnticket`)
return httpService.get(API.HOME.DEVICE_TICKET())
}

View File

@@ -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())
}

View File

@@ -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})
}

View File

@@ -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})
}

View File

@@ -1,27 +1,27 @@
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})
return httpService.post(API.POND.DEVICE_INFO(), {data})
}

View File

@@ -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())
}

View File

@@ -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

View File

@@ -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();
}
});

View File

@@ -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);
}

View File

@@ -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;
}
@@ -421,7 +481,7 @@ function getDeviceList() {
// 设备列表
function getDevicesList() {
allDeviceList({ type: 1 }).then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
res.data.forEach((r: any) => {
r.open = true;
r.disabled = false;
@@ -516,7 +576,7 @@ function onconfirm(list) {
};
bandDeviceToPond(data)
.then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "绑定成功";
getDeviceList();
@@ -549,7 +609,7 @@ function delPond() {
d_isLoading.value = true;
PondDel({ id })
.then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "删除成功";
// 返回首页

View File

@@ -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,
});

View File

@@ -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;
}
}
/** 查看用户协议 */

View File

@@ -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

View File

@@ -858,7 +858,7 @@ function resUsetInfo() {
function getWarnMsg() {
const warnParams = ref({
pageSize: 10,
curPage: 1,
pageNum: 1,
});
msgWarn(warnParams.value).then((res: any) => {
if (res.statusCode == 200) {
@@ -922,14 +922,15 @@ function changeMode() {
// 塘口模式1
function pond1() {
getPond1().then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
const pondIds = [];
res.data.forEach((item: any) => {
const rows = res.rows || [];
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 +951,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;
}
}
}

View File

@@ -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) {

View File

@@ -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();
}
});

View File

@@ -8,7 +8,7 @@ const timeOutSeconds = 10000;
const getBaseUrl = () => {
let BASE_URL = ''
if (process.env.TARO_ENV === 'h5') {
BASE_URL = '/api' //填写你的请求域名
BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
} else {
BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名
// BASE_URL = 'https://dev.yuceyun.cn' //测试环境
@@ -75,6 +75,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"]) {

View File

@@ -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']>