Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
a0744081
Commit
a0744081
authored
May 28, 2021
by
guomingpang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修改分享培训计划 学院名称缓存问题
parent
f2b70b05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
99 deletions
+103
-99
src/modules/plan-manage/modal/SharePlanModal.jsx
+103
-99
No files found.
src/modules/plan-manage/modal/SharePlanModal.jsx
View file @
a0744081
/*
* @Author: 吴文洁
* @Date: 2020-07-20 19:12:49
* @Author: 吴文洁
* @Date: 2020-07-20 19:12:49
* @Last Modified by: 吴文洁
* @Last Modified time: 2020-07-20 20:25:13
* @Description: 大班直播分享弹窗
*/
import
React
from
'react'
;
import
{
Modal
,
Input
,
Button
,
message
}
from
'antd'
;
import
domtoimage
from
'dom-to-image'
;
import
qrcode
from
"@/libs/qrcode/qrcode.js"
;
import
User
from
'@/common/js/user'
;
import
$
from
'jquery'
;
import
CourseService
from
"@/domains/course-domain/CourseService"
;
import
React
from
'react'
import
{
Modal
,
Button
,
message
}
from
'antd'
import
domtoimage
from
'dom-to-image'
import
qrcode
from
'@/libs/qrcode/qrcode.js'
import
User
from
'@/common/js/user'
import
$
from
'jquery'
import
CourseService
from
'@/domains/course-domain/CourseService'
import
'./SharePlanModal.less'
;
import
'./SharePlanModal.less'
const
storeName
=
User
.
getStoreName
();
const
DEFAULT_COVER
=
'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'
;
const
DEFAULT_COVER
=
'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'
class
ShareLiveModal
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
)
;
super
(
props
)
this
.
state
=
{
shareUrl
:
''
shareUrl
:
''
,
}
}
componentDidMount
()
{
// 获取短链接
this
.
handleConvertShortUrl
()
;
this
.
handleConvertShortUrl
()
}
handleConvertShortUrl
=
()
=>
{
const
{
longUrl
}
=
this
.
props
.
data
;
const
{
longUrl
}
=
this
.
props
.
data
// 发请求
CourseService
.
getQrcode
({
urls
:
[
longUrl
]
urls
:
[
longUrl
]
,
}).
then
((
res
)
=>
{
const
{
result
=
[]
}
=
res
;
this
.
setState
({
shareUrl
:
result
[
0
].
shortUrl
},
()
=>
{
const
qrcodeWrapDom
=
document
.
querySelector
(
'#qrcodeWrap'
);
const
qrcodeNode
=
new
qrcode
({
text
:
this
.
state
.
shareUrl
,
size
:
98
,
})
qrcodeWrapDom
.
appendChild
(
qrcodeNode
);
});
const
{
result
=
[]
}
=
res
this
.
setState
(
{
shareUrl
:
result
[
0
].
shortUrl
,
},
()
=>
{
const
qrcodeWrapDom
=
document
.
querySelector
(
'#qrcodeWrap'
)
const
qrcodeNode
=
new
qrcode
({
text
:
this
.
state
.
shareUrl
,
size
:
98
,
})
qrcodeWrapDom
.
appendChild
(
qrcodeNode
)
}
)
})
}
componentWillUnmount
()
{
// 页面销毁之前清空定时器
clearTimeout
(
this
.
timer
)
;
clearTimeout
(
this
.
timer
)
}
// 下载海报
handleDownloadPoster
=
()
=>
{
this
.
setState
({
showImg
:
true
,
time
:
new
Date
().
valueOf
()
},()
=>
{
this
.
setState
({
time
:
new
Date
().
valueOf
()},()
=>
{
let
node
=
document
.
getElementById
(
'poster'
);
domtoimage
.
toPng
(
node
)
.
then
((
imgData
)
=>
{
this
.
setState
(
{
showImg
:
true
,
time
:
new
Date
().
valueOf
(),
},
()
=>
{
this
.
setState
({
time
:
new
Date
().
valueOf
()
},
()
=>
{
let
node
=
document
.
getElementById
(
'poster'
)
domtoimage
.
toPng
(
node
).
then
((
imgData
)
=>
{
console
.
log
(
imgData
)
const
download
=
document
.
createElement
(
'a'
)
;
const
{
planName
}
=
this
.
props
.
data
;
$
(
download
).
attr
(
'href'
,
imgData
).
attr
(
'download'
,
`
${
planName
}
.png`
).
get
(
0
).
click
()
;
const
download
=
document
.
createElement
(
'a'
)
const
{
planName
}
=
this
.
props
.
data
$
(
download
).
attr
(
'href'
,
imgData
).
attr
(
'download'
,
`
${
planName
}
.png`
).
get
(
0
).
click
()
})
})
})
})
}
)
}
// 复制分享链接
handleCopy
=
()
=>
{
const
textContent
=
document
.
getElementById
(
'shareUrl'
).
innerText
;
const
textContent
=
document
.
getElementById
(
'shareUrl'
).
innerText
window
.
copyText
(
textContent
)
;
message
.
success
(
'复制成功!'
)
;
window
.
copyText
(
textContent
)
message
.
success
(
'复制成功!'
)
}
render
()
{
const
{
data
}
=
this
.
props
;
const
{
planName
,
coverUrl
=
DEFAULT_COVER
}
=
data
;
const
{
shareUrl
,
showImg
,
time
}
=
this
.
state
;
const
{
data
}
=
this
.
props
const
{
planName
,
coverUrl
=
DEFAULT_COVER
}
=
data
const
{
shareUrl
,
showImg
,
time
}
=
this
.
state
return
(
<
Modal
title=
{
'分享培训计划'
}
...
...
@@ -100,58 +101,61 @@ class ShareLiveModal extends React.Component {
visible=
{
true
}
footer=
{
null
}
maskClosable=
{
false
}
closeIcon=
{
<
span
className=
"icon iconfont modal-close-icon"
>

</
span
>
}
className=
"share-live-modal"
onCancel=
{
this
.
props
.
close
}
>
<
div
className=
"left"
>
<
div
id=
"poster"
>
<
div
className=
"store-name"
>
<
span
className=
"text"
>
{
storeName
}
</
span
>
</
div
>
<
div
className=
"course-name-title"
>
邀请你参与培训:
</
div
>
<
div
class=
"live-couse-name"
>
{
planName
}
</
div
>
{
showImg
?
<
img
crossOrigin=
'*'
src=
{
coverUrl
+
`?=${time}`
}
className=
"course-cover"
/>:
<
img
src=
{
coverUrl
+
`?=${time}`
}
className=
"course-cover"
/>
}
<
div
className=
"qrcode-wrap"
>
<
div
className=
"qrcode-wrap__left"
>
<
div
className=
"text"
>
长按识别二维码进入观看
</
div
>
<
img
className=
"finger"
src=
"https://image.xiaomaiketang.com/xm/thpkWDwJsC.png"
/>
closeIcon=
{
<
span
className=
'icon iconfont modal-close-icon'
>

</
span
>
}
className=
'share-live-modal'
onCancel=
{
this
.
props
.
close
}
>
<
div
className=
'left'
>
<
div
id=
'poster'
>
<
div
className=
'store-name'
>
<
span
className=
'text'
>
{
User
.
getStoreName
()
}
</
span
>
</
div
>
<
div
className=
"qrcode-wrap__right"
id=
"qrcodeWrap"
>
<
div
className=
'course-name-title'
>
邀请你参与培训:
</
div
>
<
div
class=
'live-couse-name'
>
{
planName
}
</
div
>
<
Choose
>
<
When
condition=
{
showImg
}
>
<
img
crossOrigin=
'*'
src=
{
coverUrl
+
`?=${time}`
}
className=
'course-cover'
alt=
''
/>
</
When
>
<
Otherwise
>
<
img
src=
{
coverUrl
+
`?=${time}`
}
className=
'course-cover'
alt=
''
/>
</
Otherwise
>
</
Choose
>
<
div
className=
'qrcode-wrap'
>
<
div
className=
'qrcode-wrap__left'
>
<
div
className=
'text'
>
长按识别二维码进入观看
</
div
>
<
img
className=
'finger'
src=
'https://image.xiaomaiketang.com/xm/thpkWDwJsC.png'
alt=
''
/>
</
div
>
<
div
className=
'qrcode-wrap__right'
id=
'qrcodeWrap'
></
div
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
className=
"right"
>
<
div
className=
"share-poster right__item"
>
<
div
className=
"title"
>
① 海报分享
</
div
>
<
div
className=
"sub-title"
>
学员可通过微信扫描海报二维码,查看培训计划
</
div
>
<
div
className=
"content"
onClick=
{
this
.
handleDownloadPoster
}
>
下载海报
</
div
>
</
div
>
<
div
className=
'right'
>
<
div
className=
'share-poster right__item'
>
<
div
className=
'title'
>
① 海报分享
</
div
>
<
div
className=
'sub-title'
>
学员可通过微信扫描海报二维码,查看培训计划
</
div
>
<
div
className=
'content'
onClick=
{
this
.
handleDownloadPoster
}
>
下载海报
</
div
>
</
div
>
<
div
className=
"share-url right__item"
>
<
div
className=
"title"
>
② 链接分享
</
div
>
<
div
className=
"sub-title"
>
学员可通过微信或浏览器打开以下链接,查看培训计划
</
div
>
<
div
className=
"content url-content"
>
<
div
className=
"share-url"
id=
"shareUrl"
>
{
shareUrl
}
</
div
>
<
Button
type=
"primary"
onClick=
{
this
.
handleCopy
}
>
复制
</
Button
>
<
div
className=
'share-url right__item'
>
<
div
className=
'title'
>
② 链接分享
</
div
>
<
div
className=
'sub-title'
>
学员可通过微信或浏览器打开以下链接,查看培训计划
</
div
>
<
div
className=
'content url-content'
>
<
div
className=
'share-url'
id=
'shareUrl'
>
{
shareUrl
}
</
div
>
<
Button
type=
'primary'
onClick=
{
this
.
handleCopy
}
>
复制
</
Button
>
</
div
>
</
div
>
</
div
>
</
div
>
</
Modal
>
)
}
}
export
default
ShareLiveModal
;
export
default
ShareLiveModal
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