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
880ef959
Commit
880ef959
authored
Nov 02, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新popup通用组件
parent
89ff55f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
170 deletions
+89
-170
src/components/blessingPreheat/index.js
+89
-170
No files found.
src/components/blessingPreheat/index.js
View file @
880ef959
...
...
@@ -29,62 +29,6 @@ import { connect } from "react-redux"
class
BlessingPreheat
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
navTop
=
183
this
.
prevY
=
0
this
.
state
=
{
userInfoList
:
[],
// userInfoList: [{
// token:'fcfef221e60ab7a2-92a80d5d30196999',
// uid:'545292',
// uname:'xzhtest2',
// avatar_file:''
// }],
isRule
:
false
,
isCourse
:
false
,
inviteUrl
:
''
,
inviteVisible
:
false
,
joinLotteryVisible
:
false
,
timelineShareVisible
:
false
,
showRecordList
:
false
,
isFormal
:
false
,
// 1正式 0 预热
isServer
:
false
,
serverUrl
:
''
,
shareMark
:
false
,
userInfo
:
{},
isSign
:
false
,
navs
:
[
{
text
:
'积福气'
,
id
:
'lucky-value'
},
{
text
:
'幸运大抽奖'
,
id
:
'lucky-draw'
},
{
text
:
'预付定金'
,
id
:
'deposit'
},
{
text
:
'精品特惠'
,
id
:
'best-courses'
},
{
text
:
'AI测试'
,
id
:
'ai-test'
},
{
text
:
'大咖直播'
,
id
:
'live'
},
],
index
:
0
,
userHasError
:
props
.
user
.
hasError
,
isApp
:
false
}
}
constructor
(
props
)
{
super
(
props
)
this
.
navTop
=
183
...
...
@@ -99,11 +43,14 @@ class BlessingPreheat extends Component {
// }],
isRule
:
false
,
isCourse
:
false
,
inviteUrl
:
''
,
inviteVisible
:
false
,
joinLotteryVisible
:
false
,
timelineShareVisible
:
false
,
showRecordList
:
false
,
isFormal
:
false
,
// 1正式 0 预热
isServer
:
false
,
serverUrl
:
''
,
shareMark
:
false
,
userInfo
:
{},
isSign
:
false
,
...
...
@@ -134,7 +81,8 @@ class BlessingPreheat extends Component {
},
],
index
:
0
,
userHasError
:
props
.
user
.
hasError
userHasError
:
props
.
user
.
hasError
,
isApp
:
false
}
}
...
...
@@ -163,46 +111,44 @@ class BlessingPreheat extends Component {
this
.
handleToAddBlessing
(
result
)
}
}
}
// 获取app登录数据
loginInfo
=
(
result
)
=>
{
this
.
setState
({
userInfoList
:
result
},
()
=>
{
if
(
this
.
state
.
userInfoList
.
length
)
{
this
.
props
.
startFetchUser
()
this
.
appLogin
()
}
})
// 获取app登录数据
loginInfo
=
(
result
)
=>
{
this
.
setState
({
userInfoList
:
result
},
()
=>
{
if
(
this
.
state
.
userInfoList
.
length
)
{
this
.
props
.
startFetchUser
()
this
.
appLogin
()
}
})
}
// 保存cookie
appLogin
=
()
=>
{
let
expires
=
addDays
(
new
Date
(),
90
)
this
.
state
.
userInfoList
.
map
((
item
,
index
)
=>
{
Toast
.
info
(
item
.
uid
)
cookie
.
set
(
"token"
,
item
.
token
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
});
cookie
.
set
(
"plat"
,
item
.
plat
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
});
cookie
.
set
(
"uid"
,
item
.
uid
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
});
cookie
.
set
(
"uname"
,
item
.
uname
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
});
cookie
.
set
(
"avatar_file"
,
item
.
avatar_file
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
});
});
if
(
cookie
.
get
(
"token"
)
&&
cookie
.
get
(
"uid"
))
{
this
.
fetchUserBlessing
();
this
.
setState
({
isApp
:
true
})
}
}
// 保存cookie
appLogin
=
()
=>
{
let
expires
=
addDays
(
new
Date
(),
90
)
this
.
state
.
userInfoList
.
map
((
item
,
index
)
=>
{
Toast
.
info
(
item
.
uid
)
cookie
.
set
(
"token"
,
item
.
token
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
cookie
.
set
(
"plat"
,
item
.
plat
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
cookie
.
set
(
"uid"
,
item
.
uid
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
cookie
.
set
(
"uname"
,
item
.
uname
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
cookie
.
set
(
"avatar_file"
,
item
.
avatar_file
,
{
expires
,
path
:
'/'
,
domain
:
'.julyedu.com'
})
})
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
if
(
cookie
.
get
(
"token"
)
&&
cookie
.
get
(
"uid"
))
{
this
.
fetchUserBlessing
()
this
.
setState
({
isApp
:
true
})
}
transformUser
=
res
=>
{
let
payload
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
}
transformUser
=
res
=>
{
let
payload
res
.
map
((
item
,
index
)
=>
{
payload
=
{
...
...
@@ -267,29 +213,29 @@ class BlessingPreheat extends Component {
return
findIndex
(
navs
,
item
=>
item
.
id
===
str
)
}
fetchUserBlessing
()
{
const
{
userInfo
}
=
this
.
state
;
http
.
get
(
`
${
API
.
home
}
/sys/user/blessing`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
alert
(
code
)
if
(
code
===
200
)
{
this
.
setState
({
isSign
:
!!
data
.
today_signed
,
isFormal
:
data
.
is_activity
,
userInfo
:
Object
.
assign
({},
userInfo
,
{
blessingVal
:
data
.
user_blessing_value
,
buyBlessing
:
(
data
.
types_total_blessing_value
&&
data
.
types_total_blessing_value
.
buy_course
)
?
data
.
types_total_blessing_value
.
buy_course
:
0
,
inviteBlessing
:
(
data
.
types_total_blessing_value
&&
data
.
types_total_blessing_value
.
invite
)
?
data
.
types_total_blessing_value
.
invite
:
0
,
})
})
alert
(
cookie
.
get
(
'uid'
))
if
(
data
.
is_login
===
1
)
{
this
.
handleToSign
()
}
this
.
initNav
(
data
.
is_activity
)
}
fetchUserBlessing
=
()
=>
{
const
{
userInfo
}
=
this
.
state
http
.
get
(
`
${
API
.
home
}
/sys/user/blessing`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
alert
(
code
)
if
(
code
===
200
)
{
this
.
setState
({
isSign
:
!!
data
.
today_signed
,
isFormal
:
data
.
is_activity
,
userInfo
:
Object
.
assign
({},
userInfo
,
{
blessingVal
:
data
.
user_blessing_value
,
buyBlessing
:
(
data
.
types_total_blessing_value
&&
data
.
types_total_blessing_value
.
buy_course
)
?
data
.
types_total_blessing_value
.
buy_course
:
0
,
inviteBlessing
:
(
data
.
types_total_blessing_value
&&
data
.
types_total_blessing_value
.
invite
)
?
data
.
types_total_blessing_value
.
invite
:
0
,
})
})
}
alert
(
cookie
.
get
(
'uid'
))
if
(
data
.
is_login
===
1
)
{
this
.
handleToSign
()
}
this
.
initNav
(
data
.
is_activity
)
}
})
}
handleToAddBlessing
=
(
key
)
=>
{
...
...
@@ -331,18 +277,18 @@ class BlessingPreheat extends Component {
// 需要用户登录 并且用户未登录
const
isLoginnew
=
!
this
.
props
.
user
.
hasError
if
(
isLogin
&&
!
isLoginnew
)
{
this
.
toLogin
()
}
else
{
let
obj
=
{}
obj
[
key
]
=
true
this
.
setState
({
...
obj
})
}
if
(
isLogin
&&
!
isLoginnew
)
{
this
.
toLogin
()
}
else
{
let
obj
=
{}
obj
[
key
]
=
true
this
.
setState
({
...
obj
})
}
}
// 邀请好友注册
// 邀请好友注册
handleToShowInvite
=
()
=>
{
const
isLogin
=
!
this
.
props
.
user
.
hasError
if
(
isLogin
)
{
...
...
@@ -474,33 +420,6 @@ class BlessingPreheat extends Component {
}
}
render
()
{
const
{
navs
,
userInfo
,
isRule
,
isCourse
,
inviteUrl
,
inviteVisible
,
isFormal
,
isServer
,
serverUrl
,
isSign
,
showRecordList
,
shareMark
,
index
,
isApp
}
=
this
.
state
;
const
{
history
}
=
this
.
props
;
const
isLogin
=
!
this
.
props
.
user
.
hasError
return
(
<
div
id
=
{
'blessing-preheat'
}
>
<
Banner
isFormal
=
{
isFormal
}
navs
=
{
navs
}
toSection
=
{
this
.
toSection
}
index
=
{
index
}
/
>
render
()
{
const
{
navs
,
...
...
@@ -511,7 +430,8 @@ class BlessingPreheat extends Component {
isSign
,
showRecordList
,
shareMark
,
index
index
,
isApp
}
=
this
.
state
const
{
history
}
=
this
.
props
const
isLogin
=
!
this
.
props
.
user
.
hasError
...
...
@@ -523,7 +443,6 @@ class BlessingPreheat extends Component {
toSection
=
{
this
.
toSection
}
index
=
{
index
}
/
>
{
/* 积福气 */
}
<
ListHeader
id
=
{
'lucky-value'
}
text
=
"积福气,享受更多福利"
styles
=
{{
margin
:
'60px 0 15px'
}}
/
>
<
Link
className
=
"luck-draw__button"
to
=
"/blessingRank"
>
福气排行榜
><
/Link
>
...
...
@@ -550,24 +469,24 @@ class BlessingPreheat extends Component {
<
button
className
=
"luck-draw__button"
onClick
=
{()
=>
this
.
handleToShow
(
'isRule'
)}
>
活动规则
><
/button
>
<
LuckDraw
/>
{
/*定金--只在预热期间显示*/
}
{
isFormal
===
0
&&
<>
<
ListHeader
id
=
{
'deposit'
}
text
=
"预付1元定金,最高可省100元"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
<
ReserveCourse
isApp
=
{
isApp
}
/
>
<
/
>
}
{
/* 精品课程特惠专区 */
}
<
ListHeader
id
=
{
'best-courses'
}
text
=
"精品课程特惠专区"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
<
CourseList
isApp
=
{
isApp
}
isFormal
=
{
isFormal
}
isLogin
=
{
isLogin
}
history
=
{
this
.
props
.
history
}
toLogin
=
{
this
.
toLogin
}
/
>
{
/*定金--只在预热期间显示*/
}
{
isFormal
===
0
&&
<>
<
ListHeader
id
=
{
'deposit'
}
text
=
"预付1元定金,最高可省100元"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
<
ReserveCourse
isApp
=
{
isApp
}
/
>
<
/
>
}
{
/* 精品课程特惠专区 */
}
<
ListHeader
id
=
{
'best-courses'
}
text
=
"精品课程特惠专区"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
<
CourseList
isApp
=
{
isApp
}
isFormal
=
{
isFormal
}
isLogin
=
{
isLogin
}
history
=
{
this
.
props
.
history
}
toLogin
=
{
this
.
toLogin
}
/
>
{
isRule
&&
...
...
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