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 f1884fdc
authored
Nov 08, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
海报缓存&登录样式
1 parent
ed7c1485
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
255 additions
and
87 deletions
components/CrowdfundPoster/CrowdfundPoster.js
components/CrowdfundPoster/CrowdfundPoster.scss
components/CrowdfundPoster/CrowdfundPoster.wxml
login/index/components/Box/Box.scss
login/index/components/Box/Box.wxml
login/index/components/TypeList/TypeList.scss
login/index/index.scss
utils/Draw.js
utils/constantData.js
components/CrowdfundPoster/CrowdfundPoster.js
View file @
f1884fd
...
@@ -9,9 +9,18 @@ Component({
...
@@ -9,9 +9,18 @@ Component({
item
:
{
item
:
{
type
:
Object
,
type
:
Object
,
observer
(
n
)
{
observer
(
n
)
{
console
.
log
(
n
,
'================='
)
this
.
check
(
n
).
then
(
res
=>
{
n
.
posterUrl
&&
this
.
getImageInfo
(
n
)
if
(
res
)
this
.
setData
({
poster
:
res
,
show
:
true
})
else
this
.
begin
()
}).
catch
(()
=>
this
.
begin
())
}
}
},
findKey
:
{
type
:
String
,
value
:
'activityId'
}
}
},
},
...
@@ -24,6 +33,48 @@ Component({
...
@@ -24,6 +33,48 @@ Component({
* 组件的方法列表
* 组件的方法列表
*/
*/
methods
:
{
methods
:
{
begin
()
{
let
{
item
}
=
this
.
data
item
.
posterUrl
&&
this
.
getImageInfo
(
item
)
},
check
(
n
)
{
const
fileList
=
wx
.
$storage
.
get
(
'fileList'
)
||
[],
fn
=
wx
.
getFileSystemManager
(),
{
findKey
}
=
this
.
data
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
fileList
.
length
)
{
fn
.
readdir
({
dirPath
:
wx
.
env
.
USER_DATA_PATH
,
success
({
files
})
{
console
.
log
(
files
,
'文件列表'
)
if
(
files
.
length
<
21
)
{
let
item
=
fileList
.
find
(
e
=>
e
[
findKey
]
===
n
[
findKey
])
if
(
item
)
{
const
poster
=
files
.
find
(
s
=>
s
.
includes
(
item
.
fileId
))
wx
.
hideLoading
()
if
(
poster
)
resolve
(
`
${
wx
.
env
.
USER_DATA_PATH
}
/
${
poster
}
`
)
else
reject
()
}
else
reject
()
}
else
{
wx
.
$storage
.
rm
(
'fileList'
)
files
.
map
(
e
=>
{
fn
.
unlink
({
filePath
:
`
${
wx
.
env
.
USER_DATA_PATH
}
/
${
e
}
`
})
})
reject
()
}
}
})
}
else
reject
()
})
},
getImageInfo
(
n
,
width
,
height
)
{
getImageInfo
(
n
,
width
,
height
)
{
wx
.
$api
.
showLoading
(
'处理中'
)
wx
.
$api
.
showLoading
(
'处理中'
)
let
that
=
this
let
that
=
this
...
@@ -46,19 +97,22 @@ Component({
...
@@ -46,19 +97,22 @@ Component({
let
actualHeight
=
ImgHeight
/
proportion
let
actualHeight
=
ImgHeight
/
proportion
console
.
log
(
actualHeight
)
console
.
log
(
actualHeight
)
n
.
activityName
=
n
.
activityName
.
length
>
12
?
`
${
n
.
activityName
.
substring
(
0
,
12
)}
...`
:
n
.
activityName
n
.
activityName
=
n
.
activityName
.
length
>
12
?
`
${
n
.
activityName
.
substring
(
0
,
12
)}
...`
:
n
.
activityName
const
drawfun
=
new
Draw
(
const
drawfun
=
new
Draw
({
{
width
:
279
,
width
:
279
,
// height: 554
// height: 554
height
:
82
+
actualHeight
height
:
82
+
actualHeight
},
},
this
this
),
),
{
userInfo
}
=
wx
.
$storage
.
get
(),
{
userInfo
}
=
wx
.
$storage
.
get
(),
merchantName
=
userInfo
.
merchantName
.
length
>
12
?
`
${
userInfo
.
merchantName
.
substring
(
0
,
12
)}
...`
:
userInfo
.
merchantName
,
merchantName
=
userInfo
.
merchantName
.
length
>
12
?
`
${
userInfo
.
merchantName
.
substring
(
0
,
12
)}
...`
:
userInfo
.
merchantName
,
res
=
await
drawfun
.
begin
({
imageList
:
[
{
{
findKey
}
=
this
.
data
,
res
=
await
drawfun
.
begin
({
imageList
:
[{
x
:
0
,
x
:
0
,
y
:
0
,
y
:
0
,
width
:
279
,
width
:
279
,
...
@@ -73,8 +127,7 @@ Component({
...
@@ -73,8 +127,7 @@ Component({
url
:
n
.
posterUrl
url
:
n
.
posterUrl
}
}
],
],
textList
:
[
textList
:
[{
{
x
:
12
,
x
:
12
,
y
:
14
,
y
:
14
,
fontSize
:
14
,
fontSize
:
14
,
...
@@ -114,6 +167,13 @@ Component({
...
@@ -114,6 +167,13 @@ Component({
poster
:
res
.
path
,
poster
:
res
.
path
,
show
:
true
show
:
true
})
})
let
fileList
=
wx
.
$storage
.
get
(
'fileList'
)
||
[]
fileList
.
push
({
fileId
:
res
.
fileId
,
path
:
res
.
path
,
[
findKey
]:
n
[
findKey
]
})
wx
.
$storage
.
set
(
'fileList'
,
fileList
)
},
},
download
()
{
download
()
{
const
filePath
=
this
.
data
.
poster
,
const
filePath
=
this
.
data
.
poster
,
...
...
components/CrowdfundPoster/CrowdfundPoster.scss
View file @
f1884fd
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
flex-direction
:
column
;
flex-direction
:
column
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
.bg
{
.bg
{
position
:
absolute
;
position
:
absolute
;
width
:
100%
;
width
:
100%
;
...
@@ -21,28 +20,26 @@
...
@@ -21,28 +20,26 @@
.poster
{
.poster
{
width
:
558rpx
;
width
:
558rpx
;
// height: 60
%;
height
:
68
%
;
height
:
1108rpx
;
//
height: 1108rpx;
overflow
:
scroll
;
overflow
:
scroll
;
border-radius
:
8rpx
;
border-radius
:
8rpx
8rpx
0
0
;
}
}
.btn
{
.btn
{
width
:
320rpx
;
display
:
flex
;
height
:
88rpx
;
align-items
:
center
;
line-height
:
88rpx
;
justify-content
:
center
;
background
:
#3666FE
;
width
:
558rpx
;
// background-image: linear-gradient(-60deg, #556AF5 0%, #7197FF 100%);
height
:
90rpx
;
border-radius
:
16rpx
;
background
:
#F7F8FA
;
border-radius
:
0
0
12rpx
12rpx
;
font-weight
:
500
;
font-weight
:
500
;
font-size
:
32rpx
;
font-size
:
32rpx
;
color
:
#FFFFFF
;
color
:
#3666FE
;
text-align
:
center
;
margin-top
:
32rpx
;
}
}
.tips
{
.tips
{
margin
:
16
rpx
80rpx
0
;
margin
:
40
rpx
80rpx
0
;
font-size
:
24rpx
;
font-size
:
24rpx
;
color
:
#FFFFFF
;
color
:
#FFFFFF
;
line-height
:
36rpx
;
line-height
:
36rpx
;
...
...
components/CrowdfundPoster/CrowdfundPoster.wxml
View file @
f1884fd
<block wx:if="{{show}}">
<block wx:if="{{show}}">
<!-- catchtouchmove="noScroll" -->
<!-- catchtouchmove="noScroll" -->
<view class="layout">
<view class="layout">
<view class="bg" bindtap="hide
" />
<view class="bg" bindtap="hide" catchtouchmove="noScroll
" />
<view class="poster">
<view class="poster">
<!-- <scroll-view scroll-x="false" scroll-y="true" style="height: 100%"> -->
<!-- <scroll-view scroll-x="false" scroll-y="true" style="height: 100%"> -->
<image src="{{poster}}" mode="widthFix"
/>
<image src="{{poster}}" mode="widthFix" show-menu-by-longpress
/>
<!-- </scroll-view> -->
<!-- </scroll-view> -->
</view>
</view>
<view class="btn" bindtap="download">保存至相册</view>
<view class="btn">
<view class="tips">提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。</view>
长按图片转发
</view>
<view class="tips">提示:这是您的专属活动海报,请长按转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。</view>
</view>
</view>
</block>
</block>
<authorize
<!-- <authorize scopeType="writePhotosAlbum" bindfail="authFail" show="{{showAuth}}" isShowCheck="{{false}}" id="auth" /> -->
scopeType="writePhotosAlbum"
bindfail="authFail"
show="{{showAuth}}"
isShowCheck="{{false}}"
id="auth" />
\ No newline at end of file
\ No newline at end of file
login/index/components/Box/Box.scss
View file @
f1884fd
/* login/index/components/LoginBox.wxss */
/* login/index/components/LoginBox.wxss */
.box
{
.wx
{
// height: 800rpx;
height
:
922rpx
;
height
:
750rpx
;
.title
{
font-weight
:
600
;
font-size
:
60rpx
;
color
:
#323436
;
padding
:
216rpx
0
24rpx
;
}
.opacity-view
{
.subtitle
{
animation
:
opacity-view
.5s
forwards
;
font-size
:
44rpx
;
color
:
#323436
;
margin-bottom
:
120rpx
;
}
}
.img
{
.img
{
width
:
472rpx
;
width
:
378rpx
;
height
:
458rpx
;
height
:
364rpx
;
position
:
absolute
;
display
:
block
;
left
:
151rpx
;
margin
:
0
auto
;
// top: 264rpx;
top
:
214rpx
;
}
}
}
.opacity-view
{
animation
:
opacity-view
.5s
forwards
;
}
.box
{
// height: 800rpx;
height
:
750rpx
;
.input-box
{
.input-box
{
width
:
540rpx
;
width
:
540rpx
;
// padding-top: 352rpx;
// padding-top: 352rpx;
...
@@ -57,6 +72,7 @@
...
@@ -57,6 +72,7 @@
padding
:
0
;
padding
:
0
;
text-align
:
right
;
text-align
:
right
;
transition
:
all
.25s
;
transition
:
all
.25s
;
&
[
disabled
]
:not
([
type
])
{
&
[
disabled
]
:not
([
type
])
{
color
:
#CCCED1
;
color
:
#CCCED1
;
}
}
...
...
login/index/components/Box/Box.wxml
View file @
f1884fd
<view class="box">
<block wx:if="{{loginType == 0}}">
<block wx:if="{{loginType == 0}}">
<view class="wx opacity-view">
<image webp class="img opacity-view" src="{{IMGURL}}login/login.webp" />
<view class="title">
</block>
您好
<block wx:else>
</view>
<view class="subtitle">
欢迎登录生意助手
</view>
<image webp class="img" src="{{IMGURL}}login/login-2.webp" />
</view>
</block>
<block wx:else>
<view class="box">
<view class="input-box opacity-view">
<view class="input-box opacity-view">
<view class="title">{{loginType == 1?'手机号':'账号'}}登录</view>
<view class="title">{{loginType == 1?'手机号':'账号'}}登录</view>
<block wx:if="{{loginType == 1}}">
<block wx:if="{{loginType == 1}}">
...
@@ -33,8 +41,8 @@
...
@@ -33,8 +41,8 @@
</view>
</view>
</block>
</block>
</view>
</view>
</
block
>
</
view
>
</
view
>
</
block
>
<block wx:if="{{loginType == 0}}">
<block wx:if="{{loginType == 0}}">
<button class="button" disabled="{{disabled}}" hover-class="btn-hover" open-type="getPhoneNumber" bindgetphonenumber="wxLogin" loading="{{loading}}">微信登录</button>
<button class="button" disabled="{{disabled}}" hover-class="btn-hover" open-type="getPhoneNumber" bindgetphonenumber="wxLogin" loading="{{loading}}">微信登录</button>
</block>
</block>
...
...
login/index/components/TypeList/TypeList.scss
View file @
f1884fd
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
flex-direction
:
column
;
flex-direction
:
column
;
width
:
100rpx
;
width
:
100rpx
;
animation
:
btn-move
.25s
forwards
;
animation
:
btn-move
.25s
forwards
;
margin
:
0
5
9rpx
;
margin
:
0
7
9rpx
;
.icon
{
.icon
{
width
:
68rpx
;
width
:
68rpx
;
height
:
68rpx
;
height
:
68rpx
;
...
...
login/index/index.scss
View file @
f1884fd
.layout
{
.layout
{
position
:
relative
;
position
:
relative
;
padding
:
0
32
rpx
;
padding
:
0
80
rpx
;
font-size
:
24rpx
;
font-size
:
24rpx
;
color
:
#8A8C90
;
color
:
#8A8C90
;
&
:
:
before
{
&
:
:
after
{
content
:
''
;
content
:
''
;
width
:
100%
;
width
:
100%
;
height
:
486
rpx
;
height
:
264
rpx
;
background
:
url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg.webp')
no-repeat
;
background
:
url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg
-top
.webp')
no-repeat
;
background-size
:
100%
486
rpx
;
background-size
:
100%
264
rpx
;
position
:
absolute
;
position
:
fixed
;
left
:
0
;
left
:
0
;
top
:
0
;
top
:
0
;
z-index
:
-1
;
z-index
:
-1
;
}
}
&
:
:
after
{
content
:
''
;
width
:
100%
;
height
:
472rpx
;
background
:
url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg-bottom.webp')
no-repeat
;
background-size
:
100%
472rpx
;
position
:
fixed
;
left
:
0
;
bottom
:
0
;
z-index
:
-1
;
}
}
}
@keyframes
opacity-view
{
@keyframes
opacity-view
{
0
%
{
0
%
{
...
@@ -31,7 +41,7 @@
...
@@ -31,7 +41,7 @@
width
:
100%
!
important
;
width
:
100%
!
important
;
height
:
88rpx
;
height
:
88rpx
;
background
:
var
(
--
btnColor
);
background
:
var
(
--
btnColor
);
border-radius
:
8
rpx
;
border-radius
:
16
rpx
;
font-weight
:
500
;
font-weight
:
500
;
font-size
:
28rpx
;
font-size
:
28rpx
;
color
:
#FFFFFF
;
color
:
#FFFFFF
;
...
...
utils/Draw.js
View file @
f1884fd
...
@@ -34,7 +34,14 @@ class Draw {
...
@@ -34,7 +34,14 @@ class Draw {
async
drawImages
(
imageParams
,
callback
)
{
async
drawImages
(
imageParams
,
callback
)
{
this
[
_ctx_
].
beginPath
()
this
[
_ctx_
].
beginPath
()
this
[
_ctx_
].
save
()
this
[
_ctx_
].
save
()
let
{
borderRadius
,
height
,
width
,
url
,
x
,
y
}
=
imageParams
let
{
borderRadius
,
height
,
width
,
url
,
x
,
y
}
=
imageParams
height
=
this
.
toRpx
(
height
)
height
=
this
.
toRpx
(
height
)
width
=
this
.
toRpx
(
width
)
width
=
this
.
toRpx
(
width
)
x
=
this
.
toRpx
(
x
)
x
=
this
.
toRpx
(
x
)
...
@@ -76,7 +83,13 @@ class Draw {
...
@@ -76,7 +83,13 @@ class Draw {
return
this
[
_ctx_
].
measureText
(
text
).
width
return
this
[
_ctx_
].
measureText
(
text
).
width
}
}
// 画块形状
// 画块形状
drawFill
({
x
,
y
,
width
,
height
,
color
})
{
drawFill
({
x
,
y
,
width
,
height
,
color
})
{
height
=
this
.
toRpx
(
height
)
height
=
this
.
toRpx
(
height
)
width
=
this
.
toRpx
(
width
)
width
=
this
.
toRpx
(
width
)
x
=
this
.
toRpx
(
x
)
x
=
this
.
toRpx
(
x
)
...
@@ -89,7 +102,24 @@ class Draw {
...
@@ -89,7 +102,24 @@ class Draw {
this
[
_ctx_
].
save
()
this
[
_ctx_
].
save
()
}
}
drawText
(
textParams
)
{
drawText
(
textParams
)
{
let
{
textDecoration
,
textBaseline
,
lineHeight
,
fontWeight
,
textAlign
,
textWidth
,
maxWidth
,
fontSize
,
lastFont
,
opacity
,
lineNum
,
width
,
color
,
text
,
x
,
y
}
=
textParams
,
let
{
textDecoration
,
textBaseline
,
lineHeight
,
fontWeight
,
textAlign
,
textWidth
,
maxWidth
,
fontSize
,
lastFont
,
opacity
,
lineNum
,
width
,
color
,
text
,
x
,
y
}
=
textParams
,
font
=
this
[
_ctx_
].
font
.
split
(
'px'
)[
1
]
font
=
this
[
_ctx_
].
font
.
split
(
'px'
)[
1
]
textAlign
=
textAlign
||
'left'
textAlign
=
textAlign
||
'left'
textBaseline
=
textBaseline
||
'normal'
textBaseline
=
textBaseline
||
'normal'
...
@@ -189,9 +219,7 @@ class Draw {
...
@@ -189,9 +219,7 @@ class Draw {
})
})
}
}
})
})
}
else
{
}
else
drawOneLineText
()
drawOneLineText
()
}
}
else
drawOneLineText
()
}
else
drawOneLineText
()
if
(
textParams
.
border
)
if
(
textParams
.
border
)
this
.
drawBorder
({
this
.
drawBorder
({
...
@@ -205,7 +233,17 @@ class Draw {
...
@@ -205,7 +233,17 @@ class Draw {
this
[
_ctx_
].
stroke
()
this
[
_ctx_
].
stroke
()
}
}
drawBorder
(
params
)
{
drawBorder
(
params
)
{
let
{
x
,
y
,
text
,
color
,
width
,
radius
,
opacity
,
padding
,
fontSize
}
=
params
,
let
{
x
,
y
,
text
,
color
,
width
,
radius
,
opacity
,
padding
,
fontSize
}
=
params
,
paddingX
=
0
,
paddingX
=
0
,
paddingY
=
0
paddingY
=
0
if
(
padding
&&
padding
.
length
)
{
if
(
padding
&&
padding
.
length
)
{
...
@@ -217,8 +255,7 @@ class Draw {
...
@@ -217,8 +255,7 @@ class Draw {
endX
=
this
.
toRpx
(
x
)
+
this
.
getTextWidth
(
text
)
+
paddingX
,
endX
=
this
.
toRpx
(
x
)
+
this
.
getTextWidth
(
text
)
+
paddingX
,
startY
=
this
.
toRpx
(
y
)
-
paddingY
,
startY
=
this
.
toRpx
(
y
)
-
paddingY
,
endY
=
this
.
toRpx
(
y
+
fontSize
)
+
paddingY
/
2
,
endY
=
this
.
toRpx
(
y
+
fontSize
)
+
paddingY
/
2
,
arr
=
[
arr
=
[{
{
x
:
startX
,
x
:
startX
,
y
:
startY
,
y
:
startY
,
width
:
endX
width
:
endX
...
@@ -245,8 +282,7 @@ class Draw {
...
@@ -245,8 +282,7 @@ class Draw {
this
[
_ctx_
].
lineWidth
=
width
||
this
.
toRpx
(
1
)
this
[
_ctx_
].
lineWidth
=
width
||
this
.
toRpx
(
1
)
if
(
radius
)
{
if
(
radius
)
{
radius
=
this
.
toRpx
(
radius
)
radius
=
this
.
toRpx
(
radius
)
let
arcArr
=
[
let
arcArr
=
[{
{
moveTo
:
[
startX
,
startY
+
radius
],
moveTo
:
[
startX
,
startY
+
radius
],
arcTo
:
[
startX
,
startY
,
startX
+
radius
,
startY
]
arcTo
:
[
startX
,
startY
,
startX
+
radius
,
startY
]
},
},
...
@@ -291,7 +327,16 @@ class Draw {
...
@@ -291,7 +327,16 @@ class Draw {
}
}
drawLine
(
lineParams
,
callback
)
{
drawLine
(
lineParams
,
callback
)
{
this
[
_ctx_
].
beginPath
()
this
[
_ctx_
].
beginPath
()
let
{
noTransition
,
opacity
,
startX
,
startY
,
width
,
color
,
endX
,
endY
}
=
lineParams
let
{
noTransition
,
opacity
,
startX
,
startY
,
width
,
color
,
endX
,
endY
}
=
lineParams
if
(
!
noTransition
)
{
if
(
!
noTransition
)
{
startX
=
this
.
toRpx
(
startX
)
startX
=
this
.
toRpx
(
startX
)
startY
=
this
.
toRpx
(
startY
)
startY
=
this
.
toRpx
(
startY
)
...
@@ -310,7 +355,12 @@ class Draw {
...
@@ -310,7 +355,12 @@ class Draw {
if
(
callback
)
callback
()
if
(
callback
)
callback
()
}
}
setLineY
=
params
=>
{
setLineY
=
params
=>
{
let
{
textDecoration
,
textBaseline
,
fontSize
,
y
}
=
params
let
{
textDecoration
,
textBaseline
,
fontSize
,
y
}
=
params
let
type
=
{
let
type
=
{
underline
:
{
underline
:
{
top
:
y
+
fontSize
,
top
:
y
+
fontSize
,
...
@@ -333,7 +383,11 @@ class Draw {
...
@@ -333,7 +383,11 @@ class Draw {
}
}
return
type
[
textDecoration
][
textBaseline
]
return
type
[
textDecoration
][
textBaseline
]
}
}
setLineX
({
textAlign
,
text
,
x
})
{
setLineX
({
textAlign
,
text
,
x
})
{
let
textWidth
=
this
.
getTextWidth
(
text
)
let
textWidth
=
this
.
getTextWidth
(
text
)
let
type
=
{
let
type
=
{
left
:
x
,
left
:
x
,
...
@@ -342,7 +396,13 @@ class Draw {
...
@@ -342,7 +396,13 @@ class Draw {
}
}
return
type
[
textAlign
]
return
type
[
textAlign
]
}
}
drawRadiusRect
({
borderRadius
,
height
,
width
,
x
,
y
},
callBack
)
{
drawRadiusRect
({
borderRadius
,
height
,
width
,
x
,
y
},
callBack
)
{
let
radius
=
typeof
borderRadius
===
'string'
?
((
Number
(
borderRadius
.
split
(
'%'
)[
0
])
/
100
)
*
width
)
/
2
:
borderRadius
/
2
let
radius
=
typeof
borderRadius
===
'string'
?
((
Number
(
borderRadius
.
split
(
'%'
)[
0
])
/
100
)
*
width
)
/
2
:
borderRadius
/
2
radius
=
radius
||
0
radius
=
radius
||
0
this
[
_ctx_
].
beginPath
()
this
[
_ctx_
].
beginPath
()
...
@@ -353,7 +413,12 @@ class Draw {
...
@@ -353,7 +413,12 @@ class Draw {
}
}
if
(
callBack
)
callBack
()
if
(
callBack
)
callBack
()
}
}
getFontWidth
({
textAlign
,
fontSize
,
text
,
x
})
{
getFontWidth
({
textAlign
,
fontSize
,
text
,
x
})
{
let
type
=
{
let
type
=
{
left
:
x
,
left
:
x
,
center
:
x
-
(
fontSize
*
text
.
length
)
/
2
,
center
:
x
-
(
fontSize
*
text
.
length
)
/
2
,
...
@@ -363,7 +428,12 @@ class Draw {
...
@@ -363,7 +428,12 @@ class Draw {
}
}
drawDecoration
(
params
)
{
drawDecoration
(
params
)
{
let
{
newText
,
opacity
,
y
,
x
}
=
params
let
{
newText
,
opacity
,
y
,
x
}
=
params
let
lineX
=
x
let
lineX
=
x
let
lineY
=
y
let
lineY
=
y
lineX
=
this
.
setLineX
(
params
)
lineX
=
this
.
setLineX
(
params
)
...
@@ -376,16 +446,20 @@ class Draw {
...
@@ -376,16 +446,20 @@ class Draw {
let
url
=
this
[
_canvas_
].
toDataURL
(
'image/png'
)
let
url
=
this
[
_canvas_
].
toDataURL
(
'image/png'
)
const
base64src
=
function
(
base64data
)
{
const
base64src
=
function
(
base64data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
[
a
,
format
,
bodyData
]
=
/data:image
\/(\w
+
)
;base64,
(
.*
)
/
.
exec
(
base64data
)
||
[]
const
[,
format
,
bodyData
]
=
/data:image
\/(\w
+
)
;base64,
(
.*
)
/
.
exec
(
base64data
)
||
[]
if
(
!
format
)
reject
(
new
Error
(
'ERROR_BASE64SRC_PARSE'
))
if
(
!
format
)
reject
(
new
Error
(
'ERROR_BASE64SRC_PARSE'
))
const
filePath
=
`
${
wx
.
env
.
USER_DATA_PATH
}
/tmp_base64src
${
Date
.
now
()}
.
${
format
}
`
const
fileId
=
Date
.
now
()
const
filePath
=
`
${
wx
.
env
.
USER_DATA_PATH
}
/tmp_base64src_
${
fileId
}
.
${
format
}
`
const
buffer
=
wx
.
base64ToArrayBuffer
(
bodyData
)
const
buffer
=
wx
.
base64ToArrayBuffer
(
bodyData
)
wx
.
getFileSystemManager
().
writeFile
({
wx
.
getFileSystemManager
().
writeFile
({
filePath
,
filePath
,
data
:
buffer
,
data
:
buffer
,
encoding
:
'binary'
,
encoding
:
'binary'
,
success
()
{
success
()
{
resolve
(
filePath
)
resolve
({
filePath
,
fileId
})
},
},
fail
()
{
fail
()
{
reject
(
new
Error
(
'ERROR_BASE64SRC_WRITE'
))
reject
(
new
Error
(
'ERROR_BASE64SRC_WRITE'
))
...
@@ -431,11 +505,17 @@ const checkTextDecoration = textDecoration => {
...
@@ -431,11 +505,17 @@ const checkTextDecoration = textDecoration => {
}
}
/**网络图片转成本地资源 */
/**网络图片转成本地资源 */
const
createLocalImg
=
(
url
,
callBack
)
=>
{
const
createLocalImg
=
({
filePath
,
fileId
},
callBack
)
=>
{
wx
.
getImageInfo
({
wx
.
getImageInfo
({
src
:
url
,
src
:
filePath
,
success
(
res
)
{
success
(
res
)
{
callBack
(
res
)
callBack
({
...
res
,
fileId
})
},
},
fail
()
{
fail
()
{
wx
.
showToast
({
wx
.
showToast
({
...
...
utils/constantData.js
View file @
f1884fd
...
@@ -16,7 +16,8 @@ export const STORAGE_OBJECTkEY = {
...
@@ -16,7 +16,8 @@ export const STORAGE_OBJECTkEY = {
firstLogin
:
'firstLogin'
,
firstLogin
:
'firstLogin'
,
authphone
:
'authphone'
,
authphone
:
'authphone'
,
posterTimer
:
'posterTimer'
,
posterTimer
:
'posterTimer'
,
disLikeRecordFlag
:
'disLikeRecordFlag'
disLikeRecordFlag
:
'disLikeRecordFlag'
,
fileList
:
'fileList'
}
}
export
const
IMG_VERSION
=
()
=>
{
export
const
IMG_VERSION
=
()
=>
{
...
...
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