Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
wx-school-app
Commits
dcaeb0a8
Commit
dcaeb0a8
authored
Jun 28, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽离页面中订单的支付逻辑
parent
3ca94d2f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
363 deletions
+69
-363
useAllBeanCount.ts
src/hooks/useAllBeanCount.ts
+11
-4
Account.tsx
src/pages/Account/Account.tsx
+21
-0
BarCode.tsx
src/pages/BarCode/BarCode.tsx
+14
-141
Shower.tsx
src/pages/Shower/Shower.tsx
+14
-113
WaterDispenser.tsx
src/pages/WaterDispenser/WaterDispenser.tsx
+9
-105
No files found.
src/hooks/useAllBeanCount.ts
View file @
dcaeb0a8
...
@@ -23,7 +23,11 @@ const useAllBeanCount = (
...
@@ -23,7 +23,11 @@ const useAllBeanCount = (
serviceList
:
Service
[],
serviceList
:
Service
[],
):
[
):
[
BeanAccount
[],
BeanAccount
[],
(
customerId
:
number
,
areaId
:
number
,
customerPhone
:
string
)
=>
void
(
customerId
:
number
,
areaId
:
number
,
customerPhone
:
string
,
)
=>
Promise
<
CustomerBeanAccountVo
[]
>
]
=>
{
]
=>
{
const
[
filterBeanList
,
setFilterBeanList
]
=
useState
(
initBeanList
);
const
[
filterBeanList
,
setFilterBeanList
]
=
useState
(
initBeanList
);
...
@@ -73,7 +77,7 @@ const useAllBeanCount = (
...
@@ -73,7 +77,7 @@ const useAllBeanCount = (
customerId
:
number
,
customerId
:
number
,
areaId
:
number
,
areaId
:
number
,
customerPhone
:
string
,
customerPhone
:
string
,
)
=>
{
)
=>
fetchBeanCount
({
fetchBeanCount
({
id
:
customerId
,
id
:
customerId
,
areaId
:
areaId
,
areaId
:
areaId
,
...
@@ -84,9 +88,12 @@ const useAllBeanCount = (
...
@@ -84,9 +88,12 @@ const useAllBeanCount = (
const
data
=
res
.
data
;
const
data
=
res
.
data
;
let
list
=
getFilterBeanList
(
data
);
let
list
=
getFilterBeanList
(
data
);
setFilterBeanList
(
list
);
setFilterBeanList
(
list
);
return
data
;
})
})
.
catch
(
console
.
error
);
.
catch
(
err
=>
{
};
console
.
log
(
err
);
throw
err
;
});
useEffect
(()
=>
{
useEffect
(()
=>
{
fetchDate
(
userinfo
.
customerId
,
userinfo
.
areaId
,
userinfo
.
customerPhone
);
fetchDate
(
userinfo
.
customerId
,
userinfo
.
areaId
,
userinfo
.
customerPhone
);
...
...
src/pages/Account/Account.tsx
View file @
dcaeb0a8
...
@@ -61,6 +61,7 @@ export const AccountComponent = () => {
...
@@ -61,6 +61,7 @@ export const AccountComponent = () => {
return
;
return
;
}
}
console
.
log
(
'in recharge'
);
console
.
log
(
'in recharge'
);
let
preAimiItem
=
filterBeanList
.
find
(
item
=>
item
.
serviceId
===
'0'
);
rechargeOrder
({
rechargeOrder
({
id
:
payConfigId
,
id
:
payConfigId
,
customerId
:
userinfo
.
customerId
,
customerId
:
userinfo
.
customerId
,
...
@@ -93,7 +94,27 @@ export const AccountComponent = () => {
...
@@ -93,7 +94,27 @@ export const AccountComponent = () => {
userinfo
.
customerId
,
userinfo
.
customerId
,
userinfo
.
areaId
,
userinfo
.
areaId
,
userinfo
.
customerPhone
,
userinfo
.
customerPhone
,
)
.
then
(
beanAccount
=>
{
console
.
log
(
beanAccount
);
let
aimiItem
=
beanAccount
.
find
(
item
=>
item
.
serviceId
===
'0'
,
);
);
if
(
aimiItem
&&
aimiItem
.
money
&&
preAimiItem
&&
preAimiItem
.
money
&&
aimiItem
.
money
===
preAimiItem
.
money
)
{
Taro
.
showModal
({
title
:
'提示'
,
content
:
'由于网络原因,本次充值可能延迟到账,请稍后查看余额'
,
});
}
})
.
catch
(
console
.
error
);
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
Taro
.
showToast
({
Taro
.
showToast
({
...
...
src/pages/BarCode/BarCode.tsx
View file @
dcaeb0a8
...
@@ -10,19 +10,13 @@ import wxbarcode from 'wxbarcode';
...
@@ -10,19 +10,13 @@ import wxbarcode from 'wxbarcode';
import
'./BarCode.scss'
;
import
'./BarCode.scss'
;
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
connect
,
useSelector
}
from
'@tarojs/redux'
;
import
{
fetchPayOrder
,
fetchOrderDetailAndPay
}
from
'../../api/order'
;
import
OrderInfo
from
'../Order/components/OrderInfo/OrderInfo'
;
import
OrderTitle
from
'../Order/components/OrderTitle/OrderTitle'
;
import
OrderPayway
from
'../Order/components/OrderPayway/OrderPayway'
;
import
{
PaymentAndActiveInfo
,
CustomerBeanAccountVo
,
}
from
'../../api/baseClass'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
import
{
refreshCodeBar
}
from
'../../api/customer'
;
import
{
refreshCodeBar
}
from
'../../api/customer'
;
import
Order
from
'@/types/Order/Order'
;
import
{
shareHandle
}
from
'@/common/shareMethod'
;
import
{
shareHandle
}
from
'@/common/shareMethod'
;
import
{
PayOrderState
}
from
'@/store/rootReducers/orderState'
;
import
WaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
import
widthWaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
type
PageStateProps
=
{
type
PageStateProps
=
{
userinfo
:
Customer
;
userinfo
:
Customer
;
...
@@ -34,25 +28,7 @@ type PageDispatchProps = {
...
@@ -34,25 +28,7 @@ type PageDispatchProps = {
type
PageOwnProps
=
{};
type
PageOwnProps
=
{};
type
PageState
=
{
type
PageState
=
{
ScreenBrightness
:
number
;
ScreenBrightness
:
number
;
showPayOrder
:
boolean
;
showBig
:
boolean
;
showBig
:
boolean
;
accounts
:
CustomerBeanAccountVo
[];
orderInfo
:
Order
;
payInfos
:
{
paymentAndActiveInfos
:
PaymentAndActiveInfo
[];
paymentConfId
:
number
;
};
deductionInfos
:
{
amiAccount
:
number
;
beanAccount
:
number
;
deductionMoney
:
number
;
deductionType
:
string
;
orderMoney
:
number
;
payMoney
:
number
;
payType
:
string
;
remainAccount
:
number
;
titlePerfix
:
string
;
};
showBackTag
:
boolean
;
showBackTag
:
boolean
;
};
};
...
@@ -77,74 +53,14 @@ class BarCode extends Component {
...
@@ -77,74 +53,14 @@ class BarCode extends Component {
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
ScreenBrightness
:
1
,
ScreenBrightness
:
1
,
showPayOrder
:
false
,
showBig
:
false
,
showBig
:
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
,
},
deductionInfos
:
{
amiAccount
:
0
,
beanAccount
:
0
,
deductionMoney
:
0
,
deductionType
:
''
,
orderMoney
:
0
,
payMoney
:
0
,
payType
:
''
,
remainAccount
:
0
,
titlePerfix
:
''
,
},
showBackTag
:
false
,
showBackTag
:
false
,
};
};
}
}
onShareAppMessage
=
shareHandle
;
onShareAppMessage
=
shareHandle
;
componentWillMount
()
{
componentWillMount
()
{
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
();
this
.
drawBarCode
();
}
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
console
.
log
(
'调整亮度'
);
console
.
log
(
'调整亮度'
);
Taro
.
getScreenBrightness
()
Taro
.
getScreenBrightness
()
.
then
(({
value
})
=>
{
.
then
(({
value
})
=>
{
...
@@ -194,33 +110,6 @@ class BarCode extends Component {
...
@@ -194,33 +110,6 @@ class BarCode extends Component {
}
}
}
}
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
,
},
()
=>
{
this
.
drawBarCode
();
},
);
}
drawBarCode
()
{
drawBarCode
()
{
const
{
userinfo
}
=
this
.
props
;
const
{
userinfo
}
=
this
.
props
;
const
routeParams
=
this
.
$router
.
params
;
const
routeParams
=
this
.
$router
.
params
;
...
@@ -248,6 +137,7 @@ class BarCode extends Component {
...
@@ -248,6 +137,7 @@ class BarCode extends Component {
showBig
:
!
showBig
,
showBig
:
!
showBig
,
});
});
}
}
refreshCodeBar
()
{
refreshCodeBar
()
{
const
{
updateUserInfo
}
=
this
.
props
;
const
{
updateUserInfo
}
=
this
.
props
;
refreshCodeBar
()
refreshCodeBar
()
...
@@ -268,31 +158,16 @@ class BarCode extends Component {
...
@@ -268,31 +158,16 @@ class BarCode extends Component {
}
}
render
()
{
render
()
{
const
{
userinfo
}
=
this
.
props
;
const
{
showBig
,
showBackTag
}
=
this
.
state
;
const
{
const
payOrderState
=
useSelector
(
showPayOrder
,
(
state
:
{
orderState
:
PayOrderState
})
=>
showBig
,
state
.
orderState
.
waitPayOrderState
,
orderInfo
,
);
payInfos
,
accounts
,
showBackTag
,
}
=
this
.
state
;
return
(
return
(
<
View
className=
'BarCode'
>
<
View
className=
'BarCode'
>
{
showPayOrder
&&
(
<
WaitPayOrderComponent
/>
<
View
className=
'OrderBox'
>
<
View
className=
{
payOrderState
?
'blur'
:
''
}
>
<
OrderTitle
price=
{
orderInfo
.
payableMoney
}
/>
<
OrderInfo
orderInfo=
{
orderInfo
}
/>
<
OrderPayway
onPayDoneCallback=
{
this
.
payDoneHandle
}
userinfo=
{
userinfo
}
accounts=
{
accounts
}
orderInfo=
{
orderInfo
}
payInfos=
{
payInfos
}
/>
</
View
>
)
}
<
View
className=
{
showPayOrder
?
'blur'
:
''
}
>
{
showBackTag
&&
(
{
showBackTag
&&
(
<
View
className=
'BackTag'
onClick=
{
this
.
goBackPage
}
>
<
View
className=
'BackTag'
onClick=
{
this
.
goBackPage
}
>
<
Image
className=
'icon'
src=
{
CodeIcon
}
/>
<
Image
className=
'icon'
src=
{
CodeIcon
}
/>
...
@@ -305,7 +180,6 @@ class BarCode extends Component {
...
@@ -305,7 +180,6 @@ class BarCode extends Component {
src=
{
RefreshIcon
}
src=
{
RefreshIcon
}
onClick=
{
this
.
refreshCodeBar
}
onClick=
{
this
.
refreshCodeBar
}
/>
/>
{
showPayOrder
?
null
:
(
<
View
className=
{
`BarCodeImg ${showBig ? 'BarCodeImgBig' : ''}`
}
>
<
View
className=
{
`BarCodeImg ${showBig ? 'BarCodeImgBig' : ''}`
}
>
<
Canvas
<
Canvas
className=
{
`BarCodeCav ${showBig ? 'show' : ''}`
}
className=
{
`BarCodeCav ${showBig ? 'show' : ''}`
}
...
@@ -316,7 +190,6 @@ class BarCode extends Component {
...
@@ -316,7 +190,6 @@ class BarCode extends Component {
canvasId=
'BarCode'
canvasId=
'BarCode'
/>
/>
</
View
>
</
View
>
)
}
<
View
className=
'toggleBtn'
onClick=
{
this
.
toggleBigBarCode
}
>
<
View
className=
'toggleBtn'
onClick=
{
this
.
toggleBigBarCode
}
>
<
Image
<
Image
className=
{
`arricon ${showBig ? 'rever' : ''}`
}
className=
{
`arricon ${showBig ? 'rever' : ''}`
}
...
@@ -333,4 +206,4 @@ class BarCode extends Component {
...
@@ -333,4 +206,4 @@ class BarCode extends Component {
}
}
}
}
export
default
BarCode
as
ComponentClass
<
PageOwnProps
,
PageState
>
;
export
default
BarCode
;
src/pages/Shower/Shower.tsx
View file @
dcaeb0a8
...
@@ -13,7 +13,7 @@ import {
...
@@ -13,7 +13,7 @@ import {
startShowerEquipment
,
startShowerEquipment
,
fetchUsingShowerInfo
,
fetchUsingShowerInfo
,
}
from
'@/api/shower'
;
}
from
'@/api/shower'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
connect
,
useSelector
}
from
'@tarojs/redux'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
ComponentClass
}
from
'react'
;
import
{
ComponentClass
}
from
'react'
;
import
{
ResponseDataEntity
}
from
'@/api'
;
import
{
ResponseDataEntity
}
from
'@/api'
;
...
@@ -22,12 +22,8 @@ import { SOCKET_URL } from '@/constants';
...
@@ -22,12 +22,8 @@ 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
WaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
import
Order
from
'@/types/Order/Order'
;
import
{
PayOrderState
}
from
'@/store/rootReducers/orderState'
;
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'
;
enum
BlueToothError
{
enum
BlueToothError
{
BlueToothNotOpen
=
'BlueToothNotOpen'
,
BlueToothNotOpen
=
'BlueToothNotOpen'
,
...
@@ -58,14 +54,6 @@ type PageState = {
...
@@ -58,14 +54,6 @@ 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
;
...
@@ -74,7 +62,7 @@ interface Shower {
...
@@ -74,7 +62,7 @@ interface Shower {
state
:
PageState
;
state
:
PageState
;
}
}
let
timer
:
number
|
null
=
null
;
let
timer
:
NodeJS
.
Timeout
|
null
=
null
;
let
reConnectting
:
boolean
=
false
;
let
reConnectting
:
boolean
=
false
;
let
socketTask
:
Taro
.
SocketTask
|
null
=
null
;
let
socketTask
:
Taro
.
SocketTask
|
null
=
null
;
@
connect
(
@
connect
(
...
@@ -109,49 +97,12 @@ class Shower extends Component {
...
@@ -109,49 +97,12 @@ 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
();
...
@@ -165,43 +116,6 @@ class Shower extends Component {
...
@@ -165,43 +116,6 @@ 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
;
...
@@ -447,7 +361,7 @@ class Shower extends Component {
...
@@ -447,7 +361,7 @@ class Shower extends Component {
return
Taro
.
startBluetoothDevicesDiscovery
()
return
Taro
.
startBluetoothDevicesDiscovery
()
.
then
(()
=>
{
.
then
(()
=>
{
const
{
code
,
isOnlyBluetooth
}
=
this
.
props
.
bluetoothDevice
;
const
{
code
,
isOnlyBluetooth
}
=
this
.
props
.
bluetoothDevice
;
let
timer
:
number
|
null
=
null
;
let
timer
:
NodeJS
.
Timeout
|
null
=
null
;
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
if
(
isOnlyBluetooth
)
{
if
(
isOnlyBluetooth
)
{
timer
=
setTimeout
(()
=>
{
timer
=
setTimeout
(()
=>
{
...
@@ -820,31 +734,18 @@ class Shower extends Component {
...
@@ -820,31 +734,18 @@ class Shower extends Component {
render
()
{
render
()
{
const
{
const
{
bluetoothDevice
:
{
code
,
position
},
bluetoothDevice
:
{
code
,
position
},
userinfo
,
}
=
this
.
props
;
}
=
this
.
props
;
const
{
const
{
showerState
}
=
this
.
state
;
showerState
,
const
payOrderState
=
useSelector
(
showPayOrder
,
(
state
:
{
orderState
:
PayOrderState
})
=>
orderInfo
,
state
.
orderState
.
waitPayOrderState
,
accounts
,
);
payInfos
,
}
=
this
.
state
;
return
(
return
(
<
View
className=
'Shower'
>
<
View
className=
'Shower'
>
{
showPayOrder
&&
(
<
WaitPayOrderComponent
/>
<
View
className=
'OrderBox'
>
<
OrderTitle
price=
{
orderInfo
.
payableMoney
}
/>
<
View
className=
{
payOrderState
?
'blur'
:
''
}
>
<
OrderInfo
orderInfo=
{
orderInfo
}
/>
<
OrderPayway
onPayDoneCallback=
{
this
.
payDoneHandle
}
userinfo=
{
userinfo
}
accounts=
{
accounts
}
orderInfo=
{
orderInfo
}
payInfos=
{
payInfos
}
/>
</
View
>
)
}
<
View
className=
{
showPayOrder
?
'blur'
:
''
}
>
<
View
className=
'equipment-info-box'
>
<
View
className=
'equipment-info-box'
>
<
View
className=
'equipment-info'
>
<
View
className=
'equipment-info'
>
{
code
?
(
{
code
?
(
...
...
src/pages/WaterDispenser/WaterDispenser.tsx
View file @
dcaeb0a8
...
@@ -18,15 +18,14 @@ import {
...
@@ -18,15 +18,14 @@ import {
PageConfigResponse
,
PageConfigResponse
,
}
from
'@/api/waterDispenser'
;
}
from
'@/api/waterDispenser'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
connect
,
useSelector
}
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
{
CustomerBeanAccountVo
,
PaymentAndActiveInfo
}
from
'@/api/baseClass'
;
import
Order
from
'@/types/Order/Order'
;
import
Order
from
'@/types/Order/Order'
;
import
{
fetchOrderDetailAndPay
,
fetchPayOrder
}
from
'@/api/order'
;
import
{
fetchOrderDetailAndPay
,
fetchPayOrder
}
from
'@/api/order'
;
import
OrderTitle
from
'../Order/components/OrderTitle/OrderTitle'
;
import
WaitPayOrderComponent
from
'@/components/WaitPayOrder/WaitPayOrder'
;
import
OrderInfo
from
'../Order/components/OrderInfo/OrderInfo'
;
import
{
PayOrderState
}
from
'@/store/rootReducers/orderState'
;
import
OrderPayway
from
'../Order/components/OrderPayway/OrderPayway'
;
export
type
DeviceInfo
=
{
export
type
DeviceInfo
=
{
code
:
string
;
code
:
string
;
...
@@ -42,14 +41,6 @@ type PageState = {
...
@@ -42,14 +41,6 @@ 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
;
...
@@ -74,47 +65,10 @@ class WaterDispenser extends Component {
...
@@ -74,47 +65,10 @@ 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
();
}
}
...
@@ -123,43 +77,6 @@ class WaterDispenser extends Component {
...
@@ -123,43 +77,6 @@ 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
({
...
@@ -339,29 +256,16 @@ class WaterDispenser extends Component {
...
@@ -339,29 +256,16 @@ 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
;
const
payOrderState
=
useSelector
(
(
state
:
{
orderState
:
PayOrderState
})
=>
state
.
orderState
.
waitPayOrderState
,
);
return
(
return
(
<
View
className=
'WaterDispenser'
>
<
View
className=
'WaterDispenser'
>
{
showPayOrder
&&
(
<
WaitPayOrderComponent
/>
<
View
className=
'OrderBox'
>
<
View
className=
{
payOrderState
?
'blur'
:
''
}
>
<
OrderTitle
price=
{
orderInfo
.
payableMoney
}
/>
<
OrderInfo
orderInfo=
{
orderInfo
}
/>
<
OrderPayway
onPayDoneCallback=
{
this
.
payDoneHandle
}
userinfo=
{
userinfo
}
accounts=
{
accounts
}
orderInfo=
{
orderInfo
}
payInfos=
{
payInfos
}
/>
</
View
>
)
}
<
View
className=
{
showPayOrder
?
'blur'
:
''
}
>
{
showToggleTag
&&
(
{
showToggleTag
&&
(
<
View
className=
'WaterDispenser-tg'
onClick=
{
this
.
toggleCodeState
}
>
<
View
className=
'WaterDispenser-tg'
onClick=
{
this
.
toggleCodeState
}
>
<
Image
className=
'icon'
src=
{
CodeIcon
}
/>
<
Image
className=
'icon'
src=
{
CodeIcon
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment