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 {
...
@@ -173,12 +173,8 @@ class Order extends Component {
info
:
!
prevState
.
info
info
:
!
prevState
.
info
}));
}));
};
};
componentDidMount
()
{
// 公共方法 存储数据
let
_this
=
this
;
publicGetData
=
(
res
)
=>
{
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
)
{
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
cacheObj
=
{
this
.
cacheObj
=
{
perfect
:
user_info
,
perfect
:
user_info
,
...
@@ -194,6 +190,9 @@ class Order extends Component {
...
@@ -194,6 +190,9 @@ class Order extends Component {
total
,
total
,
discount
,
discount
,
});
});
};
// 公共方法 本地存储
publicLocalStorage
=
()
=>
{
if
(
this
.
props
.
history
.
action
===
'PUSH'
)
{
if
(
this
.
props
.
history
.
action
===
'PUSH'
)
{
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
sessionStorage
.
removeItem
(
'orderUseCacheObj'
);
}
else
{
}
else
{
...
@@ -205,40 +204,24 @@ class Order extends Component {
...
@@ -205,40 +204,24 @@ class Order extends Component {
this
.
computedMoneyByCache
();
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
{
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
}
})
})
}
else
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
simple
===
1
)
{
}
else
if
(
this
.
props
.
location
.
state
&&
this
.
props
.
location
.
state
.
simple
===
1
)
{
http
.
get
(
`
${
API
.
home
}
/m/order/preorder`
).
then
(
res
=>
{
http
.
get
(
`
${
API
.
home
}
/m/order/preorder`
).
then
(
res
=>
{
console
.
log
(
res
);
if
(
res
.
data
.
code
===
200
)
{
if
(
res
.
data
.
code
===
200
)
{
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
publicGetData
(
res
);
this
.
cacheObj
=
{
this
.
publicLocalStorage
();
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
();
}
}
}
else
{
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
Toast
.
info
(
res
.
data
.
msg
,
2
);
}
}
...
@@ -254,54 +237,17 @@ class Order extends Component {
...
@@ -254,54 +237,17 @@ class Order extends Component {
return
;
return
;
}
}
const
{
user_info
,
user_account
,
discount
}
=
preorder
.
data
.
data
;
this
.
publicGetData
(
preorder
);
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
,
});
})
})
}
else
{
}
else
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder`
).
then
((
res
)
=>
{
http
.
get
(
`
${
API
[
'base-api'
]}
/m/order/preorder`
).
then
((
res
)
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
data
.
errno
!==
200
)
{
if
(
res
.
data
.
errno
!==
200
)
{
Toast
.
info
(
res
.
data
.
msg
,
2
);
return
;
return
;
}
}
const
{
course
,
total
,
user_account
,
user_info
,
discount
}
=
res
.
data
.
data
;
this
.
cacheObj
=
{
this
.
publicGetData
(
res
);
perfect
:
user_info
,
this
.
publicLocalStorage
();
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
();
}
}
})
})
}
}
}
}
...
...
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