Commit 155d8039 by 姜雷

进入服务前添加订单查询

parent 3f88493f
...@@ -99,4 +99,17 @@ button[disabled]:not([type]) { ...@@ -99,4 +99,17 @@ button[disabled]:not([type]) {
height: 100%; height: 100%;
background-color: rgba(25, 25, 25, 0.2); background-color: rgba(25, 25, 25, 0.2);
z-index: 99; z-index: 99;
} }
\ No newline at end of file .blur {
filter: blur(10px);
}
.OrderBox {
box-sizing: border-box;
position: absolute;
top: 0;
width: 100%;
height: 100%;
padding: 0 32px;
z-index: 100;
background-color: rgba(255, 255, 255, 0.5);
}
import { fetchPayOrder, fetchOrderDetailAndPay } from '@/api/order';
import { View } from '@tarojs/components';
import { connect } from '@tarojs/redux';
import { ComponentClass } from 'react';
function wrapCheckOrder() {
return function wrapComponent(
Component: ComponentClass<T>,
): ComponentClass<T> {
return class CheckOrder extends Component {
constructor(props) {
super(props);
this.state = {
showPayOrder: false,
accounts: [],
orderInfo: {
actualMoney: 0,
areaId: 0,
areaName: '',
consumeType: '',
createAt: '',
customerCellphone: '',
customerId: 0,
customerName: '',
deductionBean: 0,
deductionMoney: 0,
equipmentNum: '',
equipmentPosition: '',
id: 0,
operateId: 0,
operateName: '',
operationMode: '',
orderName: '',
orderNumber: '',
orderState: '',
outTradeNo: '',
payType: '',
payableMoney: 0,
serviceId: 0,
serviceName: '',
thirdDiscountMoney: 0,
thirdTradeNumber: '',
updateDate: '',
},
payInfos: {
paymentAndActiveInfos: [],
paymentConfId: 0,
},
};
}
componentWillMount() {
this.getPayState();
if (super.componentWillMount) {
super.componentWillMount();
}
}
getPayState() {
const { userinfo } = this.props;
fetchPayOrder({
customerId: userinfo.customerId,
})
.then(res => {
if (res.data.length) {
this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true });
} else {
this.drawBarCode();
}
})
.catch(err => {
console.log(err);
});
}
fetchOrder(id: number) {
return fetchOrderDetailAndPay({
id,
})
.then(res => {
const { accounts, orderInfo, payInfos } = res;
this.setState({
accounts: accounts,
orderInfo: orderInfo,
payInfos: payInfos,
});
})
.catch(err => {
console.log(err);
});
}
render() {
const { showPayOrder, orderInfo, payInfos, accounts } = this.state;
console.log(showPayOrder);
return (
<View className=''>
{showPayOrder ? (
<View className='OrderBox'>
<OrderTitle price={orderInfo.payableMoney} />
<OrderInfo orderInfo={orderInfo} />
<OrderPayway
onPayDoneCallback={this.payDoneHandle}
userinfo={userinfo}
accounts={accounts}
orderInfo={orderInfo}
payInfos={payInfos}
/>
</View>
) : (
super.render()
)}
</View>
);
}
};
};
}
export default wrapCheckOrder;
...@@ -27,18 +27,6 @@ page { ...@@ -27,18 +27,6 @@ page {
color: #fff; color: #fff;
} }
} }
.OrderBox {
box-sizing: border-box;
position: absolute;
width: 100%;
height: 100%;
padding: 0 32px;
z-index: 100;
background-color: rgba(255, 255, 255, 0.5);
}
.blur {
filter: blur(10px);
}
.BarCodeBox { .BarCodeBox {
position: relative; position: relative;
background-color: #fff; background-color: #fff;
......
...@@ -279,13 +279,6 @@ class BarCode extends Component { ...@@ -279,13 +279,6 @@ class BarCode extends Component {
} = this.state; } = this.state;
return ( return (
<View className='BarCode'> <View className='BarCode'>
{showBackTag && (
<View className='BackTag' onClick={this.goBackPage}>
<Image className='icon' src={CodeIcon} />
<Text className='text'>隐藏条码</Text>
</View>
)}
{showPayOrder && ( {showPayOrder && (
<View className='OrderBox'> <View className='OrderBox'>
<OrderTitle price={orderInfo.payableMoney} /> <OrderTitle price={orderInfo.payableMoney} />
...@@ -299,38 +292,41 @@ class BarCode extends Component { ...@@ -299,38 +292,41 @@ class BarCode extends Component {
/> />
</View> </View>
)} )}
<View className={showPayOrder ? 'blur' : ''}>
<View {showBackTag && (
className={`BarCodeBox ${showPayOrder ? 'blur' : ''} ${ <View className='BackTag' onClick={this.goBackPage}>
showBig ? 'BarCodeBoxBig' : '' <Image className='icon' src={CodeIcon} />
}`}> <Text className='text'>隐藏条码</Text>
<Image
className='BarCodeBox-refresh'
src={RefreshIcon}
onClick={this.refreshCodeBar}
/>
{showPayOrder ? null : (
<View className={`BarCodeImg ${showBig ? 'BarCodeImgBig' : ''}`}>
<Canvas
className={`BarCodeCav ${showBig ? 'show' : ''}`}
canvasId='BarCodeBig'
/>
<Canvas
className={`BarCodeCav ${showBig ? '' : 'show'}`}
canvasId='BarCode'
/>
</View> </View>
)} )}
<View className='toggleBtn' onClick={this.toggleBigBarCode}> <View className={`BarCodeBox ${showBig ? 'BarCodeBoxBig' : ''}`}>
<Image <Image
className={`arricon ${showBig ? 'rever' : ''}`} className='BarCodeBox-refresh'
src={ArrIcon} src={RefreshIcon}
onClick={this.refreshCodeBar}
/> />
{showPayOrder ? null : (
<View className={`BarCodeImg ${showBig ? 'BarCodeImgBig' : ''}`}>
<Canvas
className={`BarCodeCav ${showBig ? 'show' : ''}`}
canvasId='BarCodeBig'
/>
<Canvas
className={`BarCodeCav ${showBig ? '' : 'show'}`}
canvasId='BarCode'
/>
</View>
)}
<View className='toggleBtn' onClick={this.toggleBigBarCode}>
<Image
className={`arricon ${showBig ? 'rever' : ''}`}
src={ArrIcon}
/>
</View>
</View>
<View className='warnning'>
如扫描条码终端无响应,请刷新条码后重试!
</View> </View>
</View>
<View className='warnning'>
如扫描条码终端无响应,请刷新条码后重试!
</View> </View>
</View> </View>
); );
......
...@@ -22,6 +22,12 @@ import { SOCKET_URL } from '@/constants'; ...@@ -22,6 +22,12 @@ import { SOCKET_URL } from '@/constants';
import { BluetoothDevice } from '@/types/Shower/Shower'; import { BluetoothDevice } from '@/types/Shower/Shower';
import { updateBluetoothDevice } from './actions'; import { updateBluetoothDevice } from './actions';
import { ab2str, str2ab } from '@/utils/arrayBuffer'; import { ab2str, str2ab } from '@/utils/arrayBuffer';
import { CustomerBeanAccountVo, PaymentAndActiveInfo } from '@/api/baseClass';
import Order from '@/types/Order/Order';
import { fetchPayOrder, fetchOrderDetailAndPay } from '@/api/order';
import OrderTitle from '../Order/components/OrderTitle/OrderTitle';
import OrderInfo from '../Order/components/OrderInfo/OrderInfo';
import OrderPayway from '../Order/components/OrderPayway/OrderPayway';
type DeviceInfo = { type DeviceInfo = {
deviceId: string; deviceId: string;
...@@ -48,6 +54,14 @@ type PageState = { ...@@ -48,6 +54,14 @@ type PageState = {
sockedDone: boolean; sockedDone: boolean;
deviceDone: boolean; deviceDone: boolean;
showerState: boolean; showerState: boolean;
showPayOrder: boolean;
accounts: CustomerBeanAccountVo[];
orderInfo: Order;
payInfos: {
paymentAndActiveInfos: PaymentAndActiveInfo[];
paymentConfId: number;
};
}; };
const StopCode = 1000; const StopCode = 1000;
...@@ -91,12 +105,49 @@ class Shower extends Component { ...@@ -91,12 +105,49 @@ class Shower extends Component {
writeId: '', writeId: '',
readId: '', readId: '',
}, },
showPayOrder: false,
accounts: [],
orderInfo: {
actualMoney: 0,
areaId: 0,
areaName: '',
consumeType: '',
createAt: '',
customerCellphone: '',
customerId: 0,
customerName: '',
deductionBean: 0,
deductionMoney: 0,
equipmentNum: '',
equipmentPosition: '',
id: 0,
operateId: 0,
operateName: '',
operationMode: '',
orderName: '',
orderNumber: '',
orderState: '',
outTradeNo: '',
payType: '',
payableMoney: 0,
serviceId: 0,
serviceName: '',
thirdDiscountMoney: 0,
thirdTradeNumber: '',
updateDate: '',
},
payInfos: {
paymentAndActiveInfos: [],
paymentConfId: 0,
},
}; };
} }
onShareAppMessage = shareHandle; onShareAppMessage = shareHandle;
componentWillMount() { componentWillMount() {
this.getPayState();
this.openBluetooth(); this.openBluetooth();
this.connectDeviceSocket(); this.connectDeviceSocket();
this.checkUsingDevice(); this.checkUsingDevice();
...@@ -110,6 +161,43 @@ class Shower extends Component { ...@@ -110,6 +161,43 @@ class Shower extends Component {
reConnectting = false; reConnectting = false;
} }
getPayState() {
const { userinfo } = this.props;
fetchPayOrder({
customerId: userinfo.customerId,
})
.then(res => {
if (res.data.length) {
this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true });
}
})
.catch(err => {
console.log(err);
});
}
fetchOrder(id: number) {
return fetchOrderDetailAndPay({
id,
})
.then(res => {
const { accounts, orderInfo, payInfos } = res;
this.setState({
accounts: accounts,
orderInfo: orderInfo,
payInfos: payInfos,
});
})
.catch(err => {
console.log(err);
});
}
payDoneHandle() {
this.setState({
showPayOrder: false,
});
}
connectDeviceSocket() { connectDeviceSocket() {
connectSocket(SOCKET_URL).then(task => { connectSocket(SOCKET_URL).then(task => {
socketTask = task; socketTask = task;
...@@ -702,52 +790,74 @@ class Shower extends Component { ...@@ -702,52 +790,74 @@ class Shower extends Component {
render() { render() {
const { const {
bluetoothDevice: { code, position }, bluetoothDevice: { code, position },
userinfo,
} = this.props; } = this.props;
const { showerState } = this.state; const {
showerState,
showPayOrder,
orderInfo,
accounts,
payInfos,
} = this.state;
return ( return (
<View className='Shower'> <View className='Shower'>
<View className='equipment-info-box'> {showPayOrder && (
<View className='equipment-info'> <View className='OrderBox'>
{code ? ( <OrderTitle price={orderInfo.payableMoney} />
<View className='equipment-title matched'>已匹配设备</View> <OrderInfo orderInfo={orderInfo} />
) : ( <OrderPayway
<View className='equipment-title'>未匹配设备</View> onPayDoneCallback={this.payDoneHandle}
)} userinfo={userinfo}
accounts={accounts}
<Image className='equipment-line' src={LineImg} /> orderInfo={orderInfo}
{code ? ( payInfos={payInfos}
<View className='equipment-list'> />
<View className='equipment-item'> </View>
<Text className='equipment-label'>设备编号:</Text> )}
<Text className='equipment-value'>{code}</Text> <View className={showPayOrder ? 'blur' : ''}>
<View className='equipment-info-box'>
<View className='equipment-info'>
{code ? (
<View className='equipment-title matched'>已匹配设备</View>
) : (
<View className='equipment-title'>未匹配设备</View>
)}
<Image className='equipment-line' src={LineImg} />
{code ? (
<View className='equipment-list'>
<View className='equipment-item'>
<Text className='equipment-label'>设备编号:</Text>
<Text className='equipment-value'>{code}</Text>
</View>
<View className='equipment-item'>
<Text className='equipment-label'>设备位置:</Text>
<Text className='equipment-value'>{position}</Text>
</View>
</View> </View>
<View className='equipment-item'> ) : (
<Text className='equipment-label'>设备位置:</Text> <View v-loading='loading' className='equipment-noCode'>
<Text className='equipment-value'>{position}</Text> 点击左下角扫一扫完成匹配
</View> </View>
</View> )}
) : ( </View>
<View v-loading='loading' className='equipment-noCode'>
点击左下角扫一扫完成匹配
</View>
)}
</View> </View>
</View> <View className='btn-box'>
<View className='btn-box'>
<Image
className='shower-scan-btn'
src={ScanIcon}
onClick={this.scanEquipment}
/>
{code && !showerState ? (
<Image <Image
className='shower-start-btn' className='shower-scan-btn'
src={ShowerStart} src={ScanIcon}
onClick={() => this.startUseShower(false)} onClick={this.scanEquipment}
/> />
) : ( {code && !showerState ? (
<Image className='shower-start-btn' src={ShowerCantStart} /> <Image
)} className='shower-start-btn'
src={ShowerStart}
onClick={() => this.startUseShower(false)}
/>
) : (
<Image className='shower-start-btn' src={ShowerCantStart} />
)}
</View>
</View> </View>
</View> </View>
); );
......
...@@ -21,6 +21,12 @@ import { Customer } from '@/types/Customer/Customer'; ...@@ -21,6 +21,12 @@ import { Customer } from '@/types/Customer/Customer';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { ComponentClass } from 'react'; import { ComponentClass } from 'react';
import { ResponseDataEntity } from '@/api'; import { ResponseDataEntity } from '@/api';
import { CustomerBeanAccountVo, PaymentAndActiveInfo } from '@/api/baseClass';
import Order from '@/types/Order/Order';
import { fetchOrderDetailAndPay, fetchPayOrder } from '@/api/order';
import OrderTitle from '../Order/components/OrderTitle/OrderTitle';
import OrderInfo from '../Order/components/OrderInfo/OrderInfo';
import OrderPayway from '../Order/components/OrderPayway/OrderPayway';
export type DeviceInfo = { export type DeviceInfo = {
code: string; code: string;
...@@ -36,6 +42,14 @@ type PageState = { ...@@ -36,6 +42,14 @@ type PageState = {
useList: DeviceInfo[]; useList: DeviceInfo[];
timer: number | null; timer: number | null;
showToggleTag: boolean; showToggleTag: boolean;
showPayOrder: boolean;
accounts: CustomerBeanAccountVo[];
orderInfo: Order;
payInfos: {
paymentAndActiveInfos: PaymentAndActiveInfo[];
paymentConfId: number;
};
}; };
type IProps = PageStateProps; type IProps = PageStateProps;
...@@ -44,6 +58,7 @@ interface WaterDispenser { ...@@ -44,6 +58,7 @@ interface WaterDispenser {
props: IProps; props: IProps;
state: PageState; state: PageState;
} }
@connect(({ userinfo }) => ({ @connect(({ userinfo }) => ({
userinfo, userinfo,
})) }))
...@@ -59,10 +74,47 @@ class WaterDispenser extends Component { ...@@ -59,10 +74,47 @@ class WaterDispenser extends Component {
useList: [], useList: [],
timer: null, timer: null,
showToggleTag: false, showToggleTag: false,
showPayOrder: false,
accounts: [],
orderInfo: {
actualMoney: 0,
areaId: 0,
areaName: '',
consumeType: '',
createAt: '',
customerCellphone: '',
customerId: 0,
customerName: '',
deductionBean: 0,
deductionMoney: 0,
equipmentNum: '',
equipmentPosition: '',
id: 0,
operateId: 0,
operateName: '',
operationMode: '',
orderName: '',
orderNumber: '',
orderState: '',
outTradeNo: '',
payType: '',
payableMoney: 0,
serviceId: 0,
serviceName: '',
thirdDiscountMoney: 0,
thirdTradeNumber: '',
updateDate: '',
},
payInfos: {
paymentAndActiveInfos: [],
paymentConfId: 0,
},
}; };
} }
componentWillMount() { componentWillMount() {
this.getPayState();
this.getUsedEquipment(); this.getUsedEquipment();
this.fetchPageConfig(); this.fetchPageConfig();
} }
...@@ -71,6 +123,43 @@ class WaterDispenser extends Component { ...@@ -71,6 +123,43 @@ class WaterDispenser extends Component {
this.clearTimer(); this.clearTimer();
} }
getPayState() {
const { userinfo } = this.props;
fetchPayOrder({
customerId: userinfo.customerId,
})
.then(res => {
if (res.data.length) {
this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true });
}
})
.catch(err => {
console.log(err);
});
}
fetchOrder(id: number) {
return fetchOrderDetailAndPay({
id,
})
.then(res => {
const { accounts, orderInfo, payInfos } = res;
this.setState({
accounts: accounts,
orderInfo: orderInfo,
payInfos: payInfos,
});
})
.catch(err => {
console.log(err);
});
}
payDoneHandle() {
this.setState({
showPayOrder: false,
});
}
fetchPageConfig() { fetchPageConfig() {
const { userinfo } = this.props; const { userinfo } = this.props;
fetchPageConfig({ fetchPageConfig({
...@@ -250,45 +339,66 @@ class WaterDispenser extends Component { ...@@ -250,45 +339,66 @@ class WaterDispenser extends Component {
deviceInfo: { code, position }, deviceInfo: { code, position },
useList, useList,
showToggleTag, showToggleTag,
showPayOrder,
orderInfo,
accounts,
payInfos,
} = this.state; } = this.state;
const { userinfo } = this.props;
return ( return (
<View className='WaterDispenser'> <View className='WaterDispenser'>
{showToggleTag && ( {showPayOrder && (
<View className='WaterDispenser-tg' onClick={this.toggleCodeState}> <View className='OrderBox'>
<Image className='icon' src={CodeIcon} /> <OrderTitle price={orderInfo.payableMoney} />
<Text className='text'>显示条码</Text> <OrderInfo orderInfo={orderInfo} />
<OrderPayway
onPayDoneCallback={this.payDoneHandle}
userinfo={userinfo}
accounts={accounts}
orderInfo={orderInfo}
payInfos={payInfos}
/>
</View> </View>
)} )}
<DeviceInfo size='small' code={code} position={position} /> <View className={showPayOrder ? 'blur' : ''}>
{showToggleTag && (
<View className='WaterDispenser-tg' onClick={this.toggleCodeState}>
<Image className='icon' src={CodeIcon} />
<Text className='text'>显示条码</Text>
</View>
)}
<DeviceInfo size='small' code={code} position={position} />
<View className='btn-box'> <View className='btn-box'>
<Image
className='shower-scan-btn'
src={ScanIcon}
onClick={this.scanEquipment}
/>
{code && !waterUsingState ? (
<Image <Image
className='shower-start-btn' className='shower-scan-btn'
src={StartIcon} src={ScanIcon}
onClick={this.waterBeginning} onClick={this.scanEquipment}
/> />
) : ( {code && !waterUsingState ? (
<Image className='shower-start-btn' src={CantStartIcon} /> <Image
)} className='shower-start-btn'
</View> src={StartIcon}
onClick={this.waterBeginning}
/>
) : (
<Image className='shower-start-btn' src={CantStartIcon} />
)}
</View>
<View className='LastUseList'> <View className='LastUseList'>
<View className='LastUseList-title bb'>最近使用</View> <View className='LastUseList-title bb'>最近使用</View>
{useList.map(device => ( {useList.map(device => (
<EquipmentItem <EquipmentItem
key={device.code} key={device.code}
ex-class='bb' ex-class='bb'
code={device.code} code={device.code}
position={device.position} position={device.position}
onClick={this.getSelectedEquipment} onClick={this.getSelectedEquipment}
/> />
))} ))}
</View>
</View> </View>
</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