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
3ca94d2f
Commit
3ca94d2f
authored
Jun 28, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加订单查询支付组件
parent
2df8c7ad
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
216 additions
and
51 deletions
+216
-51
app.scss
src/app.scss
+0
-10
WaitPayOrder.scss
src/components/WaitPayOrder/WaitPayOrder.scss
+10
-0
WaitPayOrder.tsx
src/components/WaitPayOrder/WaitPayOrder.tsx
+45
-0
useAllBeanCount.ts
src/hooks/useAllBeanCount.ts
+14
-7
useRechargePay.ts
src/hooks/useRechargePay.ts
+35
-14
useWaitPayOrderState.ts
src/hooks/useWaitPayOrderState.ts
+78
-19
Account.tsx
src/pages/Account/Account.tsx
+5
-1
reducers.ts
src/store/reducers.ts
+2
-0
orderState.ts
src/store/rootReducers/orderState.ts
+27
-0
No files found.
src/app.scss
View file @
3ca94d2f
...
...
@@ -103,13 +103,3 @@ button[disabled]:not([type]) {
.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
);
}
src/components/WaitPayOrder/WaitPayOrder.scss
0 → 100644
View file @
3ca94d2f
.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
);
}
src/components/WaitPayOrder/WaitPayOrder.tsx
0 → 100644
View file @
3ca94d2f
import
'./WaitPayOrder.scss'
;
import
{
View
}
from
'@tarojs/components'
;
import
OrderTitle
from
'@/pages/Order/components/OrderTitle/OrderTitle'
;
import
OrderInfo
from
'@/pages/Order/components/OrderInfo/OrderInfo'
;
import
OrderPayway
from
'@/pages/Order/components/OrderPayway/OrderPayway'
;
import
useWaitPayOrderState
from
'@/hooks/useWaitPayOrderState'
;
import
{
useSelector
,
useDispatch
}
from
'@tarojs/redux'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
updateOrderState
}
from
'@/store/rootReducers/orderState'
;
import
{
PayOrderState
}
from
'@/store/rootReducers/orderState'
;
const
WaitPayOrderComponent
=
()
=>
{
const
dispatch
=
useDispatch
();
const
userinfo
=
useSelector
(
(
state
:
{
userinfo
:
Customer
})
=>
state
.
userinfo
,
);
const
payOrderState
=
useSelector
(
(
state
:
{
orderState
:
PayOrderState
})
=>
state
.
orderState
.
waitPayOrderState
,
);
const
{
payInfos
,
accountList
,
orderInfo
}
=
useWaitPayOrderState
(
userinfo
.
customerId
,
);
const
payDoneHandle
=
()
=>
{
dispatch
(
updateOrderState
(
false
));
};
return
payOrderState
?
(
<
View
className=
'OrderBox'
>
<
OrderTitle
price=
{
orderInfo
.
payableMoney
}
/>
<
OrderInfo
orderInfo=
{
orderInfo
}
/>
<
OrderPayway
onPayDoneCallback=
{
payDoneHandle
}
userinfo=
{
userinfo
}
accounts=
{
accountList
}
orderInfo=
{
orderInfo
}
payInfos=
{
payInfos
}
/>
</
View
>
)
:
null
;
};
export
default
WaitPayOrderComponent
;
src/hooks/useAllBeanCount.ts
View file @
3ca94d2f
...
...
@@ -21,7 +21,10 @@ let initBeanList: BeanAccount[] = [];
const
useAllBeanCount
=
(
userinfo
:
Customer
,
serviceList
:
Service
[],
):
[
BeanAccount
[],
(
userinfo
:
Customer
)
=>
void
]
=>
{
):
[
BeanAccount
[],
(
customerId
:
number
,
areaId
:
number
,
customerPhone
:
string
)
=>
void
]
=>
{
const
[
filterBeanList
,
setFilterBeanList
]
=
useState
(
initBeanList
);
const
getFilterBeanList
=
(
...
...
@@ -66,11 +69,15 @@ const useAllBeanCount = (
return
arr
;
};
const
fetchDate
=
(
userinfo
:
Customer
)
=>
{
const
fetchDate
=
(
customerId
:
number
,
areaId
:
number
,
customerPhone
:
string
,
)
=>
{
fetchBeanCount
({
id
:
userinfo
.
customerId
,
areaId
:
userinfo
.
areaId
,
customerPhone
:
userinfo
.
customerPhone
,
id
:
customerId
,
areaId
:
areaId
,
customerPhone
:
customerPhone
,
serviceIdList
:
[],
})
.
then
(
res
=>
{
...
...
@@ -82,8 +89,8 @@ const useAllBeanCount = (
};
useEffect
(()
=>
{
fetchDate
(
userinfo
);
},
[
userinfo
]);
fetchDate
(
userinfo
.
customerId
,
userinfo
.
areaId
,
userinfo
.
customerPhone
);
},
[
userinfo
.
customerId
,
userinfo
.
areaId
,
userinfo
.
customerPhone
]);
return
[
filterBeanList
,
fetchDate
];
};
...
...
src/hooks/useRechargePay.ts
View file @
3ca94d2f
import
{
use
State
,
useEffect
}
from
'@tarojs/taro'
;
import
{
use
Effect
,
useReducer
}
from
'@tarojs/taro'
;
import
{
fetchPayConfig
,
PayConfig
,
PayTypeVo
}
from
'@/api/account'
;
import
Actions
from
'@/types/Store/Actions'
;
let
initPayConfigList
:
PayConfig
[]
=
[];
let
initPaywayList
:
PayTypeVo
[]
=
[];
enum
FirstRechargeState
{
isFirstRecharge
=
1
,
notFirstRecharge
=
0
,
}
type
RechargePayState
=
{
paywayList
:
PayConfig
[];
payConfigList
:
PayTypeVo
[];
isFirstRecharge
:
FirstRechargeState
;
};
const
reducer
=
(
state
:
RechargePayState
,
action
:
Actions
)
=>
{
switch
(
action
.
type
)
{
case
'updateRechargeInfo'
:
return
action
.
payload
;
default
:
return
state
;
}
};
const
usePaywayList
=
(
areaId
:
number
,
customerId
:
number
)
=>
{
const
[
paywayList
,
setPaywayList
]
=
useState
(
initPaywayList
);
const
[
payConfigList
,
setPayConfigList
]
=
useState
(
initPayConfigList
);
const
[
isFirstRecharge
,
setIsFirstRecharge
]
=
useState
(
0
);
const
[
state
,
dispatch
]
=
useReducer
(
reducer
,
{
paywayList
:
[],
payConfigList
:
[],
isFirstRecharge
:
0
,
});
const
fetchDate
=
(
areaId
:
number
,
customerId
:
number
)
=>
{
fetchPayConfig
({
...
...
@@ -21,9 +41,14 @@ const usePaywayList = (areaId: number, customerId: number) => {
listPayList
,
listRechargeConfDetail
,
}
=
res
.
data
;
setPayConfigList
(
listRechargeConfDetail
);
setPaywayList
(
listPayList
);
setIsFirstRecharge
(
isFirstRecharge
);
dispatch
({
type
:
'updateRechargeInfo'
,
payload
:
{
isFirstRecharge
,
payConfigList
:
listRechargeConfDetail
,
paywayList
:
listPayList
,
},
});
})
.
catch
(
console
.
error
);
};
...
...
@@ -31,11 +56,7 @@ const usePaywayList = (areaId: number, customerId: number) => {
fetchDate
(
areaId
,
customerId
);
},
[
areaId
,
customerId
]);
return
{
isFirstRecharge
,
paywayList
,
payConfigList
,
};
return
state
;
};
export
default
usePaywayList
;
src/hooks/useWaitPayOrderState.ts
View file @
3ca94d2f
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
useEffect
,
useState
}
from
'@tarojs/taro'
;
import
{
useEffect
,
useReducer
}
from
'@tarojs/taro'
;
import
{
fetchPayOrder
,
fetchOrderDetailAndPay
}
from
'@/api/order'
;
import
{
PaymentAndActiveInfo
,
CustomerBeanAccountVo
}
from
'@/api/baseClass'
;
import
Order
from
'@/types/Order/Order'
;
import
Actions
from
'@/types/Store/Actions'
;
import
{
useDispatch
}
from
'@tarojs/redux'
;
import
{
updateOrderState
}
from
'@/store/rootReducers/orderState'
;
const
useWaitPayOrderState
=
(
userinfo
:
Customer
)
=>
{
const
[
payOrderState
,
setPayOrderState
]
=
useState
(
false
);
const
[
accountList
,
setAccountList
]
=
useState
([]);
const
[
orderInfo
,
setOrderInfo
]
=
useState
(
null
);
const
[
payInfos
,
setPayInfos
]
=
useState
(
null
);
type
PayOrderData
=
{
accountList
:
CustomerBeanAccountVo
[];
orderInfo
:
Order
;
payInfos
:
{
paymentAndActiveInfos
:
PaymentAndActiveInfo
[];
paymentConfId
:
number
;
};
};
const
initPayOrderData
=
{
accountList
:
[],
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
,
},
};
const
reducer
=
(
state
:
PayOrderData
,
action
:
Actions
)
=>
{
switch
(
action
.
type
)
{
case
'updateOrderData'
:
return
{
...
state
,
...
action
.
payload
,
};
default
:
return
state
;
}
};
const
useWaitPayOrderState
=
(
customerId
:
number
):
PayOrderData
=>
{
const
[
state
,
dispatch
]
=
useReducer
(
reducer
,
initPayOrderData
);
const
dispatchAction
=
useDispatch
();
useEffect
(()
=>
{
fetchPayOrder
({
customerId
:
userinfo
.
customerId
,
customerId
:
customerId
,
})
.
then
(
res
=>
{
if
(
res
.
data
.
length
)
{
dispatchAction
(
updateOrderState
(
true
));
fetchOrderDetailAndPay
({
id
:
res
.
data
[
0
].
id
})
.
then
(({
accounts
,
orderInfo
,
payInfos
})
=>
{
setAccountList
(
accounts
);
setOrderInfo
(
orderInfo
);
setPayInfos
(
payInfos
);
dispatch
({
type
:
'updateOrderData'
,
payload
:
{
accountList
:
accounts
,
orderInfo
:
orderInfo
,
payInfos
:
payInfos
,
},
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
setPayOrderState
(
true
);
}
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
},
[
userinfo
]);
},
[
customerId
]);
return
{
payOrderState
,
accountList
,
orderInfo
,
payInfos
,
};
return
state
;
};
export
default
useWaitPayOrderState
;
src/pages/Account/Account.tsx
View file @
3ca94d2f
...
...
@@ -89,7 +89,11 @@ export const AccountComponent = () => {
})
.
then
(
res
=>
{
console
.
log
(
res
);
fetchNewBeanList
(
userinfo
);
fetchNewBeanList
(
userinfo
.
customerId
,
userinfo
.
areaId
,
userinfo
.
customerPhone
,
);
})
.
catch
(
err
=>
{
Taro
.
showToast
({
...
...
src/store/reducers.ts
View file @
3ca94d2f
...
...
@@ -3,10 +3,12 @@ import userinfo from './rootReducers/userinfo';
import
OrderList
from
'../pages/Order/OrderList/store'
;
import
ShowerReducer
from
'@/pages/Shower/store'
;
import
serviceList
from
'./rootReducers/service'
;
import
orderState
from
'./rootReducers/orderState'
;
export
default
combineReducers
({
userinfo
,
OrderList
,
Shower
:
ShowerReducer
,
serviceList
,
orderState
,
});
src/store/rootReducers/orderState.ts
0 → 100644
View file @
3ca94d2f
import
Actions
from
'@/types/Store/Actions'
;
export
type
PayOrderState
=
{
waitPayOrderState
:
boolean
;
};
const
INITIAL_STATE
=
{
waitPayOrderState
:
false
,
};
export
const
updateOrderState
=
(
state
:
boolean
):
Actions
=>
({
type
:
'UPDATE_ORDER_STATE'
,
payload
:
state
,
});
export
default
function
orderState
(
state
:
PayOrderState
=
INITIAL_STATE
,
action
:
Actions
,
)
{
switch
(
action
.
type
)
{
case
'UPDATE_ORDER_STATE'
:
return
{
...
state
,
waitPayOrderState
:
action
.
payload
};
default
:
return
state
;
}
}
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