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