Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e1b64306
authored
Oct 27, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改画布&生成海报
1 parent
cacdcfc2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
44 deletions
components/Authorize/Authorize.js
packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.js
packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.json
packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.wxml
utils/Draw.js
components/Authorize/Authorize.js
View file @
e1b6430
...
@@ -52,7 +52,7 @@ Component({
...
@@ -52,7 +52,7 @@ Component({
/**
/**
* 禁止滑动
* 禁止滑动
*/
*/
noScroll
:
wx
.
$util
.
noScroll
()
,
noScroll
(){}
,
cancel
(
e
)
{
cancel
(
e
)
{
let
{
confirm
}
=
e
.
currentTarget
.
dataset
let
{
confirm
}
=
e
.
currentTarget
.
dataset
let
{
buttonType
,
title
}
=
this
.
data
let
{
buttonType
,
title
}
=
this
.
data
...
...
packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.js
View file @
e1b6430
...
@@ -44,13 +44,13 @@ Component({
...
@@ -44,13 +44,13 @@ Component({
height
:
66
,
height
:
66
,
url
:
'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png'
url
:
'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png'
},
},
{
//
{
x
:
16
,
//
x: 16,
y
:
70
,
//
y: 70,
width
:
247
,
//
width: 247,
height
:
472
,
//
height: 472,
url
:
n
.
posterUrl
//
url: n.posterUrl
}
//
}
],
],
textList
:
[{
textList
:
[{
x
:
12
,
x
:
12
,
...
@@ -71,17 +71,15 @@ Component({
...
@@ -71,17 +71,15 @@ Component({
},
},
{
{
x
:
14
+
drawfun
.
getTextWidth
(
n
.
activityName
,
14
)
+
9
,
x
:
14
+
drawfun
.
getTextWidth
(
n
.
activityName
,
14
)
+
9
,
y
:
3
7
,
y
:
3
9
,
fontSize
:
10
,
fontSize
:
10
,
color
:
'#4466F0'
,
color
:
'#4466F0'
,
text
:
'众筹'
,
text
:
'众筹'
,
textBaseline
:
'top'
,
border
:
{
border
:
{
width
:
1
,
width
:
1
,
color
:
'#
4466F0
'
,
color
:
'#
8FA5FF
'
,
radius
:
2
,
radius
:
2
,
padding
:
[
2
,
5
],
padding
:
[
5
,
5
]
opacity
:
0.5
}
}
}
}
],
],
...
@@ -89,22 +87,34 @@ Component({
...
@@ -89,22 +87,34 @@ Component({
console
.
log
(
res
)
console
.
log
(
res
)
wx
.
hideLoading
()
wx
.
hideLoading
()
this
.
setData
({
this
.
setData
({
poster
:
res
.
path
,
poster
:
res
.
path
show
:
true
})
})
},
},
download
()
{
download
()
{
const
filePath
=
this
.
data
.
poster
const
filePath
=
this
.
data
.
poster
,
_this
=
this
wx
.
saveImageToPhotosAlbum
({
wx
.
saveImageToPhotosAlbum
({
filePath
filePath
,
})
success
(){
wx
.
$api
.
showToast
(
'保存成功'
)
},
fail
(
err
)
{
const
auth
=
_this
.
selectComponent
(
'#auth'
)
auth
.
check
()
}
}
)
},
},
hide
()
{
hide
()
{
this
.
setData
({
this
.
setData
({
show
:
false
,
poster
:
''
poster
:
''
})
})
},
},
noScroll
()
{}
noScroll
()
{},
authFail
(
e
)
{
this
.
setData
({
showAuth
:
true
})
}
}
}
})
})
\ No newline at end of file
\ No newline at end of file
packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.json
View file @
e1b6430
{
{
"component"
:
true
,
"component"
:
true
,
"usingComponents"
:
{}
"usingComponents"
:
{
"authorize"
:
"/components/Authorize/Authorize"
}
}
}
\ No newline at end of file
\ No newline at end of file
packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.wxml
View file @
e1b6430
<block wx:if="{{
show
}}">
<block wx:if="{{
poster
}}">
<view class="layout" catchtouchmove="noScroll">
<view class="layout" catchtouchmove="noScroll">
<view class="bg" bindtap="hide"></view>
<view class="bg" bindtap="hide"></view>
<image src="{{poster}}" class="poster" mode="aspectFit"></image>
<image src="{{poster}}" class="poster" mode="aspectFit"></image>
...
@@ -7,4 +7,5 @@
...
@@ -7,4 +7,5 @@
提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。
提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。
</view>
</view>
</view>
</view>
</block>
\ No newline at end of file
\ No newline at end of file
</block>
<authorize scopeType="writePhotosAlbum" bindfail="authFail" show="{{showAuth}}" id="auth"></authorize>
\ No newline at end of file
\ No newline at end of file
utils/Draw.js
View file @
e1b6430
...
@@ -140,18 +140,10 @@ class Draw {
...
@@ -140,18 +140,10 @@ class Draw {
this
[
_ctx_
].
globalAlpha
=
opacity
this
[
_ctx_
].
globalAlpha
=
opacity
this
[
_ctx_
].
font
=
`
${
fontWeight
||
400
}
${
fontSize
}
px
${
font
}
`
this
[
_ctx_
].
font
=
`
${
fontWeight
||
400
}
${
fontSize
}
px
${
font
}
`
this
[
_ctx_
].
fillStyle
=
color
||
'#000'
this
[
_ctx_
].
fillStyle
=
color
||
'#000'
this
[
_ctx_
].
strokeStyle
=
color
||
'#000'
this
[
_ctx_
].
textBaseline
=
textBaseline
this
[
_ctx_
].
textBaseline
=
textBaseline
this
[
_ctx_
].
textAlign
=
textAlign
this
[
_ctx_
].
textAlign
=
textAlign
this
[
_ctx_
].
lineWidth
=
this
.
toRpx
(
2
)
this
[
_ctx_
].
lineWidth
=
this
.
toRpx
(
2
)
let
text_width
=
this
.
getTextWidth
(
text
)
let
text_width
=
this
.
getTextWidth
(
text
)
if
(
textParams
.
border
)
this
.
drawBorder
({
text
,
x
:
textParams
.
x
,
y
:
textParams
.
y
,
fontSize
:
textParams
.
fontSize
||
12
,
...
textParams
.
border
})
const
drawOneLineText
=
()
=>
{
const
drawOneLineText
=
()
=>
{
let
textArr
=
text
.
toString
().
split
(
''
),
let
textArr
=
text
.
toString
().
split
(
''
),
newText
=
''
,
newText
=
''
,
...
@@ -230,6 +222,14 @@ class Draw {
...
@@ -230,6 +222,14 @@ class Draw {
drawOneLineText
()
drawOneLineText
()
}
}
}
else
drawOneLineText
()
}
else
drawOneLineText
()
if
(
textParams
.
border
)
this
.
drawBorder
({
text
,
x
:
textParams
.
x
,
y
:
textParams
.
y
,
fontSize
:
textParams
.
fontSize
||
12
,
...
textParams
.
border
})
this
[
_ctx_
].
stroke
()
this
[
_ctx_
].
stroke
()
}
}
drawBorder
(
params
)
{
drawBorder
(
params
)
{
...
@@ -243,18 +243,91 @@ class Draw {
...
@@ -243,18 +243,91 @@ class Draw {
opacity
,
opacity
,
padding
,
padding
,
fontSize
fontSize
}
=
params
}
=
params
,
console
.
log
(
params
)
paddingX
=
0
,
let
topX
,
topY
,
rightX
,
rightY
,
bottomX
,
bottomY
,
leftX
,
leftY
,
paddingX
,
paddingY
paddingY
=
0
// if(padding && padding.length>1)
if
(
padding
&&
padding
.
length
)
{
paddingX
=
this
.
toRpx
(
padding
[
0
])
paddingY
=
this
.
toRpx
(
padding
[
0
])
if
(
padding
.
length
>
1
)
paddingX
=
this
.
toRpx
(
padding
[
1
])
}
let
startX
=
this
.
toRpx
(
x
)
-
paddingX
,
endX
=
this
.
toRpx
(
x
)
+
this
.
getTextWidth
(
text
)
+
paddingX
,
startY
=
this
.
toRpx
(
y
)
-
paddingY
,
endY
=
this
.
toRpx
(
y
+
fontSize
)
+
paddingY
/
2
,
arr
=
[{
x
:
startX
,
y
:
startY
,
width
:
endX
},
{
x
:
endX
,
y
:
startY
,
height
:
endY
},
{
x
:
startX
,
y
:
endY
,
width
:
endX
},
{
x
:
startX
,
y
:
startY
,
height
:
endY
}
]
console
.
log
(
this
.
toRpx
(
y
)
,
paddingY
)
this
[
_ctx_
].
beginPath
()
this
[
_ctx_
].
globalAlpha
=
typeof
opacity
===
'number'
?
opacity
:
1
this
[
_ctx_
].
lineWidth
=
width
||
this
.
toRpx
(
1
)
if
(
radius
)
{
if
(
radius
)
{
radius
=
this
.
toRpx
(
radius
)
let
arcArr
=
[{
moveTo
:
[
startX
,
startY
+
radius
],
arcTo
:
[
startX
,
startY
,
startX
+
radius
,
startY
],
},
{
moveTo
:
[
endX
-
radius
,
startY
],
arcTo
:
[
endX
,
startY
,
endX
,
startY
+
radius
],
},
{
moveTo
:
[
startX
,
endY
-
radius
],
arcTo
:
[
startX
,
endY
,
startX
+
radius
,
endY
],
},
{
moveTo
:
[
endX
,
endY
-
radius
],
arcTo
:
[
endX
,
endY
,
endX
-
radius
,
endY
],
}
]
arr
.
map
((
e
,
index
)
=>
{
if
(
index
==
0
||
index
==
2
)
{
e
.
x
+=
radius
e
.
width
-=
radius
}
else
{
e
.
y
+=
radius
e
.
height
-=
radius
}
})
arcArr
.
map
((
e
,
index
)
=>
{
this
[
_ctx_
].
moveTo
(...
e
.
moveTo
)
this
[
_ctx_
].
arcTo
(...
e
.
arcTo
,
radius
)
this
[
_ctx_
].
stroke
()
this
[
_ctx_
].
restore
()
this
[
_ctx_
].
save
()
})
}
}
arr
.
map
((
e
,
index
)
=>
{
this
[
_ctx_
].
moveTo
(
e
.
x
,
e
.
y
)
this
[
_ctx_
].
lineTo
(
e
.
width
?
e
.
width
:
e
.
x
,
e
.
height
?
e
.
height
:
e
.
y
)
this
[
_ctx_
].
stroke
()
this
[
_ctx_
].
restore
()
this
[
_ctx_
].
strokeStyle
=
color
||
'#000'
this
[
_ctx_
].
save
()
})
}
}
drawLine
(
lineParams
,
callback
)
{
drawLine
(
lineParams
,
callback
)
{
this
[
_ctx_
].
beginPath
()
this
[
_ctx_
].
beginPath
()
let
{
let
{
noTransition
,
opacity
,
opacity
,
startX
,
startX
,
startY
,
startY
,
...
@@ -263,18 +336,20 @@ class Draw {
...
@@ -263,18 +336,20 @@ class Draw {
endX
,
endX
,
endY
endY
}
=
lineParams
}
=
lineParams
startX
=
this
.
toRpx
(
startX
)
if
(
!
noTransition
)
{
startY
=
this
.
toRpx
(
startY
)
startX
=
this
.
toRpx
(
startX
)
width
=
this
.
toRpx
(
width
)
startY
=
this
.
toRpx
(
startY
)
endX
=
this
.
toRpx
(
endX
)
width
=
this
.
toRpx
(
width
)
endY
=
this
.
toRpx
(
endY
)
endX
=
this
.
toRpx
(
endX
)
endY
=
this
.
toRpx
(
endY
)
}
this
[
_ctx_
].
globalAlpha
=
typeof
opacity
===
'number'
?
opacity
:
1
this
[
_ctx_
].
globalAlpha
=
typeof
opacity
===
'number'
?
opacity
:
1
this
[
_ctx_
].
strokeStyle
=
color
||
'#000'
this
[
_ctx_
].
lineWidth
=
width
||
this
.
toRpx
(
1
)
this
[
_ctx_
].
lineWidth
=
width
||
this
.
toRpx
(
1
)
this
[
_ctx_
].
moveTo
(
startX
,
startY
)
this
[
_ctx_
].
moveTo
(
startX
,
startY
)
this
[
_ctx_
].
lineTo
(
endX
,
endY
)
this
[
_ctx_
].
lineTo
(
endX
,
endY
)
this
[
_ctx_
].
stroke
()
this
[
_ctx_
].
stroke
()
this
[
_ctx_
].
restore
()
this
[
_ctx_
].
restore
()
this
[
_ctx_
].
strokeStyle
=
color
||
'#000'
this
[
_ctx_
].
save
()
this
[
_ctx_
].
save
()
if
(
callback
)
callback
()
if
(
callback
)
callback
()
}
}
...
@@ -412,7 +487,7 @@ class Draw {
...
@@ -412,7 +487,7 @@ class Draw {
if
(
index
==
data
.
imageList
.
length
-
1
)
drawFun
()
if
(
index
==
data
.
imageList
.
length
-
1
)
drawFun
()
}
}
else
drawFun
()
else
drawFun
()
}
}
else
drawFun
()
})
})
}
}
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment