Commit 34a3c442 by 姜雷

Merge branch 'develop' into test

parents 90bbc848 9546f8ed
...@@ -71,3 +71,28 @@ export const fetchWaterEquipmentInfo = (params: { ...@@ -71,3 +71,28 @@ export const fetchWaterEquipmentInfo = (params: {
url: `/dcxy/api/gx/devices/${params.deviceCode}`, url: `/dcxy/api/gx/devices/${params.deviceCode}`,
data: params, 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 { ...@@ -14,6 +14,8 @@ import {
waterBeginning, waterBeginning,
fetchWaterEquipmentInfo, fetchWaterEquipmentInfo,
DeviceInfoResponse, DeviceInfoResponse,
fetchPageConfig,
PageConfigResponse,
} from '@/api/waterDispenser'; } from '@/api/waterDispenser';
import { Customer } from '@/types/Customer/Customer'; import { Customer } from '@/types/Customer/Customer';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
...@@ -33,6 +35,7 @@ type PageState = { ...@@ -33,6 +35,7 @@ type PageState = {
waterUsingState: boolean; waterUsingState: boolean;
useList: DeviceInfo[]; useList: DeviceInfo[];
timer: number | null; timer: number | null;
showToggleTag: boolean;
}; };
type IProps = PageStateProps; type IProps = PageStateProps;
...@@ -45,7 +48,7 @@ interface WaterDispenser { ...@@ -45,7 +48,7 @@ interface WaterDispenser {
userinfo, userinfo,
})) }))
class WaterDispenser extends Component { class WaterDispenser extends Component {
constructor(props) { constructor(props: IProps) {
super(props); super(props);
this.state = { this.state = {
waterUsingState: false, waterUsingState: false,
...@@ -55,17 +58,49 @@ class WaterDispenser extends Component { ...@@ -55,17 +58,49 @@ class WaterDispenser extends Component {
}, },
useList: [], useList: [],
timer: null, timer: null,
showToggleTag: false,
}; };
} }
componentWillMount() { componentWillMount() {
this.getUsedEquipment(); this.getUsedEquipment();
this.fetchPageConfig();
} }
componentWillUnmount() { componentWillUnmount() {
this.clearTimer(); 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() { clearTimer() {
const { timer } = this.state; const { timer } = this.state;
if (timer) { if (timer) {
...@@ -215,13 +250,16 @@ class WaterDispenser extends Component { ...@@ -215,13 +250,16 @@ class WaterDispenser extends Component {
waterUsingState, waterUsingState,
deviceInfo: { code, position }, deviceInfo: { code, position },
useList, useList,
showToggleTag,
} = this.state; } = this.state;
return ( return (
<View className='WaterDispenser'> <View className='WaterDispenser'>
<View className='WaterDispenser-tg' onClick={this.toggleCodeState}> {showToggleTag && (
<Image className='icon' src={CodeIcon} /> <View className='WaterDispenser-tg' onClick={this.toggleCodeState}>
<Text className='text'>显示条码</Text> <Image className='icon' src={CodeIcon} />
</View> <Text className='text'>显示条码</Text>
</View>
)}
<DeviceInfo size='small' code={code} position={position} /> <DeviceInfo size='small' code={code} position={position} />
<View className='btn-box'> <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