fix:小程序内扫码绑定弹窗失效问题

master
blak-kong 2 years ago
parent 9d594fb0c2
commit 474dfe2637

@ -18,6 +18,7 @@
"build:qq": "taro build --type qq", "build:qq": "taro build --type qq",
"build:jd": "taro build --type jd", "build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp", "build:quickapp": "taro build --type quickapp",
"dev": "npm run build:weapp -- --watch",
"dev:weapp": "npm run build:weapp -- --watch", "dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch", "dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch", "dev:alipay": "npm run build:alipay -- --watch",

@ -208,7 +208,7 @@ class IotCarePlan extends Component<any, any> {
// 按钮是否不可运行 // 按钮是否不可运行
isFooterBtnDisabled: true, isFooterBtnDisabled: true,
isFirstEntryMode: false, // 模式首次打开 // isFirstEntryMode: false, // 模式首次打开
}; };
} }
@ -1470,7 +1470,6 @@ class IotCarePlan extends Component<any, any> {
let recordModeItem = ModeList.find((item) => { let recordModeItem = ModeList.find((item) => {
return item.id == WL200NursingHistory.currentServiceData.modeId; return item.id == WL200NursingHistory.currentServiceData.modeId;
}); });
console.log("recordModeItem", recordModeItem);
if (!WL200NursingHistory || !recordModeItem) { if (!WL200NursingHistory || !recordModeItem) {
console.log("仪器有数据, 但是缓存没有数据, 忽略"); console.log("仪器有数据, 但是缓存没有数据, 忽略");
return; return;
@ -1542,6 +1541,11 @@ class IotCarePlan extends Component<any, any> {
/** 获取小程序本地缓存的历史记录 */ /** 获取小程序本地缓存的历史记录 */
getWL200NursingHistory() { getWL200NursingHistory() {
this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
// 同步历史记录
if (this.state.isSyncHistory) {
// 同步历史记录
this.setState({});
}
} }
/** 设置WL200护理历史 */ /** 设置WL200护理历史 */
setWL200NursingHistory = (jsonStatus: any) => { setWL200NursingHistory = (jsonStatus: any) => {
@ -1608,7 +1612,7 @@ class IotCarePlan extends Component<any, any> {
/** 提交护理记录 */ /** 提交护理记录 */
PostNursingLogClock = async (data: any = null, isJump = true) => { PostNursingLogClock = async (data: any = null, isJump = true) => {
let { currentDevice, ActiveModeItem, } = this.state; let { currentDevice, ActiveModeItem } = this.state;
let params = {}; let params = {};
if (data) { if (data) {
@ -1632,7 +1636,7 @@ class IotCarePlan extends Component<any, any> {
}; };
// 上传护理完成的仪器ID // 上传护理完成的仪器ID
let res = await InstrumentInfo.apiClock.addClockInstrument(params); let res = await InstrumentInfo.apiClock.addClockInstrument(params);
console.log(res,'护理完成'); console.log(res, "护理完成");
this.rmWL200NursingHistory(this.WL200NursingHistory); // 护理完成,删除记录 this.rmWL200NursingHistory(this.WL200NursingHistory); // 护理完成,删除记录
if (isJump) { if (isJump) {
@ -1976,7 +1980,6 @@ class IotCarePlan extends Component<any, any> {
nurseInfo, nurseInfo,
isShowReReadRecordSave, isShowReReadRecordSave,
isFooterBtnDisabled, isFooterBtnDisabled,
isFirstEntryMode,
} = this.state; } = this.state;
return ( return (
@ -2041,7 +2044,7 @@ class IotCarePlan extends Component<any, any> {
<PopupStepTips <PopupStepTips
isShow={isShowStepTips} isShow={isShowStepTips}
isLarge isLarge
isFirstEntry={isFirstEntryMode} isFirstEntry={false}
confirmButtonText="知道了" confirmButtonText="知道了"
data={ActiveModeItem.openSourceData} data={ActiveModeItem.openSourceData}
close={this.closeStepTips} close={this.closeStepTips}

@ -1,4 +1,5 @@
import classnames from "classnames"; import classnames from "classnames";
import { throttle } from "lodash";
import { Component, PropsWithChildren, useEffect, useState } from "react"; import { Component, PropsWithChildren, useEffect, useState } from "react";
// import { InstrumentInfo } from "../../utils/Interface"; // import { InstrumentInfo } from "../../utils/Interface";
@ -65,6 +66,7 @@ export default class Instrument extends Component<any, any> {
showLoginPopup: "", showLoginPopup: "",
fromUrl: "", fromUrl: "",
// 提示绑定与换绑
isVisibleBinding: false, isVisibleBinding: false,
isRegisterBoolean: false, isRegisterBoolean: false,
isExchangeBinding: false, isExchangeBinding: false,
@ -150,7 +152,7 @@ export default class Instrument extends Component<any, any> {
setTimeout(() => { setTimeout(() => {
this.scanCodeBinding(); this.scanCodeBinding();
}, 10); }, 100);
}, },
fail(err) {}, fail(err) {},
complete(res) {}, complete(res) {},
@ -180,13 +182,9 @@ export default class Instrument extends Component<any, any> {
console.log("success", res); console.log("success", res);
const tempFilePath = res.tempFiles[0].tempFilePath; const tempFilePath = res.tempFiles[0].tempFilePath;
let img = await getImgInfo(tempFilePath); let img = await getImgInfo(tempFilePath);
console.log("img", img);
let compressImage = await contraction(img, "compressImage"); let compressImage = await contraction(img, "compressImage");
console.log("compressImage", compressImage);
// 压缩后文件地址 // 压缩后文件地址
let compressTempFilePath = compressImage.tempFilePath; let compressTempFilePath = compressImage.tempFilePath;
console.log("tempFilePath", tempFilePath);
console.log("compressTempFilePath", compressTempFilePath);
setTimeout(() => { setTimeout(() => {
let { channelInfo } = this.state; let { channelInfo } = this.state;
channelInfo.serialImage = compressTempFilePath; channelInfo.serialImage = compressTempFilePath;
@ -291,14 +289,21 @@ export default class Instrument extends Component<any, any> {
}); });
Taro.hideLoading(); Taro.hideLoading();
// 文件上传接口返回格式不需要加data // 文件上传接口返回格式不需要加data
console.log("res.data", res);
let code = Number(res.code); // 强制类型转换 let code = Number(res.code); // 强制类型转换
if (code === 200) { if (code === 200) {
this.openBindingVisible(); msg("绑定成功");
} else if (code === 204 || code === 205) { setTimeout(() => {
this.setState({ isBindingCheckError: true }); setStorageSync("instrument_item", JSON.stringify(channelInfo));
} else { go("/pages/instrument/intro?id=" + channelInfo.id);
this.setState({ isBindingError: true }); }, 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<any, any> {
* @return code===204 * @return code===204
*/ */
scanCodeBinding = async () => { scanCodeBinding = async () => {
Taro.showLoading({ // Taro.showLoading({
title: "请求中...", // title: "请求中...",
mask: true, // mask: true,
}); // });
let { channelInfo } = this.state; let { channelInfo } = this.state;
let res = await InstrumentInfo.scanCodeBinding({ let res = await InstrumentInfo.scanCodeBinding({
serial: channelInfo.serialCode, serial: channelInfo.serialCode,
instrumentId: channelInfo.id, instrumentId: channelInfo.id,
}); });
Taro.hideLoading();
if (res.data.code === 200) { // Taro.hideLoading();
// this.bindingInstrument(); let code = Number(res.data.code);
this.openBindingVisible(); console.log("scanCodeBinding code", code);
} else if (res.data.code === 204 || res.data.code === 205) { setTimeout(() => {
this.setState({ isBindingCheckError: true }); console.log("scanCodeBinding code", code, code === 204);
} else { if (code === 200) {
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();
} }
}, 100);
}; };
// 调用绑定接口 // 调用绑定接口
@ -338,18 +356,24 @@ export default class Instrument extends Component<any, any> {
serial: channelInfo.serialCode, serial: channelInfo.serialCode,
}); });
Taro.hideLoading(); Taro.hideLoading();
setTimeout(() => {
if (res.data.code === 200) { if (res.data.code === 200) {
// this.setState({ isVisibleBinding: false }); // this.setState({ isVisibleBinding: false });
msg("绑定成功"); msg("绑定成功");
setStorageSync("instrument_item", JSON.stringify(channelInfo)); setStorageSync("instrument_item", JSON.stringify(channelInfo));
setTimeout(() => {
go("/pages/instrument/intro?id=" + channelInfo.id); go("/pages/instrument/intro?id=" + channelInfo.id);
} else if (res.data.code === 204) { }, 1000);
this.setState({ isBindingCheckError: false }); } else if (res.data.code === 202) {
this.changeBindBox();
} else if (res.data.code === 203) { } else if (res.data.code === 203) {
this.setState({ isBindingError203: true }); this.setState({ isBindingError203: true });
} else { } else if (res.data.code === 204) {
this.setState({ isBindingError: true }); this.onBindCheckErrorOpen();
} else if (res.data.code === 205 || res.data.code === 206) {
this.onBindErrorOpen();
} }
}, 100);
}; };
// 换绑仪器 // 换绑仪器
exchangeBinding = async () => { exchangeBinding = async () => {
@ -369,6 +393,10 @@ export default class Instrument extends Component<any, any> {
} }
}; };
/**绑定错误弹窗*/
onBindErrorOpen = () => {
this.setState({ isBindingError: true });
};
onBindErrorClose = () => { onBindErrorClose = () => {
this.setState({ isBindingError: false }); this.setState({ isBindingError: false });
}; };
@ -376,6 +404,11 @@ export default class Instrument extends Component<any, any> {
this.onBindErrorClose(); this.onBindErrorClose();
go("/pages/consultant/consultant"); go("/pages/consultant/consultant");
}; };
/**绑定错误:已被别人绑定弹窗*/
onBindErrorOpen203 = () => {
this.setState({ isBindingError203: true });
};
onBindErrorClose203 = () => { onBindErrorClose203 = () => {
this.setState({ isBindingError203: false }); this.setState({ isBindingError203: false });
}; };
@ -383,10 +416,17 @@ export default class Instrument extends Component<any, any> {
this.onBindErrorClose203(); this.onBindErrorClose203();
go("/pages/consultant/consultant"); go("/pages/consultant/consultant");
}; };
/**绑定错误:检查序列号弹窗*/
onBindCheckErrorOpen = () => {
this.setState({ isBindingCheckError: true });
};
onBindCheckErrorClose = () => { onBindCheckErrorClose = () => {
this.setState({ isBindingCheckError: false }); this.setState({ isBindingCheckError: false });
}; };
/** 换绑弹窗 */
changeBindBox() {
this.setState({ isVisibleBinding: true, isExchangeBinding: true });
}
customBack = () => { customBack = () => {
Taro.reLaunch({ url: "/pages/index/index" }); Taro.reLaunch({ url: "/pages/index/index" });
@ -659,7 +699,10 @@ export default class Instrument extends Component<any, any> {
</View> </View>
<View className="footer"> <View className="footer">
{inputType == 1 && ( {inputType == 1 && (
<View className="btn" onClick={this.onSubmit}> <View
className="btn"
onClick={throttle(this.onSubmit.bind(this), 1000)}
>
</View> </View>
)} )}

@ -75,7 +75,7 @@ export const Ajax = (params) => {
content: String(msg), content: String(msg),
showCancel: false, showCancel: false,
}); });
// reject(res); reject(res);
return false; return false;
} }
@ -108,6 +108,7 @@ export const Ajax = (params) => {
}); });
}; };
// 文件上传
export const AjaxUploadFile = (params, formData) => { export const AjaxUploadFile = (params, formData) => {
const app = Taro.getApp(); const app = Taro.getApp();
const global = store.getState().globalStore; const global = store.getState().globalStore;
@ -141,12 +142,14 @@ export const AjaxUploadFile = (params, formData) => {
} }
if ( if (
o.code !== 200 && o.code !== 200 &&
o.code !== 202 &&
o.code !== 203 && o.code !== 203 &&
o.code !== 204 && o.code !== 204 &&
o.code !== 205 o.code !== 205 &&
o.code !== 206
) { ) {
let msg = // let msg = typeof o.msg == "string" ? o.msg : "系统异常,请联系管理人员";
typeof o.msg == "string" ? o.msg : "系统异常,请联系管理人员"; let msg = "系统异常,请联系管理人员";
Taro.showModal({ Taro.showModal({
title: "提示", title: "提示",
content: msg, content: msg,
@ -171,6 +174,7 @@ export const AjaxUploadFile = (params, formData) => {
}); });
}; };
// 表单上传
export const AjaxFormData = (params) => { export const AjaxFormData = (params) => {
const app = Taro.getApp(); const app = Taro.getApp();
const global = store.getState().globalStore; const global = store.getState().globalStore;
@ -213,11 +217,20 @@ export const AjaxFormData = (params) => {
}); });
return false; return false;
} }
if (res.data.code !== 200 && o.code !== 204 && o.code !== 205) { let code = res.data.code;
let msg = if (
typeof res.data.msg == "string" code !== 200 &&
? res.data.msg code !== 202 &&
: "系统异常,请联系管理人员"; code !== 203 &&
code !== 204 &&
code !== 205 &&
code !== 206
) {
// let msg =
// typeof res.data.msg == "string"
// ? res.data.msg
// : "系统异常,请联系管理人员";
let msg = "系统异常,请联系管理人员";
if (msg == "请不要操作太快哦") { if (msg == "请不要操作太快哦") {
reject(res); reject(res);
return false; return false;

Loading…
Cancel
Save