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
104df056
Commit
104df056
authored
Jul 14, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
周年庆
parent
979ed9ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
161 deletions
+161
-161
src/components/preferential/index.js
+161
-161
No files found.
src/components/preferential/index.js
View file @
104df056
import
React
,
{
Component
}
from
'react'
import
{
VList
}
from
'../../common'
import
{
Tabs
,
WhiteSpace
,
Toast
}
from
'antd-mobile'
import
React
,
{
Component
}
from
'react'
import
{
VList
}
from
'../../common'
import
{
Tabs
,
WhiteSpace
,
Toast
}
from
'antd-mobile'
import
'./index.scss'
import
HeaderSearch
from
'../../common/HeaderSearch/index'
import
{
http
}
from
"@/utils"
import
{
http
}
from
"@/utils"
import
Loading
from
'@/common/Loading'
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
@
connect
(({
user
})
=>
({
user
user
,
}))
class
Preferential
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataList
:
[],
courseStatus
:
0
,
isLoading
:
true
}
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
dataList
:
[],
courseStatus
:
0
,
isLoading
:
true
,
}
}
componentDidMount
()
{
this
.
specialSale
()
}
// 限时特惠
specialSale
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home/weekDiscounts`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
this
.
setState
({
dataList
:
res
.
data
.
data
,
isLoading
:
false
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
componentDidMount
()
{
this
.
specialSale
()
}
// 限时特惠
specialSale
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home/weekDiscounts`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
this
.
setState
({
dataList
:
res
.
data
.
data
,
isLoading
:
false
,
})
}
// 砍价专区
bargain
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home/bargainZone`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
this
.
setState
({
dataList
:
JSON
.
stringify
(
res
.
data
.
data
)
==
'{}'
?
[]:
res
.
data
.
data
,
isLoading
:
false
,
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
// 一键拼团
group
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home/grouponList`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
this
.
setState
({
dataList
:
res
.
data
.
data
,
isLoading
:
false
,
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
// 砍价专区
bargain
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home/bargainZone`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
this
.
setState
({
dataList
:
JSON
.
stringify
(
res
.
data
.
data
)
==
'{}'
?
[]
:
res
.
data
.
data
,
isLoading
:
false
,
})
}
// tab 切换
ontabclick
=
(
tab
,
index
)
=>
{
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
// 一键拼团
group
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home/grouponList`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
this
.
setState
({
courseStatus
:
index
,
isLoading
:
tru
e
,
dataList
:
res
.
data
.
data
,
isLoading
:
fals
e
,
})
switch
(
index
)
{
case
0
:
this
.
specialSale
()
break
case
1
:
this
.
bargain
()
break
default
:
this
.
group
()
}
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
}
})
}
// tab 切换
ontabclick
=
(
tab
,
index
)
=>
{
this
.
setState
({
courseStatus
:
index
,
isLoading
:
true
,
})
switch
(
index
)
{
case
0
:
this
.
specialSale
()
break
case
1
:
this
.
bargain
()
break
default
:
this
.
group
()
}
}
toCourseDetail
=
(
id
)
=>
{
const
{
dispatch
,
history
}
=
this
.
props
;
// dispatch(getCourses(id, () => {
history
.
push
(
`/detail?id=
${
id
}
`
)
// }));
}
toCourseDetail
=
(
id
)
=>
{
const
{
dispatch
,
history
}
=
this
.
props
;
// dispatch(getCourses(id, () => {
history
.
push
(
`/detail?id=
${
id
}
`
)
// }));
}
render
()
{
const
tabs
=
[
{
title
:
'限时特惠'
},
{
title
:
'砍价专区'
},
{
title
:
'一键拼团'
}
]
const
{
user
=
{}}
=
this
.
props
;
let
isLogin
=
user
.
data
&&
user
.
data
.
uid
?
true
:
false
;
return
(
<
div
className
=
'preferential'
>
<
HeaderSearch
isLogin
=
{
isLogin
}
/
>
<
Loading
isLoading
=
{
this
.
state
.
isLoading
}
>
<
div
className
=
'class-content'
>
<
WhiteSpace
/>
render
()
{
const
tabs
=
[
{
title
:
'限时特惠'
},
{
title
:
'砍价专区'
},
{
title
:
'一键拼团'
},
]
const
{
user
=
{}}
=
this
.
props
;
let
isLogin
=
user
.
data
&&
user
.
data
.
uid
?
true
:
false
;
return
(
<
div
className
=
'preferential'
>
<
HeaderSearch
isLogin
=
{
isLogin
}
/
>
<
Loading
isLoading
=
{
this
.
state
.
isLoading
}
>
<
div
className
=
'class-content'
>
<
WhiteSpace
/>
<
Tabs
tabs
=
{
tabs
}
animated
=
{
false
}
onChange
=
{(
tab
,
index
)
=>
this
.
ontabclick
(
tab
,
index
)}
swipeable
=
{
false
}
page
=
{
this
.
state
.
courseStatus
}
renderTabBar
=
{
props
=>
<
div
className
=
{
'custom-tab-bar'
}
>
<
Tabs
.
DefaultTabBar
{...
props
}
/
>
<
/div>
}
>
<
/Tabs
>
<
div
className
=
'tabs'
>
{
this
.
state
.
dataList
.
length
>
0
?
<
ul
>
{
this
.
state
.
dataList
.
map
((
item
,
index
)
=>
{
const
Info
=
(
<
div
className
=
"info"
>
<
p
className
=
'title'
onClick
=
{()
=>
this
.
toCourseDetail
(
item
.
course_id
)}
>
{
/* <Link to={`/detail?id=${item.course_id}`}> */
}
{
item
.
course_title
}
{
/* </Link> */
}
<
/p
>
<
p
className
=
'contact text-overflow-2'
>
{
item
.
course_desc
}
<
/p
>
<
div
className
=
'des'
>
{
!
item
.
is_buy
&&
<
p
className
=
"course-price"
>
{
this
.
state
.
courseStatus
===
0
&&
<
span
className
=
'price'
>
特惠价:
<
/span
>
}
<
span
className
=
"new"
>
¥
{
item
.
price1
}
<
/span
>
<
span
className
=
"old"
>
¥
{
item
.
price0
}
<
/span
>
<
/p
>
}
{
item
.
is_buy
&&
<
a
className
=
"isbuy"
>
已购买
<
/a
>
}
<
/div
>
<
/div
>
)
const
status
=
(
!
item
.
is_buy
&&
<
div
>
{
this
.
state
.
courseStatus
===
1
&&
<
p
className
=
'course-status'
>
砍价减
{
item
.
bargain_price
}
元
<
/p
>
}
{
this
.
state
.
courseStatus
===
2
&&
<
p
className
=
'course-status'
>
拼团价
{
item
.
price
}
元
<
/p
>
}
{
item
.
is_aist
&&
<
span
className
=
'return_cash'
><
/span
>
}
<
/div
>
)
return
(
<
VList
key
=
{
index
}
img
=
{
item
.
image_name
}
id
=
{
item
.
course_id
}
status
=
{
status
}
info
=
{
Info
}
toDetail
=
{
this
.
toCourseDetail
}
/
>
)
})}
<
/ul>:<div className={'notdata'}>砍价的课程已被设置为双十一活动课程,参加双十一活动购买课程优惠更多哦!</
div
>
<
Tabs
tabs
=
{
tabs
}
animated
=
{
false
}
onChange
=
{(
tab
,
index
)
=>
this
.
ontabclick
(
tab
,
index
)}
swipeable
=
{
false
}
page
=
{
this
.
state
.
courseStatus
}
renderTabBar
=
{
props
=>
<
div
className
=
{
'custom-tab-bar'
}
>
<
Tabs
.
DefaultTabBar
{...
props
}
/
>
<
/div>
}
>
<
/Tabs
>
<
div
className
=
'tabs'
>
{
this
.
state
.
dataList
.
length
>
0
?
<
ul
>
{
this
.
state
.
dataList
.
map
((
item
,
index
)
=>
{
const
Info
=
(
<
div
className
=
"info"
>
<
p
className
=
'title'
onClick
=
{()
=>
this
.
toCourseDetail
(
item
.
course_id
)}
>
{
/* <Link to={`/detail?id=${item.course_id}`}> */
}
{
item
.
course_title
}
{
/* </Link> */
}
<
/p
>
<
p
className
=
'contact text-overflow-2'
>
{
item
.
course_desc
}
<
/p
>
<
div
className
=
'des'
>
{
!
item
.
is_buy
&&
<
p
className
=
"course-price"
>
{
this
.
state
.
courseStatus
===
0
&&
<
span
className
=
'price'
>
特惠价:
<
/span
>
}
<
span
className
=
"new"
>
¥
{
item
.
price1
}
<
/span
>
<
span
className
=
"old"
>
¥
{
item
.
price0
}
<
/span
>
<
/p
>
}
{
item
.
is_buy
&&
<
a
className
=
"isbuy"
>
已购买
<
/a
>
}
<
/div
>
<
/div
>
)
const
status
=
(
!
item
.
is_buy
&&
<
div
>
{
this
.
state
.
courseStatus
===
1
&&
<
p
className
=
'course-status'
>
砍价减
{
item
.
bargain_price
}
元
<
/p
>
}
{
this
.
state
.
courseStatus
===
2
&&
<
p
className
=
'course-status'
>
拼团价
{
item
.
price
}
元
<
/p
>
}
{
item
.
is_aist
&&
<
span
className
=
'return_cash'
><
/span
>
}
<
/div
>
<
WhiteSpace
/>
<
/div
>
<
/Loading
>
)
return
(
<
VList
key
=
{
index
}
img
=
{
item
.
image_name
}
id
=
{
item
.
course_id
}
status
=
{
status
}
info
=
{
Info
}
toDetail
=
{
this
.
toCourseDetail
}
/
>
)
})}
<
/ul> : <div className={'notdata'}>特惠课程都去参加活动了,可以去活动页看看哦~</
div
>
}
<
/div
>
)
}
<
WhiteSpace
/>
<
/div
>
<
/Loading
>
<
/div
>
)
}
}
...
...
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