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
2b3e9680
Commit
2b3e9680
authored
Nov 02, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新popup通用组件
parent
0814d87a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
118 deletions
+94
-118
src/common/closable-popup/index.js
+24
-29
src/components/blessingPreheat/index.js
+48
-62
src/components/blessingPreheat/live/index.js
+4
-11
src/components/blessingPreheat/live/index.scss
+18
-16
No files found.
src/common/closable-popup/index.js
View file @
2b3e9680
import
React
,
{
Component
}
from
'react'
import
React
from
'react'
import
ReactDOM
from
'react-dom'
import
'./index.scss'
import
'./index.scss'
import
classnames
from
'classnames'
import
classnames
from
'classnames'
import
propTypes
from
'prop-types'
class
ClosablePopup
extends
Component
{
function
ClosablePopup
({
title
,
content
,
className
,
closable
=
true
,
close
=
function
()
{
state
=
{
visible
:
this
.
props
.
visible
}
}
}
=
{})
{
close
=
()
=>
{
function
unmountComponent
()
{
const
{
close
}
=
this
.
props
ReactDOM
.
unmountComponentAtNode
(
div
)
close
?
close
()
:
this
.
setState
({
visible
:
false
})
if
(
div
&&
div
.
parentNode
)
{
div
.
parentNode
.
removeChild
(
div
)
}
}
}
componentDidUpdate
(
prevProps
,
prevState
)
{
function
_close
(
)
{
const
{
visible
}
=
this
.
props
let
_c
=
close
()
if
(
prevState
.
visible
!==
this
.
props
.
visible
)
{
if
(
_c
&&
_c
.
then
)
{
this
.
setState
(
{
_c
.
then
(()
=>
{
visible
unmountComponent
()
})
})
}
else
{
unmountComponent
()
}
}
}
}
render
()
{
const
closablePopup
=
(
const
{
title
,
className
,
children
,
closable
=
true
}
=
this
.
props
return
(
this
.
state
.
visible
?
<
div
className
=
{
'closable-popup-mask'
}
>
<
div
className
=
{
'closable-popup-mask'
}
>
<
div
className
=
{
classnames
([
'popup-container'
,
className
])}
>
<
div
className
=
{
classnames
([
'popup-container'
,
className
])}
>
<
div
className
=
"title"
>
{
title
}
<
/div
>
<
div
className
=
"title"
>
{
title
}
<
/div
>
<
div
className
=
"content"
>
<
div
className
=
"content"
>
{
children
}
{
content
}
<
/div
>
<
/div
>
{
{
closable
&&
<
i
className
=
{
'close iconfont iconiconfront-2'
}
onClick
=
{
this
.
close
}
/
>
closable
&&
<
i
className
=
{
'close iconfont iconiconfront-2'
}
onClick
=
{
_
close
}
/
>
}
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
:
null
)
)
}
const
div
=
document
.
createElement
(
'div'
)
}
document
.
body
.
appendChild
(
div
)
ClosablePopup
.
propTypes
=
{
ReactDOM
.
render
(
closablePopup
,
div
)
title
:
propTypes
.
string
.
isRequired
,
visible
:
propTypes
.
bool
,
closable
:
propTypes
.
string
,
close
:
propTypes
.
func
}
}
export
default
ClosablePopup
export
default
ClosablePopup
src/components/blessingPreheat/index.js
View file @
2b3e9680
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
QRCode
from
'qrcode'
import
QRCode
from
'qrcode'
import
{
http
,
SendMessageToApp
,
wxShare
,
is_weixin
,
getParam
}
from
'@/utils'
;
import
{
http
,
SendMessageToApp
,
wxShare
,
is_weixin
,
getParam
}
from
'@/utils'
import
{
Link
}
from
'react-router-dom'
import
{
Link
}
from
'react-router-dom'
import
{
throttle
,
findIndex
,
debounce
}
from
'lodash'
import
{
throttle
,
findIndex
,
debounce
}
from
'lodash'
import
RulePopup
from
'./rulePopup/index'
import
RulePopup
from
'./rulePopup/index'
import
CoursePopup
from
'./coursePopup/index'
import
CoursePopup
from
'./coursePopup/index'
import
RecordPopup
from
'./recordPopup/index'
import
RecordPopup
from
'./recordPopup/index'
...
@@ -15,16 +15,16 @@ import ListHeader from './listHeader/index'
...
@@ -15,16 +15,16 @@ import ListHeader from './listHeader/index'
import
LevelTest
from
'./levelTest/index'
import
LevelTest
from
'./levelTest/index'
import
RankList
from
'./rankList/index'
import
RankList
from
'./rankList/index'
import
'./index.scss'
import
'./index.scss'
import
{
Popup
}
from
'@/common'
import
{
Popup
}
from
'@/common'
import
{
CopyToClipboard
}
from
'react-copy-to-clipboard'
import
{
CopyToClipboard
}
from
'react-copy-to-clipboard'
import
{
Toast
}
from
"antd-mobile"
import
{
Toast
}
from
"antd-mobile"
import
Live
from
'./live'
import
Live
from
'./live'
import
Banner
from
'./banner'
import
Banner
from
'./banner'
import
cookie
from
"js-cookie"
;
import
cookie
from
"js-cookie"
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
import
{
addDays
}
from
"date-fns"
;
import
{
addDays
}
from
"date-fns"
import
{
compose
}
from
"redux"
;
import
{
compose
}
from
"redux"
import
{
connect
}
from
"react-redux"
;
import
{
connect
}
from
"react-redux"
class
BlessingPreheat
extends
Component
{
class
BlessingPreheat
extends
Component
{
...
@@ -43,14 +43,11 @@ class BlessingPreheat extends Component {
...
@@ -43,14 +43,11 @@ class BlessingPreheat extends Component {
// }],
// }],
isRule
:
false
,
isRule
:
false
,
isCourse
:
false
,
isCourse
:
false
,
inviteUrl
:
''
,
inviteVisible
:
false
,
inviteVisible
:
false
,
joinLotteryVisible
:
false
,
joinLotteryVisible
:
false
,
timelineShareVisible
:
false
,
timelineShareVisible
:
false
,
showRecordList
:
false
,
showRecordList
:
false
,
isFormal
:
false
,
// 1正式 0 预热
isFormal
:
false
,
// 1正式 0 预热
isServer
:
false
,
serverUrl
:
''
,
shareMark
:
false
,
shareMark
:
false
,
userInfo
:
{},
userInfo
:
{},
isSign
:
false
,
isSign
:
false
,
...
@@ -86,9 +83,9 @@ class BlessingPreheat extends Component {
...
@@ -86,9 +83,9 @@ class BlessingPreheat extends Component {
}
}
componentDidMount
()
{
componentDidMount
()
{
this
.
fetchUserBlessing
();
this
.
fetchUserBlessing
()
this
.
setInitialNavActiveStatus
()
this
.
setInitialNavActiveStatus
()
window
.
addEventListener
(
'scroll'
,
throttle
(
this
.
calcNavActive
,
100
));
window
.
addEventListener
(
'scroll'
,
throttle
(
this
.
calcNavActive
,
100
))
if
(
is_weixin
())
{
if
(
is_weixin
())
{
wxShare
({
wxShare
({
title
:
'AI充电节,积福气享1折秒课,超10万元奖品来就送!!'
,
title
:
'AI充电节,积福气享1折秒课,超10万元奖品来就送!!'
,
...
@@ -104,10 +101,10 @@ class BlessingPreheat extends Component {
...
@@ -104,10 +101,10 @@ class BlessingPreheat extends Component {
}
}
window
[
'getNewData'
]
=
result
=>
{
window
[
'getNewData'
]
=
result
=>
{
this
.
fetchUserBlessing
();
this
.
fetchUserBlessing
()
}
}
window
[
'QQWXWBshare'
]
=
result
=>
{
window
[
'QQWXWBshare'
]
=
result
=>
{
this
.
handleToAddBlessing
(
result
);
this
.
handleToAddBlessing
(
result
)
}
}
...
@@ -129,12 +126,12 @@ class BlessingPreheat extends Component {
...
@@ -129,12 +126,12 @@ class BlessingPreheat extends Component {
let
expires
=
addDays
(
new
Date
(),
90
)
let
expires
=
addDays
(
new
Date
(),
90
)
this
.
state
.
userInfoList
.
map
((
item
,
index
)
=>
{
this
.
state
.
userInfoList
.
map
((
item
,
index
)
=>
{
Toast
.
info
(
item
.
uid
)
Toast
.
info
(
item
.
uid
)
cookie
.
set
(
"token"
,
item
.
token
,
{
expires
,
path
:
'/'
,
domain
:
'julyedu.com'
});
cookie
.
set
(
"token"
,
item
.
token
,
{
expires
,
path
:
'/'
,
domain
:
'julyedu.com'
})
cookie
.
set
(
"plat"
,
item
.
plat
,
{
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
(
"uid"
,
item
.
uid
,
{
expires
,
path
:
'/'
,
domain
:
'julyedu.com'
})
cookie
.
set
(
"uname"
,
item
.
uname
,
{
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'
});
cookie
.
set
(
"avatar_file"
,
item
.
avatar_file
,
{
expires
,
path
:
'/'
,
domain
:
'julyedu.com'
})
});
})
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
this
.
props
.
setCurrentUser
(
this
.
transformUser
(
this
.
state
.
userInfoList
))
}
}
transformUser
=
res
=>
{
transformUser
=
res
=>
{
...
@@ -157,8 +154,6 @@ class BlessingPreheat extends Component {
...
@@ -157,8 +154,6 @@ class BlessingPreheat extends Component {
}
}
getActiveIndex
=
(
arr
,
n
)
=>
{
getActiveIndex
=
(
arr
,
n
)
=>
{
for
(
let
i
=
0
,
len
=
arr
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
arr
.
length
;
i
<
len
;
i
++
)
{
if
(
arr
[
i
]
>
n
)
{
if
(
arr
[
i
]
>
n
)
{
...
@@ -206,7 +201,7 @@ class BlessingPreheat extends Component {
...
@@ -206,7 +201,7 @@ class BlessingPreheat extends Component {
}
}
fetchUserBlessing
()
{
fetchUserBlessing
()
{
const
{
userInfo
}
=
this
.
state
;
const
{
userInfo
}
=
this
.
state
http
.
get
(
`
${
API
.
home
}
/sys/user/blessing`
).
then
(
res
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/user/blessing`
).
then
(
res
=>
{
const
{
code
,
data
}
=
res
.
data
const
{
code
,
data
}
=
res
.
data
if
(
code
===
200
)
{
if
(
code
===
200
)
{
...
@@ -233,11 +228,11 @@ class BlessingPreheat extends Component {
...
@@ -233,11 +228,11 @@ class BlessingPreheat extends Component {
share_platform
:
key
,
// 1 朋友圈 2 微博 3 qq
share_platform
:
key
,
// 1 朋友圈 2 微博 3 qq
type
:
3
// 1:签到;3:分享;4:浏览课程;
type
:
3
// 1:签到;3:分享;4:浏览课程;
}).
then
(
res
=>
{
}).
then
(
res
=>
{
const
{
code
}
=
res
.
data
;
const
{
code
}
=
res
.
data
if
(
code
===
200
)
{
if
(
code
===
200
)
{
Toast
.
info
(
'+2点福气值~'
,
2
,
null
,
false
);
Toast
.
info
(
'+2点福气值~'
,
2
,
null
,
false
)
}
}
});
})
}
}
...
@@ -289,9 +284,18 @@ class BlessingPreheat extends Component {
...
@@ -289,9 +284,18 @@ class BlessingPreheat extends Component {
margin
:
1
margin
:
1
})
})
.
then
(
url
=>
{
.
then
(
url
=>
{
this
.
setState
({
const
content
=
(
inviteUrl
:
url
,
<>
inviteVisible
:
true
<
img
src
=
{
url
}
alt
=
"barcode"
className
=
"qr-code"
/>
<
CopyToClipboard
text
=
{
`
${
API
.
m
}
/invite"`
}
onCopy
=
{
this
.
onCopy
}
>
<
button
>
一键复制网址
<
/button
>
<
/CopyToClipboard
>
<
/
>
)
Popup
({
title
:
'扫码邀请好友注册+10点福气值'
,
content
,
className
:
'invite-popup'
})
})
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
@@ -307,7 +311,7 @@ class BlessingPreheat extends Component {
...
@@ -307,7 +311,7 @@ class BlessingPreheat extends Component {
SendMessageToApp
(
"toShare"
,
data
)
SendMessageToApp
(
"toShare"
,
data
)
}
}
}
else
{
}
else
{
this
.
toLogin
();
this
.
toLogin
()
}
}
}
}
...
@@ -320,9 +324,10 @@ class BlessingPreheat extends Component {
...
@@ -320,9 +324,10 @@ class BlessingPreheat extends Component {
height
:
120
,
height
:
120
,
margin
:
1
margin
:
1
}).
then
(
url
=>
{
}).
then
(
url
=>
{
this
.
setState
({
Popup
({
isServer
:
true
,
title
:
''
,
serverUrl
:
url
,
content
:
<
img
src
=
{
url
}
alt
=
"barcode"
className
=
"qr-code"
/>
,
className
:
'invite-popup'
})
})
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
@@ -406,17 +411,13 @@ class BlessingPreheat extends Component {
...
@@ -406,17 +411,13 @@ class BlessingPreheat extends Component {
userInfo
,
userInfo
,
isRule
,
isRule
,
isCourse
,
isCourse
,
inviteUrl
,
inviteVisible
,
isFormal
,
isFormal
,
isServer
,
serverUrl
,
isSign
,
isSign
,
showRecordList
,
showRecordList
,
shareMark
,
shareMark
,
index
index
}
=
this
.
state
;
}
=
this
.
state
const
{
history
}
=
this
.
props
;
const
{
history
}
=
this
.
props
const
isLogin
=
!
this
.
props
.
user
.
hasError
const
isLogin
=
!
this
.
props
.
user
.
hasError
return
(
return
(
<
div
id
=
{
'blessing-preheat'
}
>
<
div
id
=
{
'blessing-preheat'
}
>
...
@@ -490,23 +491,8 @@ class BlessingPreheat extends Component {
...
@@ -490,23 +491,8 @@ class BlessingPreheat extends Component {
shareMark
&&
shareMark
&&
<
SharePopup
/>
<
SharePopup
/>
}
}
<
Popup
{
/*
visible
=
{
inviteVisible
}
title
=
{
'扫码邀请好友注册+10点福气值'
}
className
=
{
'invite-popup'
}
>
<
img
src
=
{
inviteUrl
}
alt
=
"barcode"
className
=
"qr-code"
/>
<
CopyToClipboard
text
=
{
`
${
API
.
m
}
/invite"`
}
onCopy
=
{
this
.
onCopy
}
>
<
button
>
一键复制网址
<
/button
>
<
/CopyToClipboard
>
<
/Popup
>
<
Popup
visible
=
{
isServer
}
title
=
"扫码关注“七月在线”服务号"
className
=
{
'invite-popup'
}
>
<
img
src
=
{
serverUrl
}
alt
=
"barcode"
className
=
"qr-code"
/>
<
/Popup
>
<Popup visible={this.state.joinLotteryVisible}
<Popup visible={this.state.joinLotteryVisible}
title={'你已成功参与本时段抽奖'}
title={'你已成功参与本时段抽奖'}
...
@@ -531,7 +517,7 @@ class BlessingPreheat extends Component {
...
@@ -531,7 +517,7 @@ class BlessingPreheat extends Component {
>
>
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/tinypng-common/right_weixin.png" alt=""
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/tinypng-common/right_weixin.png" alt=""
className="qr-code"/>
className="qr-code"/>
<
/Popup
>
</Popup>
*/
}
<
ListHeader
id
=
{
'ai-test'
}
text
=
"全国AI工程师水平测试"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
<
ListHeader
id
=
{
'ai-test'
}
text
=
"全国AI工程师水平测试"
styles
=
{{
margin
:
'30px 0 15px'
}}
/
>
...
...
src/components/blessingPreheat/live/index.js
View file @
2b3e9680
...
@@ -16,8 +16,6 @@ class Live extends Component {
...
@@ -16,8 +16,6 @@ class Live extends Component {
tabs
:
[],
tabs
:
[],
lives
:
{},
lives
:
{},
preheatLives
:
[],
preheatLives
:
[],
visible
:
false
,
qrcode
:
''
,
today
:
''
,
today
:
''
,
isApp
:
getParam
(
'version'
)
isApp
:
getParam
(
'version'
)
}
}
...
@@ -80,9 +78,9 @@ class Live extends Component {
...
@@ -80,9 +78,9 @@ class Live extends Component {
const
{
data
}
=
res
const
{
data
}
=
res
if
(
data
.
code
==
200
)
{
if
(
data
.
code
==
200
)
{
QRCode
.
toDataURL
(
data
.
data
.
url
,
(
err
,
url
)
=>
{
QRCode
.
toDataURL
(
data
.
data
.
url
,
(
err
,
url
)
=>
{
this
.
setState
({
Popup
({
qrcode
:
url
,
title
:
'扫码关注“七月在线”服务号即可预约'
,
visible
:
true
content
:
<
img
id
=
{
'live-qr-code'
}
src
=
{
url
}
alt
=
""
/>
})
})
})
})
}
else
{
}
else
{
...
@@ -92,14 +90,9 @@ class Live extends Component {
...
@@ -92,14 +90,9 @@ class Live extends Component {
}
}
render
()
{
render
()
{
const
{
tabs
,
lives
,
visible
,
qrcode
,
preheatLives
,
today
}
=
this
.
state
const
{
tabs
,
lives
,
preheatLives
,
today
}
=
this
.
state
return
(
return
(
<
div
id
=
{
'live'
}
>
<
div
id
=
{
'live'
}
>
<
Popup
title
=
{
'扫码关注“七月在线”服务号即可预约'
}
visible
=
{
visible
}
>
<
img
id
=
{
'live-qr-code'
}
src
=
{
qrcode
}
alt
=
""
/>
<
/Popup
>
<
div
className
=
"title"
>
<
div
className
=
"title"
>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/title-decorate-left.png"
alt
=
""
/>
<
img
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/title-decorate-left.png"
alt
=
""
/>
<
span
>
大咖直播
<
/span
>
<
span
>
大咖直播
<
/span
>
...
...
src/components/blessingPreheat/live/index.scss
View file @
2b3e9680
#live
{
#live
{
margin-top
:
30px
;
margin-top
:
30px
;
.title
{
.title
{
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
...
@@ -175,22 +176,6 @@
...
@@ -175,22 +176,6 @@
}
}
.popup-container
{
.title
{
color
:
#525C65
;
}
.content
{
display
:
flex
;
justify-content
:
center
;
img
{
width
:
120px
;
height
:
120px
;
}
}
}
.am-tabs
{
.am-tabs
{
width
:
330px
;
width
:
330px
;
margin
:
0
auto
;
margin
:
0
auto
;
...
@@ -234,3 +219,20 @@
...
@@ -234,3 +219,20 @@
}
}
}
}
.popup-container
{
.title
{
color
:
#525C65
;
}
.content
{
display
:
flex
;
justify-content
:
center
;
img
{
width
:
120px
;
height
:
120px
;
}
}
}
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