From 474dfe26375419cf85bc84833135015c1bb61a45 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Wed, 13 Mar 2024 16:42:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=86=85?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E7=BB=91=E5=AE=9A=E5=BC=B9=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + .../pages/iotCarePlan/iotCarePlan.tsx | 17 +-- src/pages/instrument/instrument.tsx | 119 ++++++++++++------ src/utils/request.js | 31 +++-- 4 files changed, 114 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index d08cd69..0cee936 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "build:qq": "taro build --type qq", "build:jd": "taro build --type jd", "build:quickapp": "taro build --type quickapp", + "dev": "npm run build:weapp -- --watch", "dev:weapp": "npm run build:weapp -- --watch", "dev:swan": "npm run build:swan -- --watch", "dev:alipay": "npm run build:alipay -- --watch", diff --git a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx index 7d27996..7437404 100644 --- a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx @@ -208,7 +208,7 @@ class IotCarePlan extends Component { // 按钮是否不可运行 isFooterBtnDisabled: true, - isFirstEntryMode: false, // 模式首次打开 + // isFirstEntryMode: false, // 模式首次打开 }; } @@ -1470,7 +1470,6 @@ class IotCarePlan extends Component { let recordModeItem = ModeList.find((item) => { return item.id == WL200NursingHistory.currentServiceData.modeId; }); - console.log("recordModeItem", recordModeItem); if (!WL200NursingHistory || !recordModeItem) { console.log("仪器有数据, 但是缓存没有数据, 忽略"); return; @@ -1542,6 +1541,11 @@ class IotCarePlan extends Component { /** 获取小程序本地缓存的历史记录 */ getWL200NursingHistory() { this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + // 同步历史记录 + if (this.state.isSyncHistory) { + // 同步历史记录 + this.setState({}); + } } /** 设置WL200护理历史 */ setWL200NursingHistory = (jsonStatus: any) => { @@ -1608,7 +1612,7 @@ class IotCarePlan extends Component { /** 提交护理记录 */ PostNursingLogClock = async (data: any = null, isJump = true) => { - let { currentDevice, ActiveModeItem, } = this.state; + let { currentDevice, ActiveModeItem } = this.state; let params = {}; if (data) { @@ -1632,8 +1636,8 @@ class IotCarePlan extends Component { }; // 上传护理完成的仪器ID let res = await InstrumentInfo.apiClock.addClockInstrument(params); - console.log(res,'护理完成'); - + console.log(res, "护理完成"); + this.rmWL200NursingHistory(this.WL200NursingHistory); // 护理完成,删除记录 if (isJump) { this.setState({ @@ -1976,7 +1980,6 @@ class IotCarePlan extends Component { nurseInfo, isShowReReadRecordSave, isFooterBtnDisabled, - isFirstEntryMode, } = this.state; return ( @@ -2041,7 +2044,7 @@ class IotCarePlan extends Component { { showLoginPopup: "", fromUrl: "", + // 提示绑定与换绑 isVisibleBinding: false, isRegisterBoolean: false, isExchangeBinding: false, @@ -150,7 +152,7 @@ export default class Instrument extends Component { setTimeout(() => { this.scanCodeBinding(); - }, 10); + }, 100); }, fail(err) {}, complete(res) {}, @@ -180,13 +182,9 @@ export default class Instrument extends Component { console.log("success", res); const tempFilePath = res.tempFiles[0].tempFilePath; let img = await getImgInfo(tempFilePath); - console.log("img", img); let compressImage = await contraction(img, "compressImage"); - console.log("compressImage", compressImage); // 压缩后文件地址 let compressTempFilePath = compressImage.tempFilePath; - console.log("tempFilePath", tempFilePath); - console.log("compressTempFilePath", compressTempFilePath); setTimeout(() => { let { channelInfo } = this.state; channelInfo.serialImage = compressTempFilePath; @@ -291,14 +289,21 @@ export default class Instrument extends Component { }); Taro.hideLoading(); // 文件上传接口返回格式,不需要加data - console.log("res.data", res); let code = Number(res.code); // 强制类型转换 if (code === 200) { - this.openBindingVisible(); - } else if (code === 204 || code === 205) { - this.setState({ isBindingCheckError: true }); - } else { - this.setState({ isBindingError: true }); + msg("绑定成功"); + setTimeout(() => { + setStorageSync("instrument_item", JSON.stringify(channelInfo)); + go("/pages/instrument/intro?id=" + channelInfo.id); + }, 1000); + } else if (res.data.code === 202) { + this.changeBindBox(); + } else if (res.data.code === 203) { + this.setState({ isBindingError203: true }); + } else if (res.data.code === 204) { + this.onBindCheckErrorOpen(); + } else if (res.data.code === 205 || res.data.code === 206) { + this.onBindErrorOpen(); } }; /** @@ -306,24 +311,37 @@ export default class Instrument extends Component { * @return code===204 用户选择的仪器与序列号对应的仪器不一致 */ scanCodeBinding = async () => { - Taro.showLoading({ - title: "请求中...", - mask: true, - }); + // Taro.showLoading({ + // title: "请求中...", + // mask: true, + // }); let { channelInfo } = this.state; let res = await InstrumentInfo.scanCodeBinding({ serial: channelInfo.serialCode, instrumentId: channelInfo.id, }); - Taro.hideLoading(); - if (res.data.code === 200) { - // this.bindingInstrument(); - this.openBindingVisible(); - } else if (res.data.code === 204 || res.data.code === 205) { - this.setState({ isBindingCheckError: true }); - } else { - this.setState({ isBindingError: true }); - } + + // Taro.hideLoading(); + let code = Number(res.data.code); + console.log("scanCodeBinding code", code); + setTimeout(() => { + console.log("scanCodeBinding code", code, code === 204); + if (code === 200) { + msg("绑定成功"); + setTimeout(() => { + setStorageSync("instrument_item", JSON.stringify(channelInfo)); + go("/pages/instrument/intro?id=" + channelInfo.id); + }, 1000); + } else if (res.data.code === 202) { + this.changeBindBox(); + } else if (res.data.code === 203) { + this.setState({ isBindingError203: true }); + } else if (res.data.code === 204) { + this.onBindCheckErrorOpen(); + } else if (res.data.code === 205 || res.data.code === 206) { + this.onBindErrorOpen(); + } + }, 100); }; // 调用绑定接口 @@ -338,18 +356,24 @@ export default class Instrument extends Component { serial: channelInfo.serialCode, }); Taro.hideLoading(); - if (res.data.code === 200) { - // this.setState({ isVisibleBinding: false }); - msg("绑定成功"); - setStorageSync("instrument_item", JSON.stringify(channelInfo)); - go("/pages/instrument/intro?id=" + channelInfo.id); - } else if (res.data.code === 204) { - this.setState({ isBindingCheckError: false }); - } else if (res.data.code === 203) { - this.setState({ isBindingError203: true }); - } else { - this.setState({ isBindingError: true }); - } + setTimeout(() => { + if (res.data.code === 200) { + // this.setState({ isVisibleBinding: false }); + msg("绑定成功"); + setStorageSync("instrument_item", JSON.stringify(channelInfo)); + setTimeout(() => { + go("/pages/instrument/intro?id=" + channelInfo.id); + }, 1000); + } else if (res.data.code === 202) { + this.changeBindBox(); + } else if (res.data.code === 203) { + this.setState({ isBindingError203: true }); + } else if (res.data.code === 204) { + this.onBindCheckErrorOpen(); + } else if (res.data.code === 205 || res.data.code === 206) { + this.onBindErrorOpen(); + } + }, 100); }; // 换绑仪器 exchangeBinding = async () => { @@ -369,6 +393,10 @@ export default class Instrument extends Component { } }; + /**绑定错误弹窗*/ + onBindErrorOpen = () => { + this.setState({ isBindingError: true }); + }; onBindErrorClose = () => { this.setState({ isBindingError: false }); }; @@ -376,6 +404,11 @@ export default class Instrument extends Component { this.onBindErrorClose(); go("/pages/consultant/consultant"); }; + + /**绑定错误:已被别人绑定弹窗*/ + onBindErrorOpen203 = () => { + this.setState({ isBindingError203: true }); + }; onBindErrorClose203 = () => { this.setState({ isBindingError203: false }); }; @@ -383,10 +416,17 @@ export default class Instrument extends Component { this.onBindErrorClose203(); go("/pages/consultant/consultant"); }; - + /**绑定错误:检查序列号弹窗*/ + onBindCheckErrorOpen = () => { + this.setState({ isBindingCheckError: true }); + }; onBindCheckErrorClose = () => { this.setState({ isBindingCheckError: false }); }; + /** 换绑弹窗 */ + changeBindBox() { + this.setState({ isVisibleBinding: true, isExchangeBinding: true }); + } customBack = () => { Taro.reLaunch({ url: "/pages/index/index" }); @@ -659,7 +699,10 @@ export default class Instrument extends Component { {inputType == 1 && ( - + 确认绑定 )} diff --git a/src/utils/request.js b/src/utils/request.js index db74ffe..888e69c 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -75,7 +75,7 @@ export const Ajax = (params) => { content: String(msg), showCancel: false, }); - // reject(res); + reject(res); return false; } @@ -108,6 +108,7 @@ export const Ajax = (params) => { }); }; +// 文件上传 export const AjaxUploadFile = (params, formData) => { const app = Taro.getApp(); const global = store.getState().globalStore; @@ -141,12 +142,14 @@ export const AjaxUploadFile = (params, formData) => { } if ( o.code !== 200 && + o.code !== 202 && o.code !== 203 && o.code !== 204 && - o.code !== 205 + o.code !== 205 && + o.code !== 206 ) { - let msg = - typeof o.msg == "string" ? o.msg : "系统异常,请联系管理人员"; + // let msg = typeof o.msg == "string" ? o.msg : "系统异常,请联系管理人员"; + let msg = "系统异常,请联系管理人员"; Taro.showModal({ title: "提示", content: msg, @@ -171,6 +174,7 @@ export const AjaxUploadFile = (params, formData) => { }); }; +// 表单上传 export const AjaxFormData = (params) => { const app = Taro.getApp(); const global = store.getState().globalStore; @@ -213,11 +217,20 @@ export const AjaxFormData = (params) => { }); return false; } - if (res.data.code !== 200 && o.code !== 204 && o.code !== 205) { - let msg = - typeof res.data.msg == "string" - ? res.data.msg - : "系统异常,请联系管理人员"; + let code = res.data.code; + if ( + code !== 200 && + code !== 202 && + code !== 203 && + code !== 204 && + code !== 205 && + code !== 206 + ) { + // let msg = + // typeof res.data.msg == "string" + // ? res.data.msg + // : "系统异常,请联系管理人员"; + let msg = "系统异常,请联系管理人员"; if (msg == "请不要操作太快哦") { reject(res); return false;