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
28c6f509
Commit
28c6f509
authored
Apr 23, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改设备以及支付配置更新逻辑
parent
285a907f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
+35
-5
index.tsx
src/pages/index/index.tsx
+25
-4
device.ts
src/store/rootReducers/device.ts
+9
-0
prepayConfig.ts
src/store/rootReducers/prepayConfig.ts
+1
-1
No files found.
src/pages/index/index.tsx
View file @
28c6f509
...
@@ -10,7 +10,11 @@ import { getDeviceConfig } from '../../api/device';
...
@@ -10,7 +10,11 @@ import { getDeviceConfig } from '../../api/device';
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
UserState
,
updateUserInfo
}
from
'../../store/rootReducers/userinfo'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
import
{
Customer
}
from
'../../types/Customer/Customer'
;
import
{
DeviceState
,
updateDeviceData
}
from
'../../store/rootReducers/device'
;
import
{
DeviceState
,
updateDeviceData
,
resetDeviceData
,
}
from
'../../store/rootReducers/device'
;
import
PrepayConfig
from
'../../types/Order/Order'
;
import
PrepayConfig
from
'../../types/Order/Order'
;
import
{
updatePayData
}
from
'../../store/rootReducers/prepayConfig'
;
import
{
updatePayData
}
from
'../../store/rootReducers/prepayConfig'
;
...
@@ -27,6 +31,7 @@ type PageDispatchProps = {
...
@@ -27,6 +31,7 @@ type PageDispatchProps = {
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
updateUserInfo
:
(
e
:
UserState
)
=>
void
;
updateDeviceData
:
(
e
:
DeviceState
)
=>
void
;
updateDeviceData
:
(
e
:
DeviceState
)
=>
void
;
updatePayData
:
(
e
:
PrepayConfig
[])
=>
void
;
updatePayData
:
(
e
:
PrepayConfig
[])
=>
void
;
resetDeviceData
:
()
=>
void
;
};
};
type
PageOwnProps
=
{};
type
PageOwnProps
=
{};
...
@@ -53,6 +58,9 @@ interface Index {
...
@@ -53,6 +58,9 @@ interface Index {
updatePayData
(
data
:
PrepayConfig
[])
{
updatePayData
(
data
:
PrepayConfig
[])
{
dispatch
(
updatePayData
(
data
));
dispatch
(
updatePayData
(
data
));
},
},
resetDeviceData
()
{
dispatch
(
resetDeviceData
());
},
}),
}),
)
)
class
Index
extends
Component
{
class
Index
extends
Component
{
...
@@ -133,7 +141,12 @@ class Index extends Component {
...
@@ -133,7 +141,12 @@ class Index extends Component {
getDeviceConfigHandle
({
equipmentNum
,
serviceId
}:
DeviceEntity
)
{
getDeviceConfigHandle
({
equipmentNum
,
serviceId
}:
DeviceEntity
)
{
Taro
.
showLoading
();
Taro
.
showLoading
();
const
{
userinfo
,
updateDeviceData
,
updatePayData
}
=
this
.
props
;
const
{
userinfo
,
updateDeviceData
,
updatePayData
,
resetDeviceData
,
}
=
this
.
props
;
return
getDeviceConfig
({
return
getDeviceConfig
({
customerId
:
userinfo
.
customerId
,
customerId
:
userinfo
.
customerId
,
equipmentNum
:
equipmentNum
,
equipmentNum
:
equipmentNum
,
...
@@ -147,8 +160,16 @@ class Index extends Component {
...
@@ -147,8 +160,16 @@ class Index extends Component {
console
.
log
(
'设备使用中'
);
console
.
log
(
'设备使用中'
);
return
;
return
;
}
}
deviceInfoResponse
&&
updateDeviceData
(
deviceInfoResponse
);
if
(
deviceInfoResponse
)
{
prepayConfigs
&&
updatePayData
(
prepayConfigs
);
updateDeviceData
(
deviceInfoResponse
);
}
else
{
resetDeviceData
();
}
if
(
prepayConfigs
)
{
updatePayData
(
prepayConfigs
);
}
else
{
updatePayData
([]);
}
Taro
.
navigateTo
({
Taro
.
navigateTo
({
url
:
'/pages/pay/pay'
,
url
:
'/pages/pay/pay'
,
});
});
...
...
src/store/rootReducers/device.ts
View file @
28c6f509
...
@@ -13,12 +13,17 @@ export const INITIAL_STATE = {
...
@@ -13,12 +13,17 @@ export const INITIAL_STATE = {
position
:
''
,
position
:
''
,
positionId
:
''
,
positionId
:
''
,
rates
:
[],
rates
:
[],
serviceId
:
0
,
serviceName
:
''
,
};
};
export
const
updateDeviceData
=
(
entity
:
DeviceState
):
Action
=>
({
export
const
updateDeviceData
=
(
entity
:
DeviceState
):
Action
=>
({
type
:
'UPDATE_DEVICE_DATA'
,
type
:
'UPDATE_DEVICE_DATA'
,
payload
:
entity
,
payload
:
entity
,
});
});
export
const
resetDeviceData
=
():
Action
=>
({
type
:
'UPDATE_DEVICE_DATA'
,
});
export
default
function
device
(
export
default
function
device
(
state
:
Device
=
INITIAL_STATE
,
state
:
Device
=
INITIAL_STATE
,
...
@@ -30,6 +35,10 @@ export default function device(
...
@@ -30,6 +35,10 @@ export default function device(
...
state
,
...
state
,
...
actions
.
payload
,
...
actions
.
payload
,
};
};
case
'UPDATE_DEVICE_DATA'
:
return
{
...
INITIAL_STATE
,
};
default
:
default
:
return
state
;
return
state
;
}
}
...
...
src/store/rootReducers/prepayConfig.ts
View file @
28c6f509
...
@@ -14,7 +14,7 @@ export default function prepayConfig(
...
@@ -14,7 +14,7 @@ export default function prepayConfig(
):
PrepayConfig
[]
{
):
PrepayConfig
[]
{
switch
(
actions
.
type
)
{
switch
(
actions
.
type
)
{
case
'UPDATE_PAY_DATA'
:
case
'UPDATE_PAY_DATA'
:
return
[...
state
,
...
actions
.
payload
];
return
[...
actions
.
payload
];
default
:
default
:
return
state
;
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