Commit e2bcb4f2 by 姜雷

添加预约前检查阈值

parent c04e761c
...@@ -123,7 +123,7 @@ export type AppointDeviceResponse = { ...@@ -123,7 +123,7 @@ export type AppointDeviceResponse = {
// allowEmptyValue: false // allowEmptyValue: false
// 设备位置 // 设备位置
operationMode: number; operationMode: OperationMode;
// allowEmptyValue: false // allowEmptyValue: false
// 设备计费模式 // 设备计费模式
}; };
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
getAppointmentDevice, getAppointmentDevice,
appointingEquipment, appointingEquipment,
ShowerUseType, ShowerUseType,
OperationMode,
} from '@/api/shower'; } from '@/api/shower';
import { useSelector } from '@tarojs/redux'; import { useSelector } from '@tarojs/redux';
import { Customer } from '@/types/Customer/Customer'; import { Customer } from '@/types/Customer/Customer';
...@@ -21,7 +22,8 @@ function ShowerAppointment() { ...@@ -21,7 +22,8 @@ function ShowerAppointment() {
(state: { userinfo: Customer }) => state.userinfo, (state: { userinfo: Customer }) => state.userinfo,
); );
const showerControlConfig = useSelector( const showerControlConfig = useSelector(
(state: { showerState: ShowerState }) => state.showerState, (state: { showerState: ShowerState }) =>
state.showerState.controllerConfigs,
); );
const [showState, setShowState] = useState(1); const [showState, setShowState] = useState(1);
const search = useInputValue(''); const search = useInputValue('');
...@@ -44,32 +46,44 @@ function ShowerAppointment() { ...@@ -44,32 +46,44 @@ function ShowerAppointment() {
const searchEquipment = () => { const searchEquipment = () => {
setSearchString(search.value); setSearchString(search.value);
}; };
const appointingStart = (deviceCode: string) => { const appointingStart = (deviceCode: string, operationMode: number) => {
// Taro.showModal({ const thresholdValue = showerControlConfig.thresholdValue;
// title: '', let aimiItem = showerControlConfig.balances.find(
// content: '', item => item.serviceId === '0',
// }).then(res => { );
// if(res.confirm){ let aimi = aimiItem ? aimiItem.amount : 0;
let beanItem = showerControlConfig.balances.find(
item => item.serviceId === '1',
);
let bean = beanItem ? beanItem.amount : 0;
let money = operationMode === OperationMode.onlyAimi ? aimi : aimi + bean;
// } if (money < thresholdValue) {
// }) let text = showerControlConfig.appointmentThresholdPrompt;
Taro.showModal({
appointingEquipment({ title: '提示',
account: userInfo.customerId.toString(), content: text,
phone: userInfo.customerPhone, }).then(res => {
userId: userInfo.customerId, if (res.confirm) {
userName: userInfo.customerName, appointingEquipment({
deviceCode: deviceCode, account: userInfo.customerId.toString(),
}) phone: userInfo.customerPhone,
.then(res => { userId: userInfo.customerId,
console.log(res); userName: userInfo.customerName,
Taro.showToast({ deviceCode: deviceCode,
title: res.msg, })
}); .then(res => {
}) console.log(res);
.catch(err => { Taro.showToast({
console.log(err); title: res.msg,
});
})
.catch(err => {
console.log(err);
});
}
}); });
}
}; };
const goBluetoothShower = () => { const goBluetoothShower = () => {
Taro.navigateTo({ Taro.navigateTo({
...@@ -93,9 +107,9 @@ function ShowerAppointment() { ...@@ -93,9 +107,9 @@ function ShowerAppointment() {
</Text> </Text>
</View> </View>
)} )}
{showState == 1 && showerControlConfig.controllerConfigs.balances.length && ( {showState == 1 && showerControlConfig.balances.length && (
<View className='ShowerAppointment-Account'> <View className='ShowerAppointment-Account'>
{showerControlConfig.controllerConfigs.balances.map(item => ( {showerControlConfig.balances.map(item => (
<View className='ShowerAppointment-Account-item'> <View className='ShowerAppointment-Account-item'>
<Text className='name'>{item.serviceName}</Text> <Text className='name'>{item.serviceName}</Text>
<Text>{item.amount.toFixed(2)}</Text> <Text>{item.amount.toFixed(2)}</Text>
...@@ -118,14 +132,13 @@ function ShowerAppointment() { ...@@ -118,14 +132,13 @@ function ShowerAppointment() {
))} ))}
</View> </View>
)} )}
{showState == 1 && {showState == 1 && showerControlConfig.useType === ShowerUseType.mix && (
showerControlConfig.controllerConfigs.useType === ShowerUseType.mix && ( <View
<View className='ShowerAppointment-ToggleBtn'
className='ShowerAppointment-ToggleBtn' onClick={goBluetoothShower}>
onClick={goBluetoothShower}> 自助洗浴
自助洗浴 </View>
</View> )}
)}
{showState == 2 && ( {showState == 2 && (
<ScrollView <ScrollView
className='ShowerAppointment-AppointmentList' className='ShowerAppointment-AppointmentList'
......
...@@ -5,12 +5,12 @@ import DisabledIcon from '@/images/shower/ic_jinyuyue@2x.png'; ...@@ -5,12 +5,12 @@ import DisabledIcon from '@/images/shower/ic_jinyuyue@2x.png';
type PageOwnProps = { type PageOwnProps = {
data: AppointDeviceResponse; data: AppointDeviceResponse;
appointingStart: (deviceCode: string) => void; appointingStart: (deviceCode: string, operationMode: number) => void;
}; };
const AppointermentEquipment = (props: PageOwnProps) => { const AppointermentEquipment = (props: PageOwnProps) => {
const { data, appointingStart } = props; const { data, appointingStart } = props;
const clickHandle = () => { const clickHandle = () => {
appointingStart && appointingStart(data.code); appointingStart && appointingStart(data.code, data.operationMode);
}; };
return ( return (
<View <View
......
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