Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yanghanwen
/
wanda-vr
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
62f69288
authored
Sep 07, 2020
by
杨翰文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 分享图改成一上来就生成图的模式,增加阴影
parent
628e46d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
19 deletions
+61
-19
libs/html2canvas.js
+0
-0
show.html
+61
-19
No files found.
libs/html2canvas.js
0 → 100644
View file @
62f69288
This source diff could not be displayed because it is too large. You can
view the blob
instead.
show.html
View file @
62f69288
...
...
@@ -8,6 +8,7 @@
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/>
<meta
http-equiv=
"x-ua-compatible"
content=
"IE=edge"
/>
<script
src=
"./libs/helper.js"
></script>
<script
src=
"./libs/html2canvas.js"
></script>
<script
src=
"./libs/vue/vue.js"
></script>
<script
src=
"./libs/axios.min.js"
></script>
<style>
...
...
@@ -190,40 +191,61 @@
z-index
:
1000
;
width
:
100%
;
height
:
100%
;
transform
:
translate
(
-2000px
,
-2000px
);
overflow
:
hidden
;
box-sizing
:
border-box
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.modal-wrap.show
{
transform
:
translate
(
0px
,
0px
);
}
.modal-container
{
position
:
relative
;
}
.poster
{
.poster
,
.share-pic
{
width
:
6.51rem
;
height
:
10.65rem
;
position
:
relative
;
margin
:
0
.56rem
auto
0.25
rem
;
margin
:
0
rem
auto
0
rem
;
position
:
relative
;
}
.share-pic
{
z-index
:
100
;
display
:
block
;
}
.poster
{
position
:
absolute
;
top
:
0
;
left
:
50%
;
transform
:
translate
(
-50%
,
0
);
}
.poster.hide
{
transform
:
translate
(
-2000px
,
-2000px
);
}
.poster-img
{
width
:
100%
;
height
:
100%
;
display
:
block
;
}
.change-poster-btn
{
position
:
absolute
;
right
:
0.32rem
;
top
:
0.3rem
;
top
:
0.3
2
rem
;
width
:
2.08rem
;
height
:
0.67rem
;
background
:
#FFFFFF
;
background
:
rgba
(
255
,
255
,
255
,
.8
)
;
font-size
:
0.3rem
;
font-weight
:
400
;
color
:
#343434
;
;
line-height
:
0.66rem
;
border-radius
:
0.33rem
;
text-align
:
center
;
z-index
:
9
;
z-index
:
101
;
}
.poster-action-box
{
width
:
6.51rem
;
margin
:
0
auto
;
margin
:
0
.4rem
auto
0
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
...
...
@@ -258,6 +280,7 @@
font-weight
:
bold
;
color
:
#FFFFFF
;
line-height
:
0.8rem
;
text-shadow
:
0
0
10px
rgba
(
0
,
0
,
0
,
0.7
);
}
.poster-content__content
{
width
:
4.12rem
;
...
...
@@ -267,18 +290,19 @@
font-weight
:
bold
;
color
:
#FFFFFF
;
line-height
:
0.42rem
;
text-shadow
:
0
0
10px
rgba
(
0
,
0
,
0
,
0.6
);
}
.poster-content__qrcode
{
width
:
1.07rem
;
height
:
1.07rem
;
position
:
absolute
;
left
:
0.4
4
rem
;
bottom
:
0.
36
rem
;
left
:
0.4rem
;
bottom
:
0.
4
rem
;
}
.poster-content__userinfo
{
position
:
absolute
;
right
:
0.47rem
;
bottom
:
0.
32
rem
;
bottom
:
0.
4
rem
;
display
:
flex
;
align-items
:
center
;
...
...
@@ -324,11 +348,13 @@
<div
class=
"bottom"
v-if=
"!showPoster"
>
<img
@
click=
"bindShareEvent"
class=
"bottom__icon"
src=
"./images/show/share.png"
/>
</div>
<div
class=
"modal-wrap"
v-if=
"showPoster"
@
click=
"closeModal"
>
<div
class=
"modal-wrap"
:class=
"{show: showPoster}"
@
click=
"closeModal"
>
<div
class=
"modal-container"
>
<div
class=
"poster"
>
<img
:src=
"navs[activeIdx].share_image"
class=
"poster-img"
/>
<div
@
click
.
stop=
"refreshShareText"
class=
"change-poster-btn"
>
换一换
</div>
<div
@
click
.
stop=
"refreshShareText"
class=
"change-poster-btn"
>
换一换
</div>
<div
class=
"poster"
ref=
"postContent"
>
<img
:src=
"navs[activeIdx].share_image"
class=
"poster-img"
@
load=
"generatePost"
/>
<div
class=
"poster-content"
>
<div
class=
"poster-content__title"
>
{{userInfo.nickname}}的
<br/>
2020幸运打卡地:丹寨
</div>
<div
class=
"poster-content__content"
>
{{shareDesc}}
</div>
...
...
@@ -339,6 +365,7 @@
</div>
</div>
</div>
<img
:src=
"postData"
alt=
""
v-if=
"postData"
class=
"share-pic"
>
<div
class=
"poster-action-box"
>
<div
@
click
.
stop=
"previewImg"
class=
"poster-action-btn"
>
保存图片并发送给好友
</div>
<!-- <div @click.stop="shareToFirends" class="poster-action-btn">分享好友</div>-->
...
...
@@ -368,7 +395,8 @@ var vueInstance = new Vue({
activeIdx
:
0
,
posterUrl
:
''
,
navs
:[],
userInfo
:{}
userInfo
:{},
postData
:
''
}
},
methods
:{
...
...
@@ -426,6 +454,18 @@ var vueInstance = new Vue({
//
// }
},
generatePost
()
{
setTimeout
(()
=>
{
html2canvas
(
this
.
$refs
.
postContent
,
{
allowTaint
:
true
,
useCORS
:
true
,
backgroundColor
:
null
}).
then
((
canvas
)
=>
{
this
.
postData
=
canvas
.
toDataURL
();
});
},
200
)
},
closeModal
(){
this
.
showPoster
=
false
this
.
posterUrl
=
''
...
...
@@ -498,7 +538,7 @@ var vueInstance = new Vue({
return
canvas
.
toDataURL
(
"image/png"
);
},
async
refreshShareText
(){
async
refreshShareText
(
only
){
var
randStr
=
this
.
contentList
[
parseInt
(
Math
.
random
()
*
this
.
contentList
.
length
)].
content
console
.
log
(
randStr
)
...
...
@@ -508,6 +548,7 @@ var vueInstance = new Vue({
// // this.posterUrl = currentInfo.poster
//this.showPoster = true
// showModal()
only
!==
'true'
&&
this
.
generatePost
();
},
async
bindShareEvent
(){
...
...
@@ -528,12 +569,13 @@ var vueInstance = new Vue({
console
.
log
(
this
.
navs
)
this
.
contentList
=
await
$get
(
'/travel/desc'
).
then
(
res
=>
res
.
data
).
catch
(
err
=>
{
throw
err
})
this
.
refreshShareText
()
this
.
refreshShareText
(
true
)
// var idx = getQueryByString(location.href,'idx')
// if(!isNaN(idx) && idx>=0){
// this.setActive(idx)
// }
var
userInfo
=
await
getUserInfo
();
userInfo
.
qrcode
=
(
await
createImgByAsync
(
userInfo
.
qrcode
)).
src
console
.
log
(
userInfo
);
this
.
$set
(
this
,
'userInfo'
,
userInfo
)
var
largeShareName
=
`
${
userInfo
.
nickname
}
的`
...
...
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