blak-kong 2 years ago
parent 75413856f7
commit 40e3c12e0a

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

@ -77,7 +77,9 @@ export default class Instrument extends Component<any, any> {
currentDevice: any = null;
id: any = "";
async onLoad() {}
async onLoad() {
this.unbindingInstrumentInfoList();
}
componentDidMount() {}
componentWillUnmount() {}
@ -98,7 +100,6 @@ export default class Instrument extends Component<any, any> {
}
}
console.log("params", params);
this.unbindingInstrumentInfoList();
}
componentDidHide() {}
@ -204,16 +205,13 @@ export default class Instrument extends Component<any, any> {
channelInfo.scanCodeBinding = "";
this.setState({
channelInfo: channelInfo,
channelInfo: {
...channelInfo,
...item,
},
isVideo: this.isVideo(item.banner),
serialCodeValue: "",
});
setTimeout(() => {
this.setState({
channelInfo: item,
});
}, 10);
}
closeDev = () => {
@ -266,7 +264,10 @@ export default class Instrument extends Component<any, any> {
}
};
// 手写绑定仪器
/**
* @name
* @return code===204
*/
manualCodeBinding = async () => {
Taro.showLoading({
title: "请求中...",
@ -281,14 +282,20 @@ export default class Instrument extends Component<any, any> {
});
Taro.hideLoading();
// 文件上传接口返回格式不需要加data
if (res.code === 200) {
console.log("res.data", res);
let code = Number(res.code); // 强制类型转换
if (code === 200) {
this.openBindingVisible();
} else if (res.code === 204) {
this.setState({ isBindingCheckError: false });
} else if (code === 204) {
this.setState({ isBindingCheckError: true });
} else {
this.setState({ isBindingError: true });
}
};
/**
* @name
* @return code===204
*/
scanCodeBinding = async () => {
Taro.showLoading({
title: "请求中...",
@ -303,7 +310,7 @@ export default class Instrument extends Component<any, any> {
if (res.data.code === 200) {
// this.bindingInstrument();
this.openBindingVisible();
} else if (res.data.code === 204) {
} else if (res.data.code === 204 || res.data.code === 205) {
this.setState({ isBindingCheckError: true });
} else {
this.setState({ isBindingError: true });
@ -499,6 +506,7 @@ export default class Instrument extends Component<any, any> {
className="instrument_list"
style="width: 100%; white-space: nowrap;"
scrollIntoView={"scroll" + channelInfo.id}
scrollIntoViewAlignment={"center"}
>
{equipmentList.length > 0 &&
equipmentList.map((item, index) => {
@ -515,7 +523,6 @@ export default class Instrument extends Component<any, any> {
className="instrument_img"
src={item.banner}
mode="aspectFill"
// mode="aspectFit"
></Image>
<View className="desc">{item.name}</View>
</View>

@ -85,14 +85,16 @@ export default class InstrumentDetail extends Component<any, any> {
</View>
</View>
<View className="box">
<View className="tip2"></View>
<Image
className="serial_img"
src={info.bindingSerialImage}
mode="aspectFill"
/>
</View>
{info.bindingSerialImage && (
<View className="box">
<View className="tip2"></View>
<Image
className="serial_img"
src={info.bindingSerialImage}
mode="aspectFill"
/>
</View>
)}
<View className="box">
<View className="tip2"></View>
@ -117,21 +119,6 @@ export default class InstrumentDetail extends Component<any, any> {
/>
</View>
</View>
{info.id == 74 ||
(info.id == 73 && (
<View className="box">
<View className="tip2"></View>
<View className="inputbox">
<Input
type="text"
disabled={true}
placeholder-style="color:#000000;font-size:28rpx;font-weight: 500;"
placeholder="花至FLOSSOM.V01.00.00.230316"
/>
</View>
</View>
))}
</View>
</Block>
);

@ -208,6 +208,7 @@ class IotCarePlan extends Component<any, any> {
// 按钮是否可运行
isFooterBtnDisabled: false,
isFirstEntryMode: false, // 模式首次打开
};
}
@ -551,6 +552,7 @@ class IotCarePlan extends Component<any, any> {
// 如果检查通过,可运行,则执行下一步
if (!this.footerIsDisabled()) {
this.stepNext();
this.openStepTips(); // 仅在进入运行页的时候弹窗
return;
}
// 如果检查失败,则报错
@ -592,9 +594,22 @@ class IotCarePlan extends Component<any, any> {
});
};
/**
* @name
*/
openStepTips = () => {
let isFirstEntryModeNot = getStorageSync(
"isFirstEntryMode_" + this.state.currentDevice.id
);
console.log("isFirstEntryModeNot", isFirstEntryModeNot);
// 如果没有持久化不再提示,每次进入都会弹窗提示
if (!isFirstEntryModeNot) {
this.setState({ isShowStepTips: true });
}
};
closeStepTips = (data) => {
if (data.isLocal) {
setStorageSync("isFirstEntry_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
setStorageSync("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
}
this.setState({ isShowStepTips: false });
};
@ -1827,7 +1842,7 @@ class IotCarePlan extends Component<any, any> {
this.setState({ isFirstTipShow: true });
};
onTipShowClose = async () => {
setStorageSync("first_instrument_" + this.state.currentDevice.id, "true");
setStorageSync("first_instrument_" + this.state.currentDevice.id, true);
this.setState({ isFirstTipShow: false });
};
/** 初次护理信息弹窗 END */
@ -1898,6 +1913,7 @@ class IotCarePlan extends Component<any, any> {
nurseInfo,
isShowReReadRecordSave,
isFooterBtnDisabled,
isFirstEntryMode,
} = this.state;
return (
@ -1955,7 +1971,7 @@ class IotCarePlan extends Component<any, any> {
<PopupStepTips
isShow={isShowStepTips}
isLarge
isFirstEntry
isFirstEntry={isFirstEntryMode}
confirmButtonText="知道了"
data={ActiveModeItem.openSourceData}
close={this.closeStepTips}

@ -58,9 +58,7 @@ class Register extends Component<any, any> {
skipRegister() {
// 跳过注册
Taro.setStorageSync("skipRegister", true);
Taro.navigateBack({
delta: 1,
});
Taro.switchTab({ url: "/pages/index/index" });
}
onDisagreeTap = () => {
// 关闭小程序

Loading…
Cancel
Save