|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import classnames from "classnames";
|
|
|
|
|
import { throttle } from "lodash";
|
|
|
|
|
import { Component, PropsWithChildren, useEffect, useState } from "react";
|
|
|
|
|
|
|
|
|
|
// import { InstrumentInfo } from "../../utils/Interface";
|
|
|
|
|
@ -16,7 +17,7 @@ import {
|
|
|
|
|
ScrollView,
|
|
|
|
|
Canvas,
|
|
|
|
|
} from "@tarojs/components";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { InstrumentInfo } from "@/utils/Interface";
|
|
|
|
|
import { go, msg, setStorageSync } from "@/utils/traoAPI";
|
|
|
|
|
|
|
|
|
|
@ -49,7 +50,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
serialImage: "",
|
|
|
|
|
serialCode: "",
|
|
|
|
|
},
|
|
|
|
|
show:true,
|
|
|
|
|
show: true,
|
|
|
|
|
equipmentList: [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
@ -66,6 +67,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
showLoginPopup: "",
|
|
|
|
|
fromUrl: "",
|
|
|
|
|
|
|
|
|
|
// 提示绑定与换绑
|
|
|
|
|
isVisibleBinding: false,
|
|
|
|
|
isRegisterBoolean: false,
|
|
|
|
|
isExchangeBinding: false,
|
|
|
|
|
@ -151,7 +153,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.scanCodeBinding();
|
|
|
|
|
}, 10);
|
|
|
|
|
}, 100);
|
|
|
|
|
},
|
|
|
|
|
fail(err) {},
|
|
|
|
|
complete(res) {},
|
|
|
|
|
@ -181,13 +183,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;
|
|
|
|
|
@ -244,8 +242,8 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
// 未绑定列表
|
|
|
|
|
unbindingInstrumentInfoList = async () => {
|
|
|
|
|
let { data } = await InstrumentInfo.unbindingInstrumentInfoList();
|
|
|
|
|
console.log(data,'查看未绑定设备');
|
|
|
|
|
|
|
|
|
|
console.log(data, "查看未绑定设备");
|
|
|
|
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
if (data.data.length) {
|
|
|
|
|
if (!this.isOnly) {
|
|
|
|
|
@ -294,14 +292,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) {
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
/**
|
|
|
|
|
@ -309,24 +314,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.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);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 调用绑定接口
|
|
|
|
|
@ -341,16 +359,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 {
|
|
|
|
|
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 () => {
|
|
|
|
|
@ -362,7 +388,6 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
let { data } = await InstrumentInfo.exchangeBinding({
|
|
|
|
|
serial: channelInfo.serialCode,
|
|
|
|
|
});
|
|
|
|
|
console.log("exchangeBinding", data);
|
|
|
|
|
Taro.hideLoading();
|
|
|
|
|
this.closeBinding();
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
@ -370,6 +395,10 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**绑定错误弹窗*/
|
|
|
|
|
onBindErrorOpen = () => {
|
|
|
|
|
this.setState({ isBindingError: true });
|
|
|
|
|
};
|
|
|
|
|
onBindErrorClose = () => {
|
|
|
|
|
this.setState({ isBindingError: false });
|
|
|
|
|
};
|
|
|
|
|
@ -377,6 +406,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 });
|
|
|
|
|
};
|
|
|
|
|
@ -384,10 +418,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" });
|
|
|
|
|
@ -661,7 +702,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>
|
|
|
|
|
)}
|
|
|
|
|
@ -676,7 +720,6 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
</View>
|
|
|
|
|
)}
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
</Block>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|