Commit d6b5dfab by 姜雷

修改部分BUG

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