Commit 34a3c442 by 姜雷

Merge branch 'develop' into test

parents 90bbc848 9546f8ed
......@@ -71,3 +71,28 @@ export const fetchWaterEquipmentInfo = (params: {
url: `/dcxy/api/gx/devices/${params.deviceCode}`,
data: params,
});
enum DefualtMode {
code = 1,
scan = 2,
}
enum Mode {
code = 1,
scan = 2,
mix = 3,
}
export type PageConfigResponse = {
/** 校区id */
campusId: string;
/** 混合模式下的默认使用方式(1.条码,2扫码) */
defualtMode: DefualtMode;
/** 使用方式(1.条码,2扫码,3 混合) */
mode: Mode;
};
export const fetchPageConfig = (params: { campusId: number }) =>
gxFetch({
url: '/dcxy/api/gx/pageConfigs',
data: params,
});
......@@ -14,6 +14,8 @@ import {
waterBeginning,
fetchWaterEquipmentInfo,
DeviceInfoResponse,
fetchPageConfig,
PageConfigResponse,
} from '@/api/waterDispenser';
import { Customer } from '@/types/Customer/Customer';
import { connect } from '@tarojs/redux';
......@@ -33,6 +35,7 @@ type PageState = {
waterUsingState: boolean;
useList: DeviceInfo[];
timer: number | null;
showToggleTag: boolean;
};
type IProps = PageStateProps;
......@@ -45,7 +48,7 @@ interface WaterDispenser {
userinfo,
}))
class WaterDispenser extends Component {
constructor(props) {
constructor(props: IProps) {
super(props);
this.state = {
waterUsingState: false,
......@@ -55,17 +58,49 @@ class WaterDispenser extends Component {
},
useList: [],
timer: null,
showToggleTag: false,
};
}
componentWillMount() {
this.getUsedEquipment();
this.fetchPageConfig();
}
componentWillUnmount() {
this.clearTimer();
}
fetchPageConfig() {
const { userinfo } = this.props;
fetchPageConfig({
campusId: userinfo.areaId,
})
.then((res: ResponseDataEntity<PageConfigResponse>) => {
console.log(res);
const data = res.data;
if (data.mode === 3) {
if (data.defualtMode === 1) {
this.toggleCodeState();
} else {
this.setState({
showToggleTag: true,
});
}
} else if (data.mode === 2) {
this.setState({
showToggleTag: false,
});
} else if (data.mode === 1) {
Taro.redirectTo({
url: '/pages/BarCode/BarCode',
});
}
})
.catch(err => {
console.error(err);
});
}
clearTimer() {
const { timer } = this.state;
if (timer) {
......@@ -215,13 +250,16 @@ class WaterDispenser extends Component {
waterUsingState,
deviceInfo: { code, position },
useList,
showToggleTag,
} = this.state;
return (
<View className='WaterDispenser'>
{showToggleTag && (
<View className='WaterDispenser-tg' onClick={this.toggleCodeState}>
<Image className='icon' src={CodeIcon} />
<Text className='text'>显示条码</Text>
</View>
)}
<DeviceInfo size='small' code={code} position={position} />
<View className='btn-box'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment