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

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

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

@ -208,7 +208,7 @@ class IotCarePlan extends Component<any, any> {
// 按钮是否不可运行
isFooterBtnDisabled: true,
isFirstEntryMode: false, // 模式首次打开
// isFirstEntryMode: false, // 模式首次打开
};
}
@ -1470,7 +1470,6 @@ class IotCarePlan extends Component<any, any> {
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<any, any> {
/** 获取小程序本地缓存的历史记录 */
getWL200NursingHistory() {
this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
// 同步历史记录
if (this.state.isSyncHistory) {
// 同步历史记录
this.setState({});
}
}
/** 设置WL200护理历史 */
setWL200NursingHistory = (jsonStatus: any) => {
@ -1608,7 +1612,7 @@ class IotCarePlan extends Component<any, any> {
/** 提交护理记录 */
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<any, any> {
};
// 上传护理完成的仪器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<any, any> {
nurseInfo,
isShowReReadRecordSave,
isFooterBtnDisabled,
isFirstEntryMode,
} = this.state;
return (
@ -2041,7 +2044,7 @@ class IotCarePlan extends Component<any, any> {
<PopupStepTips
isShow={isShowStepTips}
isLarge
isFirstEntry={isFirstEntryMode}
isFirstEntry={false}
confirmButtonText="知道了"
data={ActiveModeItem.openSourceData}
close={this.closeStepTips}

@ -1,4 +1,5 @@
import classnames from "classnames";
import { throttle } from "lodash";
import { Component, PropsWithChildren, useEffect, useState } from "react";
// import { InstrumentInfo } from "../../utils/Interface";
@ -65,6 +66,7 @@ export default class Instrument extends Component<any, any> {
showLoginPopup: "",
fromUrl: "",
// 提示绑定与换绑
isVisibleBinding: false,
isRegisterBoolean: false,
isExchangeBinding: false,
@ -150,7 +152,7 @@ export default class Instrument extends Component<any, any> {
setTimeout(() => {
this.scanCodeBinding();
}, 10);
}, 100);
},
fail(err) {},
complete(res) {},
@ -180,13 +182,9 @@ export default class Instrument extends Component<any, any> {
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<any, any> {
});
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<any, any> {
* @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<any, any> {
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<any, any> {
}
};
/**绑定错误弹窗*/
onBindErrorOpen = () => {
this.setState({ isBindingError: true });
};
onBindErrorClose = () => {
this.setState({ isBindingError: false });
};
@ -376,6 +404,11 @@ export default class Instrument extends Component<any, any> {
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<any, any> {
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<any, any> {
</View>
<View className="footer">
{inputType == 1 && (
<View className="btn" onClick={this.onSubmit}>
<View
className="btn"
onClick={throttle(this.onSubmit.bind(this), 1000)}
>
</View>
)}

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

Loading…
Cancel
Save