|
|
|
|
@ -64,6 +64,7 @@ class Index extends Component<any, any> {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
isDisabledClickAddDevice: false, // 是否禁止点击添加设备
|
|
|
|
|
isCommonError: false, // 是否显示通用错误提示
|
|
|
|
|
commonErrorText: [], // 通用错误提示
|
|
|
|
|
|
|
|
|
|
@ -103,7 +104,9 @@ class Index extends Component<any, any> {
|
|
|
|
|
/** 绑定仪器 */
|
|
|
|
|
isVisibleBinding: false, // 绑定弹窗
|
|
|
|
|
isBindingError: false, // 绑定失败
|
|
|
|
|
isBeforeBinding: false, // 已绑定弹窗
|
|
|
|
|
isBeforeBindingError: false, // 绑定前校验错误弹窗
|
|
|
|
|
BeforeBindingErrorText: "", // 绑定前校验错误文本
|
|
|
|
|
|
|
|
|
|
instrumentList: [], // 仪器列表
|
|
|
|
|
instrumentInfo: {
|
|
|
|
|
// 扫码获得的序列号仪器
|
|
|
|
|
@ -155,22 +158,27 @@ class Index extends Component<any, any> {
|
|
|
|
|
go("/pages/initiate/initiate");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 判断是否跳过了注册
|
|
|
|
|
if (Taro.getStorageSync("skipRegister")) {
|
|
|
|
|
this.setState({ showEquipment: true });
|
|
|
|
|
Taro.removeStorageSync("skipRegister");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {}
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
// 页面卸载监听
|
|
|
|
|
Taro.offAppHide((res) => {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidShow() {
|
|
|
|
|
const tabbar = Taro.getTabBar<CustomTabBar>(this.$instance.page);
|
|
|
|
|
tabbar?.setSelected(0);
|
|
|
|
|
|
|
|
|
|
this.showInit();
|
|
|
|
|
// 判断是否跳过了注册
|
|
|
|
|
if (Taro.getStorageSync("skipRegister")) {
|
|
|
|
|
this.setState({ showEquipment: true });
|
|
|
|
|
Taro.removeStorageSync("skipRegister");
|
|
|
|
|
} else {
|
|
|
|
|
// 已注册且非跳过,正常执行逻辑
|
|
|
|
|
this.showInit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidHide() {}
|
|
|
|
|
@ -182,10 +190,10 @@ class Index extends Component<any, any> {
|
|
|
|
|
this.setState({ isRegisterBoolean: true });
|
|
|
|
|
}
|
|
|
|
|
// 非扫码进入小程序,需判断是否跳转欢迎页;扫码进入小程序,先缓存序列号,再检测隐私弹窗
|
|
|
|
|
let serial = Taro.getStorageSync("serial");
|
|
|
|
|
let url = this.$instance.router?.params?.q || "";
|
|
|
|
|
if (!url) {
|
|
|
|
|
if (!url || serial) {
|
|
|
|
|
// 非扫码进入
|
|
|
|
|
Taro.setStorageSync("isScan", false);
|
|
|
|
|
const isFirst = Taro.getStorageSync("isWelcome");
|
|
|
|
|
if (isFirst) {
|
|
|
|
|
this.checkShowPrivacyPopup();
|
|
|
|
|
@ -200,10 +208,6 @@ class Index extends Component<any, any> {
|
|
|
|
|
if (ids.length > 1) {
|
|
|
|
|
let serial = ids[1];
|
|
|
|
|
Taro.setStorageSync("serial", serial);
|
|
|
|
|
if (!Taro.getStorageSync("mobile")) {
|
|
|
|
|
await this.onlyLogin();
|
|
|
|
|
go("/pages/register/register");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -244,12 +248,15 @@ class Index extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async initPageData() {
|
|
|
|
|
if (Taro.getStorageSync("serial")) {
|
|
|
|
|
go("/pages/register/register");
|
|
|
|
|
}
|
|
|
|
|
const mobile = Taro.getStorageSync("mobile");
|
|
|
|
|
this.GetSiteCarousel();
|
|
|
|
|
|
|
|
|
|
if (mobile) {
|
|
|
|
|
this.GetNoReadMessageNum(); // 查询是否有消息
|
|
|
|
|
await this.bindingInstrumentList(); // 获取已绑定设备
|
|
|
|
|
await this.unbindingInstrumentInfoList(); // 获取未绑定设备
|
|
|
|
|
await this.getInstrumentInfoBySerial(); // 扫码序列号查询:注册后才调用,因为扫码未注册直接跳转注册页
|
|
|
|
|
|
|
|
|
|
if (!this.props.isShowIndexFlag) {
|
|
|
|
|
@ -263,6 +270,7 @@ class Index extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.GetSiteCarousel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 刷新用户信息
|
|
|
|
|
@ -321,7 +329,10 @@ class Index extends Component<any, any> {
|
|
|
|
|
// 新增设备
|
|
|
|
|
addNewDevice = () => {
|
|
|
|
|
if (this.isRegister("addNewDevice")) {
|
|
|
|
|
// todo
|
|
|
|
|
if (this.state.isDisabledClickAddDevice) {
|
|
|
|
|
msg("您已绑定所有设备");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
go("/pages/instrument/instrument");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
@ -346,7 +357,7 @@ class Index extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
closePrivacy = () => {
|
|
|
|
|
this.setState({ isShowPrivacyPopup: false });
|
|
|
|
|
this.initData();
|
|
|
|
|
this.isSancQrcodeEnter(); // 关闭隐私弹窗后,需要判断是否扫码进入
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
closeAlert = () => {
|
|
|
|
|
@ -401,6 +412,24 @@ class Index extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 仪器与是否扫码进入逻辑 */
|
|
|
|
|
|
|
|
|
|
isVideo = (str) => {
|
|
|
|
|
if (str.includes(".mp4")) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
// 未绑定列表
|
|
|
|
|
unbindingInstrumentInfoList = async () => {
|
|
|
|
|
let { data } = await InstrumentInfo.unbindingInstrumentInfoList();
|
|
|
|
|
if (data.code === 200) {
|
|
|
|
|
if (data.data.length === 0) {
|
|
|
|
|
this.setState({
|
|
|
|
|
isDisabledClickAddDevice: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// 获取已绑定仪器列表
|
|
|
|
|
bindingInstrumentList = async () => {
|
|
|
|
|
Taro.showLoading({
|
|
|
|
|
@ -440,9 +469,14 @@ class Index extends Component<any, any> {
|
|
|
|
|
Taro.setStorageSync("mobile", data.data.mobile);
|
|
|
|
|
this.props.tokenRefresh(data.data);
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.initPageData();
|
|
|
|
|
}, 300);
|
|
|
|
|
// 如果是扫码进入,直接跳转到注册登录页.
|
|
|
|
|
if (Taro.getStorageSync("isScan")) {
|
|
|
|
|
go("/pages/register/register");
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.initPageData();
|
|
|
|
|
}, 300);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
msg("请求失败,尝试重新请求");
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
@ -505,10 +539,23 @@ class Index extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
// 0已绑定 1未绑定 2已解绑
|
|
|
|
|
if (instrumentInfo.bindingStatus === 0) {
|
|
|
|
|
// 选择仪器有误
|
|
|
|
|
this.setState({
|
|
|
|
|
isBeforeBinding: true,
|
|
|
|
|
});
|
|
|
|
|
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 ||
|
|
|
|
|
@ -608,11 +655,11 @@ class Index extends Component<any, any> {
|
|
|
|
|
go("/pages/consultant/consultant?customBack=true");
|
|
|
|
|
};
|
|
|
|
|
onBeforeBindClose = () => {
|
|
|
|
|
this.setState({ isBeforeBinding: false });
|
|
|
|
|
this.setState({ isBeforeBindingError: false });
|
|
|
|
|
this.removeScanFun();
|
|
|
|
|
};
|
|
|
|
|
onBeforeBindConfirm = () => {
|
|
|
|
|
this.setState({ isBeforeBinding: false });
|
|
|
|
|
this.setState({ isBeforeBindingError: false });
|
|
|
|
|
this.removeScanFun();
|
|
|
|
|
};
|
|
|
|
|
/**删除扫码缓存*/
|
|
|
|
|
@ -691,11 +738,15 @@ class Index extends Component<any, any> {
|
|
|
|
|
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
|
|
|
|
|
// return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 扫码绑定必须先完成注册弹窗:确定以后删除扫码缓存,防止死循环
|
|
|
|
|
onUnloginConfirm() {
|
|
|
|
|
this.setState({ showEquipment: false });
|
|
|
|
|
this.removeScanFun();
|
|
|
|
|
}
|
|
|
|
|
onUnloginClose() {
|
|
|
|
|
this.setState({ showEquipment: false });
|
|
|
|
|
this.removeScanFun();
|
|
|
|
|
}
|
|
|
|
|
//连接完成时数据的回调
|
|
|
|
|
offlineChange = async (e) => {
|
|
|
|
|
@ -835,7 +886,8 @@ class Index extends Component<any, any> {
|
|
|
|
|
// 绑定弹窗
|
|
|
|
|
isVisibleBinding,
|
|
|
|
|
isBindingError,
|
|
|
|
|
isBeforeBinding,
|
|
|
|
|
isBeforeBindingError,
|
|
|
|
|
BeforeBindingErrorText,
|
|
|
|
|
isRegisterBoolean,
|
|
|
|
|
isExchangeBinding,
|
|
|
|
|
instrumentInfo,
|
|
|
|
|
@ -954,9 +1006,11 @@ class Index extends Component<any, any> {
|
|
|
|
|
confirm={this.onBindErrorConfirm}
|
|
|
|
|
/>
|
|
|
|
|
<PopupAlert
|
|
|
|
|
isShow={isBeforeBinding}
|
|
|
|
|
isShow={isBeforeBindingError}
|
|
|
|
|
title="提示"
|
|
|
|
|
content="您选择的仪器有误,请重新确认选择"
|
|
|
|
|
content={
|
|
|
|
|
BeforeBindingErrorText || "您选择的仪器有误,请重新确认选择"
|
|
|
|
|
}
|
|
|
|
|
confirmButtonText="知道了"
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
close={this.onBeforeBindClose}
|
|
|
|
|
@ -981,11 +1035,6 @@ class Index extends Component<any, any> {
|
|
|
|
|
confirm={this.onUnloginConfirm.bind(this)}
|
|
|
|
|
></PopupAlert>
|
|
|
|
|
|
|
|
|
|
{/* <PopupPrivacyTest
|
|
|
|
|
closePrivacy={this.closePrivacy.bind(this)}
|
|
|
|
|
initData={this.initData.bind(this)}
|
|
|
|
|
></PopupPrivacyTest> */}
|
|
|
|
|
|
|
|
|
|
<PopupSiteSwiper
|
|
|
|
|
isShow={isShowSiteSwiper}
|
|
|
|
|
siteData={sitePopupList}
|
|
|
|
|
|