|
|
|
|
@ -175,15 +175,20 @@ class Index extends Component<any, any> {
|
|
|
|
|
componentDidShow() {
|
|
|
|
|
const tabbar = Taro.getTabBar<CustomTabBar>(this.$instance.page);
|
|
|
|
|
tabbar?.setSelected(0);
|
|
|
|
|
|
|
|
|
|
// 判断是否跳过了注册
|
|
|
|
|
if (Taro.getStorageSync("skipRegister")) {
|
|
|
|
|
this.setState({ showEquipment: true });
|
|
|
|
|
Taro.removeStorageSync("skipRegister");
|
|
|
|
|
} else {
|
|
|
|
|
// 已注册且非跳过,正常执行逻辑
|
|
|
|
|
this.showInit();
|
|
|
|
|
console.log(this.state.instrumentInfo, '查看', this.state.instrumentList, Taro.getStorageSync("skipRegister"));
|
|
|
|
|
const handleAsyncLogic = async () => {
|
|
|
|
|
// 判断是否跳过了注册
|
|
|
|
|
if (Taro.getStorageSync("skipRegister")) {
|
|
|
|
|
await this.EquipmentNo(); // 扫码序列号查询:注册后才调用,因为扫码未注册直接跳转注册页
|
|
|
|
|
this.setState({ showEquipment: true });
|
|
|
|
|
Taro.removeStorageSync("skipRegister");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// 已注册且非跳过,正常执行逻辑
|
|
|
|
|
this.showInit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
handleAsyncLogic()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidHide() {
|
|
|
|
|
@ -211,6 +216,7 @@ class Index extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
// 非扫码进入小程序,需判断是否跳转欢迎页;扫码进入小程序,先缓存序列号,再检测隐私弹窗
|
|
|
|
|
let serial = Taro.getStorageSync("serial");
|
|
|
|
|
console.log(this.$instance, '2222', serial);
|
|
|
|
|
let url = this.$instance.router?.params?.q || "";
|
|
|
|
|
if (!url) {
|
|
|
|
|
// 非扫码或扫码已跳转的返回进入
|
|
|
|
|
@ -225,7 +231,10 @@ class Index extends Component<any, any> {
|
|
|
|
|
// 是否可以运行扫码逻辑:每次扫码后设为真,
|
|
|
|
|
Taro.setStorageSync("isScanRun", true);
|
|
|
|
|
if (url) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let _url = decodeURIComponent(url);
|
|
|
|
|
|
|
|
|
|
if (_url.indexOf("?")) {
|
|
|
|
|
let ids = _url.split("?");
|
|
|
|
|
if (ids.length > 1) {
|
|
|
|
|
@ -260,6 +269,7 @@ class Index extends Component<any, any> {
|
|
|
|
|
// 页面初始化
|
|
|
|
|
initData = async () => {
|
|
|
|
|
let token = getStorageSync("token");
|
|
|
|
|
|
|
|
|
|
if (!token) {
|
|
|
|
|
// 如果token过期,先登录,登录完成后自动初始化
|
|
|
|
|
await this.WCUserLogin();
|
|
|
|
|
@ -268,7 +278,60 @@ class Index extends Component<any, any> {
|
|
|
|
|
this.initPageData();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// 查看设备序号与仪器
|
|
|
|
|
EquipmentNo = async () => {
|
|
|
|
|
let serial = Taro.getStorageSync("serial"); // 扫码可能跳转注册页,所以先缓存
|
|
|
|
|
|
|
|
|
|
let { data } = await InstrumentInfo.getInstrumentInfoBySerial({
|
|
|
|
|
serial: serial,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
let instrumentInfo = data.data;
|
|
|
|
|
// 更新扫码进入仪器信息
|
|
|
|
|
this.setState({ instrumentInfo: instrumentInfo });
|
|
|
|
|
|
|
|
|
|
// 1有效 0无效
|
|
|
|
|
// if (instrumentInfo.validStatus === 0) {
|
|
|
|
|
// this.setState({ isBindingError: true });
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// // 0已绑定 1未绑定 2已解绑
|
|
|
|
|
// if (instrumentInfo.bindingStatus === 0) {
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// this.isBindingSerial();
|
|
|
|
|
// }, 100);
|
|
|
|
|
// let isBind = this.state.instrumentList.find(
|
|
|
|
|
// (item) => item.id === instrumentInfo.id
|
|
|
|
|
// );
|
|
|
|
|
// if (isBind) {
|
|
|
|
|
// this.setState({
|
|
|
|
|
// isBeforeBindingError: true,
|
|
|
|
|
// BeforeBindingErrorText: "序列号已绑定",
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// this.setState({
|
|
|
|
|
// isBeforeBindingError: true,
|
|
|
|
|
// BeforeBindingErrorText: "序列号已被其他用户绑定",
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
// } else if (
|
|
|
|
|
// instrumentInfo.bindingStatus === 1 ||
|
|
|
|
|
// instrumentInfo.bindingStatus === 2
|
|
|
|
|
// ) {
|
|
|
|
|
// // 判断是否已绑定同名仪器,如果已绑定,判断序列号是否一致
|
|
|
|
|
// // 如果自己已绑定,判断扫码序列号和已绑定序列号是否一致,如果一致:忽略
|
|
|
|
|
// // 如果自己已绑定,判断扫码序列号和已绑定序列号是否一致,如果不一致:提示换绑
|
|
|
|
|
// // 以上逻辑交给后端处理,直接查询是否绑定或换绑
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// this.isBindingSerial();
|
|
|
|
|
// }, 100);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
// this.removeScanFun();
|
|
|
|
|
}
|
|
|
|
|
initPageData = async () => {
|
|
|
|
|
const mobile = Taro.getStorageSync("mobile");
|
|
|
|
|
const isToken = getStorageSync("token");
|
|
|
|
|
@ -276,11 +339,15 @@ class Index extends Component<any, any> {
|
|
|
|
|
// 防止逻辑出错没有token
|
|
|
|
|
await this.onlyLogin();
|
|
|
|
|
}
|
|
|
|
|
console.log("initPageData");
|
|
|
|
|
console.log("initPageData", Taro.getStorageSync("serial"));
|
|
|
|
|
// 如果是扫码且已有token则跳转
|
|
|
|
|
if (Taro.getStorageSync("serial")) {
|
|
|
|
|
console.log(mobile, 'mobile');
|
|
|
|
|
|
|
|
|
|
// 如果已注册绑定手机号不用跳转
|
|
|
|
|
if (!mobile) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
go("/pages/register/register");
|
|
|
|
|
}, 300);
|
|
|
|
|
@ -584,6 +651,7 @@ class Index extends Component<any, any> {
|
|
|
|
|
};
|
|
|
|
|
// 根据扫码的序列号获取仪器信息
|
|
|
|
|
getInstrumentInfoBySerial = async () => {
|
|
|
|
|
|
|
|
|
|
let url = this.$instance.router?.params?.q || "";
|
|
|
|
|
let isScan = Taro.getStorageSync("isScan"); // 判断是否扫码进入
|
|
|
|
|
let serial = Taro.getStorageSync("serial"); // 扫码可能跳转注册页,所以先缓存
|
|
|
|
|
@ -591,6 +659,8 @@ class Index extends Component<any, any> {
|
|
|
|
|
let { data } = await InstrumentInfo.getInstrumentInfoBySerial({
|
|
|
|
|
serial: serial,
|
|
|
|
|
});
|
|
|
|
|
console.log(data, '查看赋值');
|
|
|
|
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
let instrumentInfo = data.data;
|
|
|
|
|
// 更新扫码进入仪器信息
|
|
|
|
|
|