From b2f7f5fe1e75ea8be0cd879d748da8632c6d1ea6 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Mon, 12 Jan 2026 00:36:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=94=B9=E4=B8=BAjava,=E8=81=94=E8=B0=83=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- babel.config.js | 7 +- config/index.js | 37 +++++++ src/api/device.ts | 93 +++++++--------- src/api/home.ts | 26 +++-- src/api/login.ts | 20 ++-- src/api/msg.ts | 19 ++-- src/api/my.ts | 25 +++-- src/api/pond.ts | 16 +-- src/api/sub.ts | 13 ++- src/app.ts | 74 +++++++------ src/components/other/fish.vue | 4 +- src/home/addPond.vue | 29 ++++- src/home/updatePond.vue | 102 +++++++++++++---- src/my/addDetector.vue | 45 +++++++- src/pages/login/index.vue | 36 ++++-- src/pages/login/loginPhone.vue | 23 ++-- src/pages/main/home.vue | 23 ++-- src/pages/main/my.vue | 2 +- src/pages/msg/index.vue | 194 +++++++++++++++++++++------------ src/utils/request.ts | 6 +- types/auto-imports.d.ts | 15 +++ 21 files changed, 550 insertions(+), 259 deletions(-) diff --git a/babel.config.js b/babel.config.js index dc20faf..fcf6f0d 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,12 @@ module.exports = { presets: [ ['taro', { framework: 'vue3', - ts: true + ts: true, + targets: { + chrome: '60', + ios: '10', + android: '5' + } }] ] } diff --git a/config/index.js b/config/index.js index 3b14a1b..a6cafac 100644 --- a/config/index.js +++ b/config/index.js @@ -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', diff --git a/src/api/device.ts b/src/api/device.ts index 36681b5..fee626d 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -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}) } \ No newline at end of file diff --git a/src/api/home.ts b/src/api/home.ts index e4a15c0..872a48b 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -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()) } \ No newline at end of file diff --git a/src/api/login.ts b/src/api/login.ts index 293fca4..89344bf 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -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()) } \ No newline at end of file diff --git a/src/api/msg.ts b/src/api/msg.ts index 499f2d8..9085d33 100644 --- a/src/api/msg.ts +++ b/src/api/msg.ts @@ -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}) } \ No newline at end of file diff --git a/src/api/my.ts b/src/api/my.ts index 054e0f1..b6fc56a 100644 --- a/src/api/my.ts +++ b/src/api/my.ts @@ -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}) } \ No newline at end of file diff --git a/src/api/pond.ts b/src/api/pond.ts index 7c101e5..311567d 100644 --- a/src/api/pond.ts +++ b/src/api/pond.ts @@ -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}) } \ No newline at end of file diff --git a/src/api/sub.ts b/src/api/sub.ts index 71fe259..e519aeb 100644 --- a/src/api/sub.ts +++ b/src/api/sub.ts @@ -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()) } \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 26f37cc..da5b830 100644 --- a/src/app.ts +++ b/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 diff --git a/src/components/other/fish.vue b/src/components/other/fish.vue index 776c54e..a82db9e 100644 --- a/src/components/other/fish.vue +++ b/src/components/other/fish.vue @@ -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(); } }); diff --git a/src/home/addPond.vue b/src/home/addPond.vue index ab1c172..e0323a0 100644 --- a/src/home/addPond.vue +++ b/src/home/addPond.vue @@ -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); } diff --git a/src/home/updatePond.vue b/src/home/updatePond.vue index 9477c9d..a9542f9 100644 --- a/src/home/updatePond.vue +++ b/src/home/updatePond.vue @@ -236,7 +236,7 @@