Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
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
baiguangyao
mr-julyedu
Commits
939e928a
Commit
939e928a
authored
Aug 14, 2019
by
wangshuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公共方法提取
parent
533c5f55
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
75 deletions
+21
-75
src/components/order/index.js
+21
-75
No files found.
src/components/order/index.js
View file @
939e928a
...
...
@@ -173,12 +173,8 @@ class Order extends Component {
info
:
!
prevState
.
info
}));
};
componentDidMount
()
{
let
_this
=
this
;
console
.
log
(
this
.
props
.
location
.
state
);
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
type
===
1
)
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder?type=1`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
200
)
{
// 公共方法 存储数据
publicGetData
=
(
res
)
=>
{
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
cacheObj
=
{
perfect
:
user_info
,
...
...
@@ -194,6 +190,9 @@ class Order extends Component {
total
,
discount
,
});
};
// 公共方法 本地存储
publicLocalStorage
=
()
=>
{
if
(
this
.
props
.
history
.
action
===
'PUSH'
)
{
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
}
else
{
...
...
@@ -205,40 +204,24 @@ class Order extends Component {
this
.
computedMoneyByCache
();
}
}
};
componentDidMount
()
{
let
_this
=
this
;
console
.
log
(
this
.
props
.
location
.
state
);
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
type
===
1
)
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder?type=1`
).
then
((
res
)
=>
{
if
(
res
.
data
.
errno
===
200
)
{
this
.
publicGetData
(
res
);
this
.
publicLocalStorage
();
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
})
}
else
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
simple
===
1
)
{
http
.
get
(
`
${
API
.
home
}
/m/order/preorder`
).
then
(
res
=>
{
console
.
log
(
res
);
if
(
res
.
data
.
code
===
200
)
{
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
cacheObj
=
{
perfect
:
user_info
,
orderList
:
course
,
user_account
,
total
,
discount
,
};
this
.
setState
({
perfect
:
user_info
,
orderList
:
course
,
user_account
,
total
,
discount
,
});
if
(
this
.
props
.
history
.
action
===
'PUSH'
)
{
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
}
else
{
const
cacheObj
=
sessionStorage
.
getItem
(
'orderUseCacheObj'
);
if
(
cacheObj
!==
null
)
{
this
.
setState
({
useBalance
:
true
});
this
.
computedMoneyByCache
();
}
}
this
.
publicGetData
(
res
);
this
.
publicLocalStorage
();
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
...
...
@@ -254,54 +237,17 @@ class Order extends Component {
return
;
}
const
{
user_info
,
user_account
,
discount
}
=
preorder
.
data
.
data
;
this
.
cacheObj
=
{
perfect
:
user_info
,
orderList
:
orderList
,
user_account
,
total
:
preorder
.
data
.
data
.
total
,
discount
,
};
_this
.
setState
({
perfect
:
user_info
,
orderList
:
orderList
,
user_account
,
total
:
preorder
.
data
.
data
.
total
,
discount
,
});
this
.
publicGetData
(
preorder
);
})
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder`
).
then
((
res
)
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
data
.
errno
!==
200
)
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
return
;
}
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
cacheObj
=
{
perfect
:
user_info
,
orderList
:
course
,
user_account
,
total
,
discount
,
};
this
.
setState
({
perfect
:
user_info
,
orderList
:
course
,
user_account
,
total
,
discount
,
});
if
(
this
.
props
.
history
.
action
===
'PUSH'
)
{
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
}
else
{
const
cacheObj
=
sessionStorage
.
getItem
(
'orderUseCacheObj'
);
if
(
cacheObj
!==
null
)
{
this
.
setState
({
useBalance
:
true
});
this
.
computedMoneyByCache
();
}
}
this
.
publicGetData
(
res
);
this
.
publicLocalStorage
();
})
}
}
...
...
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