Commit d6b5dfab by 姜雷

修改部分BUG

parent 41897cdc
......@@ -812,7 +812,7 @@ class Shower extends Component {
});
}
goAppointShower() {
Taro.navigateTo({
Taro.redirectTo({
url: '/pages/Shower/ShowerAppointment',
});
}
......
import './ShowerAppointment.scss';
import { View, Input, Text, Image, ScrollView } from '@tarojs/components';
import Taro, { useState, useReducer, useEffect } from '@tarojs/taro';
import { View, Input, Text, ScrollView } from '@tarojs/components';
import Taro, { useState } from '@tarojs/taro';
import AppointermentCard from './components/AppointermentCard/AppointermentCard';
import useInputValue from '@/hooks/useInputValue';
import {
getAppointmentDevice,
appointingEquipment,
ShowerUseType,
OperationMode,
......@@ -69,50 +68,68 @@ function ShowerAppointment() {
console.log(err);
});
};
const appointingStart = (deviceCode: string, operationMode: number) => {
const appointingStart = (
deviceCode: string,
operationMode: number,
location: string,
) => {
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;
if (money < thresholdValue) {
let i = 0;
let text = showerControlConfig.appointmentThresholdPrompt.replace(
/\{\}/g,
() => {
return i++ == 0 ? aimi.toFixed(2) : bean.toFixed(2);
},
if (showerControlConfig.balances.length) {
let aimiItem = showerControlConfig.balances.find(
item => item.serviceId === '0',
);
Taro.showModal({
title: '提示',
content: text,
}).then(res => {
if (res.confirm) {
appointingEquipmentHandle(deviceCode);
}
});
} else {
appointingEquipmentHandle(deviceCode);
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 i = 0;
let text = showerControlConfig.appointmentThresholdPrompt.replace(
/\{\}/g,
() => {
return i++ == 0 ? aimi.toFixed(2) : bean.toFixed(2);
},
);
Taro.showModal({
title: '提示',
content: text,
}).then(res => {
if (res.confirm) {
beforeStartCheckHandle(deviceCode, location);
}
});
return;
}
}
beforeStartCheckHandle(deviceCode, location);
};
const goBluetoothShower = () => {
Taro.navigateTo({
Taro.redirectTo({
url: '/pages/Shower/Shower',
});
};
const beforeStartCheckHandle = (deviceCode: string, location: string) => {
let minData = appointableData.duration / 60;
let hourData = appointableData.punishment / 3600;
Taro.showModal({
title: '提示',
content: `确认是否预约${deviceCode}(${location})预约后请在${minData}分钟内激活设备使用,否则将会在${hourData}小时内无法预约设备,`,
}).then(res => {
if (res.confirm) {
appointingEquipmentHandle(deviceCode);
}
});
};
return (
<View className='ShowerAppointment'>
{showState == 1 && (
<View className='ShowerAppointment-Searchbox'>
<Input
placeholder='请输入要选的设备位置'
placeholder='请输入要选的设备位置'
value={search.value}
onInput={e => search.onChange(e)}
/>
......
......@@ -29,10 +29,10 @@ const AppointermentCard = (props: PageOwnProps) => {
</View>
<View className='AppointermentCard-Time'>
<Text>预约失效时间:</Text>
<Text>2019-15-24 12:45:31</Text>
<Text>{data.expireTime ? data.expireTime : ''}</Text>
{/* <Text>{data.expireTime ? data.expireTime : ''}</Text> */}
</View>
{data.status === 5 && (
{(data.status === 5 || data.status === 8) && (
<Image className='AppointermentCard-Dis-Icon' src={DisabledIcon} />
)}
</View>
......
......@@ -5,12 +5,17 @@ import DisabledIcon from '@/images/shower/ic_jinyuyue@2x.png';
type PageOwnProps = {
data: AppointDeviceResponse;
appointingStart: (deviceCode: string, operationMode: number) => void;
appointingStart: (
deviceCode: string,
operationMode: number,
location: string,
) => void;
};
const AppointermentEquipment = (props: PageOwnProps) => {
const { data, appointingStart } = props;
const clickHandle = () => {
appointingStart && appointingStart(data.code, data.operationMode);
appointingStart &&
appointingStart(data.code, data.operationMode, data.location);
};
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