Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app-public
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-public
Commits
11e46672
Commit
11e46672
authored
Apr 22, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整支付逻辑
parent
e0526383
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
23 deletions
+32
-23
index.tsx
src/pages/index/index.tsx
+5
-3
pay.tsx
src/pages/pay/pay.tsx
+22
-14
prepayConfig.ts
src/store/rootReducers/prepayConfig.ts
+3
-6
Device.ts
src/types/Device/Device.ts
+2
-0
No files found.
src/pages/index/index.tsx
View file @
11e46672
...
...
@@ -64,6 +64,8 @@ class Index extends Component {
this
.
loginHandle
().
then
(()
=>
{
const
{
userinfo
}
=
this
.
props
;
let
queryArr
=
Object
.
keys
(
this
.
$router
.
params
);
console
.
log
(
this
.
$router
.
params
);
let
scene
:
string
=
queryArr
.
length
>
0
?
queryArr
[
0
]
:
''
;
console
.
log
(
'scene:'
,
scene
);
...
...
@@ -138,13 +140,13 @@ class Index extends Component {
})
.
then
(
res
=>
{
console
.
log
(
res
);
const
{
deviceInfoResponse
,
prepayConfigs
}
=
res
.
data
;
const
{
deviceInfoResponse
,
prepayConfigs
}
=
res
;
if
(
deviceInfoResponse
.
isUsed
)
{
console
.
log
(
'设备使用中'
);
return
;
}
updateDeviceData
(
deviceInfoResponse
);
updatePayData
(
prepayConfigs
);
deviceInfoResponse
&&
updateDeviceData
(
deviceInfoResponse
);
prepayConfigs
&&
updatePayData
(
prepayConfigs
);
Taro
.
navigateTo
({
url
:
'/pages/pay/pay'
,
});
...
...
src/pages/pay/pay.tsx
View file @
11e46672
...
...
@@ -10,7 +10,7 @@ import AES from 'crypto-js/aes';
import
Utf8
from
'crypto-js/enc-utf8'
;
import
ECBmode
from
'crypto-js/mode-ecb'
;
import
PaddingPkcs7
from
'crypto-js/pad-pkcs7'
;
import
{
paySuccess
}
from
'../../api/Order/paySuccess'
;
//
import { paySuccess } from '../../api/Order/paySuccess';
type
PageStateProps
=
{
device
:
Device
;
...
...
@@ -62,13 +62,13 @@ class Pay extends Component {
getPayOrder
({
equipmentNum
:
device
.
code
,
equipmentPos
:
device
.
position
,
payType
:
''
,
serviceId
:
0
,
payType
:
'
2
'
,
serviceId
:
device
.
serviceId
,
smaproCustomerId
:
customerId
,
smaproPrepayConfigId
:
payId
,
})
.
then
(
res
=>
{
const
{
payStr
,
outTradeNo
}
=
res
;
const
{
payStr
}
=
res
;
const
key
=
customerId
.
toString
().
padEnd
(
16
,
'0'
);
const
payData
=
JSON
.
parse
(
AES
.
decrypt
(
payStr
,
Utf8
.
parse
(
key
),
{
...
...
@@ -85,11 +85,21 @@ class Pay extends Component {
paySign
:
payData
.
msg
.
paySign
,
}).
then
(
res
=>
{
console
.
log
(
res
);
paySuccess
({
orderId
:
outTradeNo
});
Taro
.
showLoading
({
title
:
'设备连接中'
,
// paySuccess({ orderId: outTradeNo });
// Taro.showLoading({
// title: '设备连接中',
// mask: true,
// });
Taro
.
showToast
({
title
:
'支付成功!'
,
icon
:
'success'
,
mask
:
true
,
});
setTimeout
(()
=>
{
Taro
.
navigateTo
({
url
:
'/pages/index/index?'
,
// 需要问号不然回到首页可以取到业务参数
});
},
2000
);
});
})
.
catch
(
err
=>
{
...
...
@@ -115,15 +125,11 @@ class Pay extends Component {
<
View
className=
'Pay-info'
>
<
View
className=
'Pay-info-item'
>
<
Text
>
服务类型
</
Text
>
<
Text
>
{
prepayConfig
&&
prepayConfig
.
length
?
prepayConfig
[
0
].
serviceName
:
''
}
</
Text
>
<
Text
>
{
device
.
serviceName
?
device
.
serviceName
:
''
}
</
Text
>
</
View
>
<
View
className=
'Pay-info-item'
>
<
Text
>
设备编号
</
Text
>
<
Text
>
{
device
.
code
}
</
Text
>
<
Text
>
{
device
.
code
?
device
.
code
:
''
}
</
Text
>
</
View
>
<
View
className=
'Pay-info-item'
>
<
Text
>
设备位置
</
Text
>
...
...
@@ -153,7 +159,9 @@ class Pay extends Component {
温馨提示:如本次预付款未全部使用,系统将在使用结束后半小时内自动退还剩余金额,请留意查收!
</
View
>
<
View
className=
'Pay-money'
>
{
prepayConfig
.
map
(
payConfig
=>
(
{
prepayConfig
&&
prepayConfig
.
length
&&
prepayConfig
.
map
(
payConfig
=>
(
<
View
key=
{
payConfig
.
id
}
className=
{
`Pay-money-item ${
...
...
src/store/rootReducers/prepayConfig.ts
View file @
11e46672
...
...
@@ -4,7 +4,7 @@ import { PrepayConfig } from '../../types/Order/Order';
export
const
INITIAL_STATE
=
[];
export
const
updatePayData
=
(
entity
:
PrepayConfig
[]):
Action
=>
({
type
:
'UPDATE_
DEVICE
_DATA'
,
type
:
'UPDATE_
PAY
_DATA'
,
payload
:
entity
,
});
...
...
@@ -13,11 +13,8 @@ export default function prepayConfig(
actions
:
Action
,
):
PrepayConfig
[]
{
switch
(
actions
.
type
)
{
case
'UPDATE_DEVICE_DATA'
:
return
{
...
state
,
...
actions
.
payload
,
};
case
'UPDATE_PAY_DATA'
:
return
[...
state
,
...
actions
.
payload
];
default
:
return
state
;
}
...
...
src/types/Device/Device.ts
View file @
11e46672
...
...
@@ -12,4 +12,6 @@ export type Device = {
position
:
string
;
positionId
:
string
;
rates
:
Rate
[];
serviceId
:
number
;
serviceName
:
string
;
};
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