Commit e2bcb4f2 by 姜雷

添加预约前检查阈值

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