|
|
|
|
@ -18,7 +18,7 @@ import {
|
|
|
|
|
} from "@tarojs/components";
|
|
|
|
|
|
|
|
|
|
import { InstrumentInfo } from "@/utils/Interface";
|
|
|
|
|
import { go, msg, setStorageSync, getStorageSync } from "@/utils/traoAPI";
|
|
|
|
|
import { go, msg, setStorageSync } from "@/utils/traoAPI";
|
|
|
|
|
|
|
|
|
|
import { getImgInfo, contraction } from "@/utils/compressImage";
|
|
|
|
|
|
|
|
|
|
@ -26,6 +26,7 @@ import { getImgInfo, contraction } from "@/utils/compressImage";
|
|
|
|
|
import Navbar from "@/components/navbar/navbar";
|
|
|
|
|
import PopupAlert from "@/components/popup/popup-alert";
|
|
|
|
|
import PopupBinding from "@/components/popup/popup-binding";
|
|
|
|
|
import NoDataComponent from "@/components/base/nodata";
|
|
|
|
|
/* 组件 */
|
|
|
|
|
|
|
|
|
|
import "./instrument.less";
|
|
|
|
|
@ -66,6 +67,9 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
isVisibleBinding: false,
|
|
|
|
|
isRegisterBoolean: false,
|
|
|
|
|
isExchangeBinding: false,
|
|
|
|
|
|
|
|
|
|
/** INPUT序列号:拎出来,防止上传图片被清空bug */
|
|
|
|
|
serialCodeValue: "",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
$instance = Taro.getCurrentInstance();
|
|
|
|
|
@ -79,6 +83,13 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
componentWillUnmount() {}
|
|
|
|
|
|
|
|
|
|
componentDidShow() {
|
|
|
|
|
// 进入页面判断是否注册,用于扫码登录
|
|
|
|
|
let mobile = Taro.getStorageSync("mobile");
|
|
|
|
|
if (mobile) {
|
|
|
|
|
this.setState({ isRegisterBoolean: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用于判断是否只显示一个设备
|
|
|
|
|
let params: any = this.$instance.router?.params;
|
|
|
|
|
if (params?.isOnly && params?.id) {
|
|
|
|
|
if (params?.isOnly === "true") {
|
|
|
|
|
@ -96,10 +107,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
onSerial = (event) => {
|
|
|
|
|
const { value } = event.detail;
|
|
|
|
|
let { channelInfo } = this.state;
|
|
|
|
|
channelInfo.serialCode = value;
|
|
|
|
|
|
|
|
|
|
this.setState({ channelInfo });
|
|
|
|
|
this.setState({ serialCodeValue: value });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onTipShow = () => {
|
|
|
|
|
@ -170,16 +178,20 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
let compressImage = await contraction(img, "compressImage");
|
|
|
|
|
// 压缩后文件地址
|
|
|
|
|
let compressTempFilePath = compressImage.tempFilePath;
|
|
|
|
|
let { channelInfo } = this.state;
|
|
|
|
|
channelInfo.serialImage = compressTempFilePath;
|
|
|
|
|
this.setState({ channelInfo });
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
let { channelInfo } = this.state;
|
|
|
|
|
channelInfo.serialImage = compressTempFilePath;
|
|
|
|
|
this.setState({ channelInfo });
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onSubmit = () => {
|
|
|
|
|
const { serialCode, serialImage, id } = this.state.channelInfo;
|
|
|
|
|
if (!serialCode?.trim()) return msg("请填写序列号");
|
|
|
|
|
const { serialImage } = this.state.channelInfo;
|
|
|
|
|
|
|
|
|
|
if (!this.state.serialCodeValue?.trim()) return msg("请填写序列号");
|
|
|
|
|
if (!serialImage) return msg("请上传序列号照片");
|
|
|
|
|
this.manualCodeBinding();
|
|
|
|
|
};
|
|
|
|
|
@ -194,6 +206,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
this.setState({
|
|
|
|
|
channelInfo: channelInfo,
|
|
|
|
|
isVideo: this.isVideo(item.banner),
|
|
|
|
|
serialCodeValue: "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
@ -226,27 +239,34 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
if (data.data.length) {
|
|
|
|
|
if (!this.isOnly) {
|
|
|
|
|
let item = data.data[0];
|
|
|
|
|
let equipmentList = data.data.filter((item) => item.status === 0);
|
|
|
|
|
if (equipmentList.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let item = equipmentList[0];
|
|
|
|
|
item.serialCode = "";
|
|
|
|
|
this.setState({
|
|
|
|
|
equipmentList: data.data,
|
|
|
|
|
equipmentList: equipmentList,
|
|
|
|
|
channelInfo: item,
|
|
|
|
|
isVideo: this.isVideo(item.banner),
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
let item = data.data.find((item) => String(item.id) === this.id);
|
|
|
|
|
item.serialCode = "";
|
|
|
|
|
this.setState({
|
|
|
|
|
equipmentList: [item],
|
|
|
|
|
channelInfo: item,
|
|
|
|
|
isVideo: this.isVideo(item.banner),
|
|
|
|
|
});
|
|
|
|
|
if (item) {
|
|
|
|
|
item.serialCode = "";
|
|
|
|
|
this.setState({
|
|
|
|
|
equipmentList: [item],
|
|
|
|
|
channelInfo: item,
|
|
|
|
|
isVideo: this.isVideo(item.banner),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 绑定仪器
|
|
|
|
|
// 手写绑定仪器
|
|
|
|
|
manualCodeBinding = async () => {
|
|
|
|
|
Taro.showLoading({
|
|
|
|
|
title: "请求中...",
|
|
|
|
|
@ -255,12 +275,12 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
let { channelInfo } = this.state;
|
|
|
|
|
|
|
|
|
|
let res = await InstrumentInfo.manualCodeBinding({
|
|
|
|
|
serial: channelInfo.serialCode,
|
|
|
|
|
serial: this.state.serialCodeValue,
|
|
|
|
|
serialImage: channelInfo.serialImage,
|
|
|
|
|
instrumentId: channelInfo.id,
|
|
|
|
|
});
|
|
|
|
|
console.log("bindingInstrument", res);
|
|
|
|
|
Taro.hideLoading();
|
|
|
|
|
// 文件上传接口返回格式,不需要加data
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.openBindingVisible();
|
|
|
|
|
} else if (res.code === 204) {
|
|
|
|
|
@ -326,8 +346,8 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
console.log("exchangeBinding", data);
|
|
|
|
|
Taro.hideLoading();
|
|
|
|
|
this.closeBinding();
|
|
|
|
|
if (data.code !== 200) {
|
|
|
|
|
//todo
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
msg("换绑成功");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -377,6 +397,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
isVisibleBinding,
|
|
|
|
|
isRegisterBoolean,
|
|
|
|
|
isExchangeBinding,
|
|
|
|
|
serialCodeValue,
|
|
|
|
|
} = this.state;
|
|
|
|
|
return (
|
|
|
|
|
<Block>
|
|
|
|
|
@ -412,9 +433,8 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
content="序列号库仍在更新,请联系微信助手"
|
|
|
|
|
confirmButtonText="知道了"
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
isClose={false}
|
|
|
|
|
close={this.onBindErrorClose}
|
|
|
|
|
confirm={this.onBindErrorClose}
|
|
|
|
|
confirm={this.onBindErrorConfirm}
|
|
|
|
|
></PopupAlert>
|
|
|
|
|
<PopupAlert
|
|
|
|
|
isShow={isBindingCheckError}
|
|
|
|
|
@ -422,7 +442,6 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
content="您选择的仪器有误,请重新选择确认"
|
|
|
|
|
confirmButtonText="知道了"
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
isClose={false}
|
|
|
|
|
close={this.onBindCheckErrorClose}
|
|
|
|
|
confirm={this.onBindCheckErrorClose}
|
|
|
|
|
></PopupAlert>
|
|
|
|
|
@ -481,26 +500,35 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
style="width: 100%; white-space: nowrap;"
|
|
|
|
|
scrollIntoView={"scroll" + channelInfo.id}
|
|
|
|
|
>
|
|
|
|
|
{equipmentList.map((item, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<View
|
|
|
|
|
className={classnames("cover", {
|
|
|
|
|
active_cover: channelInfo.id === item.id,
|
|
|
|
|
})}
|
|
|
|
|
id={"scroll" + item.id}
|
|
|
|
|
key={index}
|
|
|
|
|
onClick={this.onSelectChange.bind(this, item)}
|
|
|
|
|
>
|
|
|
|
|
<Image
|
|
|
|
|
className="instrument_img"
|
|
|
|
|
src={item.banner}
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
// mode="aspectFit"
|
|
|
|
|
></Image>
|
|
|
|
|
<View className="desc">{item.name}</View>
|
|
|
|
|
{equipmentList.length > 0 &&
|
|
|
|
|
equipmentList.map((item, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<View
|
|
|
|
|
className={classnames("cover", {
|
|
|
|
|
active_cover: channelInfo.id === item.id,
|
|
|
|
|
})}
|
|
|
|
|
id={"scroll" + item.id}
|
|
|
|
|
key={index}
|
|
|
|
|
onClick={this.onSelectChange.bind(this, item)}
|
|
|
|
|
>
|
|
|
|
|
<Image
|
|
|
|
|
className="instrument_img"
|
|
|
|
|
src={item.banner}
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
// mode="aspectFit"
|
|
|
|
|
></Image>
|
|
|
|
|
<View className="desc">{item.name}</View>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
{equipmentList.length === 0 && (
|
|
|
|
|
<Block>
|
|
|
|
|
<View>
|
|
|
|
|
<NoDataComponent />
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Block>
|
|
|
|
|
)}
|
|
|
|
|
</ScrollView>
|
|
|
|
|
</View>
|
|
|
|
|
<View className="form_item is-tab">
|
|
|
|
|
@ -555,7 +583,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
placeholder="例如:FR10*********1"
|
|
|
|
|
placeholder-style={style}
|
|
|
|
|
onInput={this.onSerial}
|
|
|
|
|
value={channelInfo.serialCode}
|
|
|
|
|
value={serialCodeValue}
|
|
|
|
|
></Input>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
|