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
f9e31271
Commit
f9e31271
authored
Jan 08, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
海报页奖品
parent
d9f3127f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
407 additions
and
41 deletions
+407
-41
src/components/activity/give-courses/share-content/index.js
+16
-5
src/components/activity/give-courses/share-content/poster/poster.js
+104
-20
src/components/activity/give-courses/share-content/poster/poster.scss
+2
-14
src/components/activity/give-courses/share-content/prizes/prizes.js
+136
-2
src/components/activity/give-courses/share-content/prizes/prizes.scss
+149
-0
No files found.
src/components/activity/give-courses/share-content/index.js
View file @
f9e31271
...
...
@@ -4,18 +4,21 @@ import Poster from "./poster/poster"
import
Prizes
from
'./prizes/prizes'
class
ShareContent
extends
Component
{
state
=
{
activeIndex
:
0
,
tabs
:
[
'分享海报'
,
'活动奖品'
]
tabs
:
[
'分享海报'
,
'活动奖品'
],
poster
:
''
,
rankingList
:
[]
}
render
()
{
const
{
tabs
,
activeIndex
activeIndex
,
poster
,
rankingList
}
=
this
.
state
return
(
<
div
id
=
{
'share-content'
}
>
...
...
@@ -23,13 +26,21 @@ class ShareContent extends Component {
{
tabs
.
map
((
item
,
index
)
=>
{
return
(
<
li
key
=
{
index
}
className
=
{
activeIndex
===
index
?
'active'
:
''
}
onClick
=
{()
=>
{
this
.
setState
({
activeIndex
:
index
})}}
>
{
item
}
<
/li
>
<
li
key
=
{
index
}
className
=
{
activeIndex
===
index
?
'active'
:
''
}
onClick
=
{()
=>
{
this
.
setState
({
activeIndex
:
index
})
}}
>
{
item
}
<
/li
>
)
})
}
<
/ul
>
{
activeIndex
===
0
?
<
Poster
/>
:
<
Prizes
/>
activeIndex
===
0
?
<
Poster
poster
=
{
poster
}
savePoster
=
{
poster
=>
{
this
.
setState
({
poster
})
}}
/
>
:
<
Prizes
rankingList
=
{
rankingList
}
saveRankingList
=
{
rankingList
=>
{
this
.
setState
({
rankingList
})}}
/
>
}
<
/div
>
)
...
...
src/components/activity/give-courses/share-content/poster/poster.js
View file @
f9e31271
...
...
@@ -11,34 +11,120 @@ function showToast(text) {
class
Poster
extends
Component
{
state
=
{
redirectURL
:
''
,
posterBgUrl
:
''
,
avatar
:
''
redirectUrl
:
''
,
backgroundUrl
:
''
,
avatar
:
''
,
username
:
''
,
poster
:
this
.
props
.
poster
,
}
componentDidMount
()
{
http
.
get
(
`
${
API
[
"base-api"
]}
/assistance/active_haibao_info/
${
getParam
(
'assis_word'
)}
`
)
.
then
(
res
=>
{
const
{
data
,
errno
,
msg
}
=
res
.
data
if
(
errno
===
200
)
{
this
.
setState
({
avatar
:
''
})
}
else
{
showToast
(
msg
)
}
})
const
{
poster
}
=
this
.
props
if
(
!
poster
)
{
http
.
get
(
`
${
API
[
"base-api"
]}
/assistance/active_haibao_info/
${
getParam
(
'assis_word'
)}
`
)
.
then
(
res
=>
{
const
{
data
,
errno
,
msg
}
=
res
.
data
if
(
errno
===
200
)
{
this
.
setState
({
avatar
:
data
.
head_img
,
username
:
data
.
user_name
,
redirectUrl
:
data
.
m_redirect_code
,
backgroundUrl
:
data
.
background_img_url
},
()
=>
{
this
.
generatePoster
()
})
}
else
{
showToast
(
msg
)
}
})
}
}
generatePoster
=
()
=>
{
generatePoster
=
async
()
=>
{
let
canvas
=
document
.
createElement
(
'canvas'
),
scale
=
window
.
devicePixelRatio
||
1
,
ctx
=
canvas
.
getContext
(
'2d'
),
posterWidth
=
window
.
innerWidth
*
0.72
,
canvasWidth
=
posterWidth
*
scale
const
{
backgroundUrl
,
avatar
,
username
,
redirectUrl
}
=
this
.
state
const
bg
=
await
this
.
getImage
(
backgroundUrl
)
canvas
.
style
.
width
=
posterWidth
+
'px'
canvas
.
style
.
height
=
posterWidth
*
bg
.
height
/
bg
.
width
+
'px'
canvas
.
width
=
canvasWidth
canvas
.
height
=
canvasWidth
*
bg
.
height
/
bg
.
width
console
.
log
(
canvas
.
width
)
// ctx.scale(scale, scale)
ctx
.
drawImage
(
bg
,
0
,
0
,
canvas
.
width
,
canvas
.
height
)
// ctx.drawImage(bg, 0, 0, Math.round(+canvas.style.width.slice(0, -2)), Math.round(+canvas.style.height.slice(0, -2)))
let
r
=
16
*
scale
const
avatarImage
=
await
this
.
getImage
(
avatar
)
const
ax
=
20
*
scale
const
ay
=
15
/
2
*
scale
ctx
.
save
()
ctx
.
beginPath
()
ctx
.
arc
(
r
+
ax
,
r
+
ay
,
r
,
0
,
Math
.
PI
*
2
)
ctx
.
clip
()
ctx
.
drawImage
(
avatarImage
,
ax
,
ay
,
2
*
r
,
2
*
r
)
ctx
.
restore
()
ctx
.
font
=
`
${
12
*
scale
}
px serif`
ctx
.
fillStyle
=
'#fff'
ctx
.
fillText
(
username
,
2
*
r
+
ax
+
(
7
*
scale
),
22
*
scale
)
let
qrcode
=
await
this
.
getQRCodeCanvas
(
redirectUrl
,
scale
,
posterWidth
)
ctx
.
drawImage
(
qrcode
,
192
*
scale
,
405
*
scale
,
posterWidth
*
(
100
/
(
window
.
innerWidth
*
0.72
)),
posterWidth
*
(
100
/
(
window
.
innerWidth
*
0.72
)))
// 540 384 810
// 894 636 1342
// ctx.drawImage(qrcode, 220, 450, 60, 60)
// document.body.appendChild(canvas)
this
.
setState
({
poster
:
canvas
.
toDataURL
()
},
()
=>
{
const
{
savePoster
}
=
this
.
props
savePoster
&&
savePoster
(
this
.
state
.
poster
)
})
}
getImage
=
url
=>
{
return
new
Promise
(
resolve
=>
{
const
img
=
new
Image
()
img
.
setAttribute
(
'crossOrigin'
,
'anonymous'
)
img
.
onload
=
function
()
{
resolve
(
this
)
}
img
.
src
=
url
})
}
getQRCodeCanvas
=
(
text
,
scale
,
posterWidth
)
=>
{
const
canvas
=
document
.
createElement
(
'canvas'
)
let
codeWidth
=
100
*
scale
,
codeHeight
=
100
*
scale
,
codeSize
=
posterWidth
*
(
100
/
(
window
.
innerWidth
*
0.72
))
canvas
.
style
.
width
=
`
${
codeSize
}
px`
canvas
.
style
.
height
=
`
${
codeSize
}
px`
canvas
.
width
=
codeWidth
canvas
.
height
=
codeHeight
return
QRCode
.
toCanvas
(
canvas
,
text
)
}
render
()
{
const
{
poster
}
=
this
.
state
return
(
<
div
id
=
'poster'
>
<
div
className
=
"placard-desc"
>
...
...
@@ -46,10 +132,8 @@ class Poster extends Component {
<
/div
>
<
div
className
=
"total-container"
>
<
div
className
=
"placard-img-container"
id
=
'imgWrapper'
>
<
img
src
=
"billSrc.src"
/>
<
img
src
=
{
poster
}
alt
=
'分享海报'
/>
<
/div
>
<
div
id
=
"qrcode"
className
=
"placard-code"
><
/div
>
<
canvas
id
=
"canvas"
width
=
"450"
height
=
"imgHeight"
ref
=
"canvas"
><
/canvas
>
<
/div
>
<
/div
>
)
...
...
src/components/activity/give-courses/share-content/poster/poster.scss
View file @
f9e31271
...
...
@@ -8,15 +8,11 @@
-webkit-touch-callout
:
none
;
@mixin
px2px
(
$prop
,
$px
){
$prop
:
#{
$px
}
px
}
.placard-desc
{
width
:
100%
;
color
:
#fff
;
background-color
:
#470bc8
;
@include
px2px
(
font-size
,
28
)
;
font-size
:
14px
;
margin-bottom
:
15px
;
}
...
...
@@ -30,17 +26,9 @@
position
:
relative
;
img
{
width
:
270px
;
width
:
72%
;
}
}
.placard-code
{
opacity
:
0
;
position
:
absolute
;
width
:
100%
;
bottom
:
-400px
;
height
:
200px
;
}
}
...
...
src/components/activity/give-courses/share-content/prizes/prizes.js
View file @
f9e31271
import
React
,
{
Component
}
from
'react'
import
'./prizes.scss'
import
{
http
}
from
"@/utils"
import
{
Toast
}
from
"antd-mobile"
function
showToast
(
text
)
{
Toast
.
info
(
text
,
2
,
null
,
false
)
}
class
Prizes
extends
Component
{
state
=
{
list
:
[
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/prize-1.png'
,
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/prize-2.png'
,
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/prize-3.png'
,
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/prize-4.png'
,
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/prize-5.png'
,
'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/prize-6.png'
,
],
isShowRule
:
false
,
rankList
:
[]
}
componentDidMount
()
{
const
{
rankingList
}
=
this
.
props
console
.
log
(
rankingList
)
if
(
!
rankingList
||
!
rankingList
.
length
)
{
this
.
getRankingList
()
}
else
{
this
.
setState
({
rankingList
})
}
}
getRankingList
=
()
=>
{
const
{
saveRankingList
}
=
this
.
props
http
.
get
(
`
${
API
[
"base-api"
]}
/assistance/ranking_list/50`
)
.
then
(
res
=>
{
const
{
data
,
msg
,
errno
}
=
res
.
data
if
(
errno
===
200
)
{
this
.
setState
({
rankList
:
data
.
list
})
saveRankingList
&&
saveRankingList
(
data
.
list
)
}
else
{
showToast
(
msg
)
}
})
}
render
()
{
const
{
list
,
rankList
,
isShowRule
}
=
this
.
state
return
(
<
div
>
<
div
id
=
{
'prizes'
}
>
<
div
className
=
"content"
>
<
i
className
=
"part-title__decorate"
/>
<
div
className
=
"part-title__txt"
>
活动奖品
<
/div
>
<
i
className
=
"part-title__decorate"
/>
<
div
className
=
"prize-img"
>
{
list
.
map
((
item
,
index
)
=>
{
return
(
<
div
className
=
'img-box'
key
=
{
index
}
>
<
img
src
=
{
item
}
alt
=
""
/>
<
/div
>
)
})
}
<
/div
>
<
span
className
=
"rule"
onClick
=
{()
=>
{
this
.
setState
({
isShowRule
:
true
})
}}
>
活动规则
<
/span
>
<
/div
>
<
div
className
=
"content"
style
=
{{
padding
:
`20px 0 30px 0`
}}
>
<
i
className
=
"part-title__decorate"
/>
<
div
className
=
"part-title__txt"
>
排行榜
<
/div
>
<
i
className
=
"part-title__decorate"
/>
<
div
className
=
"tip"
>
数据实时更新
只显示
Top50
<
/div
>
<
table
className
=
"ranking"
cellSpacing
=
"0"
cellPadding
=
"0"
border
=
"0"
>
<
thead
>
<
tr
>
<
td
>
排名
<
/td
>
<
td
>
用户名称
<
/td
>
<
td
>
邀请人数
<
/td
>
<
/tr
>
<
/thead
>
<
tbody
>
{
rankList
.
map
((
item
,
index
)
=>
{
return
(
<
tr
key
=
{
index
}
>
<
td
>
{
index
+
1
}
<
/td
>
<
td
>
{
item
.
name
}
<
/td
>
<
td
>
{
item
.
num
}
<
/td
>
<
/tr
>
)
})
}
<
/tbody
>
<
/table
>
<
/div
>
{
isShowRule
?
<
div
className
=
"mbc-box"
>
<
div
className
=
"rele-content"
>
<
div
className
=
"title"
>
活动规则
<
/div
>
<
p
>
1
、进入七月在线服务号
<
a
style
=
{{
fontSize
:
`16px`
,
color
:
`rgba(47, 248, 255, 1)`
,
display
:
`inline-block`
}}
>
回复
77
<
/a>获取活动海报,将上方课程赠送给好友,每有1名好友领取后,您和好友均可免费学习1课时该课
;
<
/p
>
<
p
>
2
、每多
1
名好友领取,您获得的课时数
+
1
,直到获得全部课时,届时仍可赠送给好友;
<
/p
>
<
p
>
3
、活动结束后,邀请好友数超过
50
人且排行榜前
20
名用户会得到
<
a
style
=
{{
fontSize
:
`16px`
,
color
:
`rgba(47, 248, 255, 1)`
,
display
:
`inline-block`
}}
>
19
VIP
年会员、樱桃键盘
<
/a>等大奖
。
<
/p
>
<
/div
>
<
img
className
=
"close"
onClick
=
{()
=>
{
this
.
setState
({
isShowRule
:
false
})}}
src
=
"https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/newyear20/H5/close-btn.png"
alt
=
""
/>
<
/div
>
:
null
}
<
/div
>
)
}
...
...
src/components/activity/give-courses/share-content/prizes/prizes.scss
0 → 100644
View file @
f9e31271
#prizes
{
padding
:
0
10px
;
height
:
auto
;
.content
{
padding
:
20px
10px
30px
10px
;
background-color
:
#3F07B8
;
border
:
1px
solid
#5970FF
;
border-radius
:
4px
;
text-align
:
center
;
margin-bottom
:
30px
;
}
.part-title__decorate
{
display
:
block
;
width
:
232px
;
height
:
2px
;
margin
:
0
auto
;
background
:
linear-gradient
(
90deg
,
rgba
(
255
,
255
,
255
,
0
)
0%
,
rgba
(
255
,
255
,
255
,
1
)
48%
,
rgba
(
255
,
255
,
255
,
0
)
100%
);
}
.part-title__txt
{
display
:
inline-block
;
height
:
32px
;
line-height
:
32px
;
font-size
:
16px
;
color
:
#fff
;
font-weight
:
400
;
letter-spacing
:
2px
;
}
.prize-img
{
display
:
flex
;
justify-content
:
space-between
;
flex-wrap
:
wrap
;
margin-top
:
20px
;
.img-box
{
width
:
31
.3%
;
height
:
112px
;
margin-bottom
:
5px
;
img
{
width
:
100%
;
height
:
100%
;
}
}
}
.rule
{
display
:
inline-block
;
width
:
101px
;
height
:
28px
;
line-height
:
28px
;
border
:
1px
solid
rgba
(
254
,
228
,
29
,
1
);
border-radius
:
14px
;
margin-top
:
15px
;
color
:
#FEE41D
;
font-size
:
15px
;
}
.tip
{
margin-top
:
15px
;
font-size
:
12px
;
color
:
#fff
;
}
.ranking
{
width
:
100%
;
margin-top
:
20px
;
tr
{
height
:
44px
;
line-height
:
44px
;
}
thead
{
color
:
#FEE41D
;
font-size
:
14px
;
font-weight
:
500
;
background-color
:
#490AD1
;
}
tbody
{
color
:
#fff
;
font-weight
:
400
;
font-size
:
12px
;
tr
{
td
:first-child
{
font-size
:
14px
;
}
}
tr
:nth-child
(
odd
)
{
background-color
:
#470AC9
;
}
tr
:nth-child
(
even
)
{
background-color
:
#490AD1
;
}
}
}
}
.mbc-box
{
position
:
fixed
;
top
:
0
;
bottom
:
0
;
left
:
0
;
right
:
0
;
background
:
rgba
(
0
,
0
,
0
,
.6
);
.rele-content
{
display
:
inline-block
;
width
:
320px
;
background
:
#fff
;
border-radius
:
5px
;
padding
:
20px
28px
30px
28px
;
box-sizing
:
border-box
;
margin
:
145px
auto
30px
auto
;
.title
{
font-size
:
18px
;
color
:
#111
;
margin-bottom
:
20px
;
font-weight
:
normal
;
}
p
{
text-align
:
left
;
font-size
:
14px
;
color
:
#666666
;
line-height
:
18px
;
margin-bottom
:
3px
;
}
}
.close
{
display
:
block
;
margin
:
auto
;
width
:
33px
;
height
:
33px
;
}
}
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