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

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

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

@ -85,14 +85,16 @@ export default class InstrumentDetail extends Component<any, any> {
</View> </View>
</View> </View>
<View className="box"> {info.bindingSerialImage && (
<View className="tip2"></View> <View className="box">
<Image <View className="tip2"></View>
className="serial_img" <Image
src={info.bindingSerialImage} className="serial_img"
mode="aspectFill" src={info.bindingSerialImage}
/> mode="aspectFill"
</View> />
</View>
)}
<View className="box"> <View className="box">
<View className="tip2"></View> <View className="tip2"></View>
@ -117,21 +119,6 @@ export default class InstrumentDetail extends Component<any, any> {
/> />
</View> </View>
</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> </View>
</Block> </Block>
); );

@ -208,6 +208,7 @@ class IotCarePlan extends Component<any, any> {
// 按钮是否可运行 // 按钮是否可运行
isFooterBtnDisabled: false, isFooterBtnDisabled: false,
isFirstEntryMode: false, // 模式首次打开
}; };
} }
@ -551,6 +552,7 @@ class IotCarePlan extends Component<any, any> {
// 如果检查通过,可运行,则执行下一步 // 如果检查通过,可运行,则执行下一步
if (!this.footerIsDisabled()) { if (!this.footerIsDisabled()) {
this.stepNext(); this.stepNext();
this.openStepTips(); // 仅在进入运行页的时候弹窗
return; 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) => { closeStepTips = (data) => {
if (data.isLocal) { if (data.isLocal) {
setStorageSync("isFirstEntry_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗 setStorageSync("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
} }
this.setState({ isShowStepTips: false }); this.setState({ isShowStepTips: false });
}; };
@ -1827,7 +1842,7 @@ class IotCarePlan extends Component<any, any> {
this.setState({ isFirstTipShow: true }); this.setState({ isFirstTipShow: true });
}; };
onTipShowClose = async () => { onTipShowClose = async () => {
setStorageSync("first_instrument_" + this.state.currentDevice.id, "true"); setStorageSync("first_instrument_" + this.state.currentDevice.id, true);
this.setState({ isFirstTipShow: false }); this.setState({ isFirstTipShow: false });
}; };
/** 初次护理信息弹窗 END */ /** 初次护理信息弹窗 END */
@ -1898,6 +1913,7 @@ class IotCarePlan extends Component<any, any> {
nurseInfo, nurseInfo,
isShowReReadRecordSave, isShowReReadRecordSave,
isFooterBtnDisabled, isFooterBtnDisabled,
isFirstEntryMode,
} = this.state; } = this.state;
return ( return (
@ -1955,7 +1971,7 @@ class IotCarePlan extends Component<any, any> {
<PopupStepTips <PopupStepTips
isShow={isShowStepTips} isShow={isShowStepTips}
isLarge isLarge
isFirstEntry isFirstEntry={isFirstEntryMode}
confirmButtonText="知道了" confirmButtonText="知道了"
data={ActiveModeItem.openSourceData} data={ActiveModeItem.openSourceData}
close={this.closeStepTips} close={this.closeStepTips}

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

Loading…
Cancel
Save