Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-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 c76098d7
authored
Oct 27, 2022
by
zhangxw
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
需求变更
1 parent
51a0b8b4
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
213 additions
and
123 deletions
api/activityApi/ActivityApi.js
components/sharePopup/sharePopup.js
components/sharePopup/sharePopup.scss
components/sharePopup/sharePopup.wxml
packageActivity/pages/taskDetail/taskDetail.js
packageActivity/pages/taskDetail/taskDetail.scss
packageActivity/pages/taskDetail/taskDetail.wxml
pages/tab/index/components/activeBox/activeBox.js
pages/tab/index/index.wxml
utils/Draw.js
utils/request/environment.js
api/activityApi/ActivityApi.js
View file @
c76098d
...
@@ -76,7 +76,7 @@ class ActivityApi {
...
@@ -76,7 +76,7 @@ class ActivityApi {
// 获取当前活动的海报
// 获取当前活动的海报
getActivityPosters
(
data
)
{
getActivityPosters
(
data
)
{
return
api
.
post
({
return
api
.
post
({
method
:
`scrm.api.assistant.
activity
.poster`
,
method
:
`scrm.api.assistant.
crowdFunding
.poster`
,
...
data
...
data
})
})
}
}
...
...
components/sharePopup/sharePopup.js
View file @
c76098d
// components/sharePopup/sharePopup.js
// components/sharePopup/sharePopup.js
import
{
imgUrlMixin
}
from
'~/mixins/index'
import
{
imgUrlMixin
}
from
'~/mixins/index'
import
index_const
from
"~/pages/tab/index/index_const"
import
index_const
from
"~/pages/tab/index/index_const"
import
{
IMG_URL
}
from
'~/utils/constantData'
import
Draw
from
'~/utils/Draw'
import
Draw
from
'~/utils/Draw'
Component
({
Component
({
/**
/**
...
@@ -8,24 +9,6 @@ Component({
...
@@ -8,24 +9,6 @@ Component({
*/
*/
behaviors
:
[
imgUrlMixin
],
behaviors
:
[
imgUrlMixin
],
properties
:
{
properties
:
{
show
:
{
type
:
Boolean
,
observer
(
value
)
{
if
(
value
)
{
wx
.
$util
.
getViewInfo
(
'.user-box'
,
res
=>
{
this
.
setData
({
boxImageHeight
:
res
.
height
,
})
},
this
)
// 计算弹窗图片区域最大高度
wx
.
$util
.
getViewInfo
(
'.layout'
,
res
=>
{
this
.
setData
({
postersBoxHeight
:
res
.
height
*
0.7
,
})
})
}
}
},
data
:
{
data
:
{
type
:
Object
,
type
:
Object
,
observer
(
val
)
{
observer
(
val
)
{
...
@@ -33,20 +16,27 @@ Component({
...
@@ -33,20 +16,27 @@ Component({
this
.
setData
({
this
.
setData
({
navHeight
:
thisPage
.
data
.
navHeight
navHeight
:
thisPage
.
data
.
navHeight
})
})
let
imgurl
=
`
${
this
.
data
.
IMGURL
}
scene/scene12.png`
if
(
val
.
showSharePopup
)
{
// 计算海报图片高度
wx
.
$util
.
getViewInfo
(
'.user-box'
,
res
=>
{
wx
.
getImageInfo
({
src
:
imgurl
,
success
:(
res
)
=>
{
val
.
postersImageHeight
=
(
494
/
750
)
*
res
.
height
this
.
setData
({
this
.
setData
({
postersImageHeight
:
(
494
/
750
)
*
res
.
height
boxImageHeight
:
res
.
height
,
})
})
}
val
.
boxImageHeight
=
res
.
height
// 计算弹窗图片区域最大高度
wx
.
$util
.
getViewInfo
(
'.layout'
,
res
=>
{
this
.
setData
({
postersBoxHeight
:
res
.
height
*
0.7
,
postersImageHeight
:
res
.
height
*
0.7
-
this
.
data
.
boxImageHeight
-
20
})
})
// setTimeout(() => {
val
.
postersBoxHeight
=
res
.
height
*
0.7
,
val
.
postersImageHeight
=
res
.
height
*
0.7
-
this
.
data
.
boxImageHeight
-
20
this
.
init
(
val
)
this
.
init
(
val
)
// }, 1000)
// this.init(val)
})
},
this
)
}
}
}
}
}
},
},
...
@@ -64,41 +54,39 @@ Component({
...
@@ -64,41 +54,39 @@ Component({
*/
*/
methods
:
{
methods
:
{
async
init
(
n
)
{
async
init
(
n
)
{
console
.
log
(
n
)
wx
.
$api
.
showLoading
()
wx
.
$api
.
showLoading
()
const
drawfun
=
new
Draw
({
const
drawfun
=
new
Draw
({
width
:
2
79
,
width
:
2
80
,
height
:
5
54
height
:
5
60
+
n
.
boxImageHeight
},
this
),
},
this
),
{
{
userInfo
userInfo
}
=
wx
.
$storage
.
get
(),
}
=
wx
.
$storage
.
get
(),
merchantName
=
userInfo
.
merchantName
.
length
>
12
?
`
${
userInfo
.
merchantName
.
substring
(
0
,
12
)}
...`
:
userInfo
.
merchantName
,
res
=
await
drawfun
.
begin
({
res
=
await
drawfun
.
begin
({
imageList
:
[{
imageList
:
[{
x
:
0
,
x
:
0
,
y
:
0
,
y
:
0
,
width
:
279
,
width
:
279
,
height
:
66
,
height
:
n
.
boxImageHeight
,
url
:
`
${
this
.
data
.
IMGURL
}
taskDetail_bg.png`
url
:
`
${
this
.
data
.
IMGURL
}
taskDetail_bg.png`
},
},
{
//
{
x
:
12
,
//
x: 12,
y
:
12
,
//
y: 12,
width
:
20
,
//
width: 20,
height
:
20
,
//
height: 20,
url
:
`
${
userInfo
.
weChatAvatarUrl
?
userInfo
.
weChatAvatarUrl
:
this
.
data
.
IMGURL
}
order_person_default.png`
//
url: `${userInfo.weChatAvatarUrl ? userInfo.weChatAvatarUrl : this.data.IMGURL}order_person_default.png`
},
//
},
{
{
x
:
16
,
x
:
16
,
y
:
8
0
,
y
:
n
.
boxImageHeight
+
1
0
,
width
:
247
,
width
:
247
,
height
:
n
.
postersImageHeight
/
2
+
8
0
,
height
:
50
0
,
url
:
n
.
posterImg
url
:
n
.
posterImg
},
},
// {
// {
// x: 204,
// x: 204,
// y: n.postersImageHeight / 2 +
17
0,
// y: n.postersImageHeight / 2 +
boxImageHeight + 2
0,
// width: 60,
// width: 60,
// height: 60,
// height: 60,
// url: n.imagePath
// url: n.imagePath
...
@@ -113,7 +101,7 @@ Component({
...
@@ -113,7 +101,7 @@ Component({
textBaseline
:
'top'
textBaseline
:
'top'
},
},
{
{
x
:
16
+
drawfun
.
getTextWidth
(
merchantN
ame
,
14
),
x
:
44
+
drawfun
.
getTextWidth
(
userInfo
.
n
ame
,
14
),
y
:
15
,
y
:
15
,
fontSize
:
12
,
fontSize
:
12
,
color
:
'#6E6E7A'
,
color
:
'#6E6E7A'
,
...
@@ -130,7 +118,7 @@ Component({
...
@@ -130,7 +118,7 @@ Component({
fontWeight
:
500
fontWeight
:
500
},
},
{
{
x
:
1
4
+
drawfun
.
getTextWidth
(
n
.
activityName
,
14
)
+
9
,
x
:
4
4
+
drawfun
.
getTextWidth
(
n
.
activityName
,
14
)
+
9
,
y
:
39
,
y
:
39
,
fontSize
:
10
,
fontSize
:
10
,
color
:
'#4466F0'
,
color
:
'#4466F0'
,
...
@@ -144,21 +132,22 @@ Component({
...
@@ -144,21 +132,22 @@ Component({
},
},
// {
// {
// x: 16,
// x: 16,
// y:
n.postersImageHeight / 2 + 17
0,
// y:
(n.postersImageHeight / 2) + boxImageHeight + 3
0,
// fontSize: 13,
// fontSize: 13,
// color: '#1B233D',
// color: '#1B233D',
// text: userInfo.merchantName
// text: userInfo.merchantName
// },
// },
// {
// {
// x: 16,
// x: 16,
// y: n.postersImageHeight / 2 +
195
,
// y: n.postersImageHeight / 2 +
boxImageHeight + 50
,
// fontSize: 11,
// fontSize: 11,
// color: '#6E6E7A',
// color: '#6E6E7A',
// text: n.address
// text: n.address,
// lineNum: 3,
// width: 193
// }
// }
],
],
})
})
console
.
log
(
res
)
wx
.
hideLoading
()
wx
.
hideLoading
()
this
.
setData
({
this
.
setData
({
poster
:
res
.
path
poster
:
res
.
path
...
@@ -173,7 +162,6 @@ Component({
...
@@ -173,7 +162,6 @@ Component({
})
})
},
},
saveImage
(
e
)
{
saveImage
(
e
)
{
console
.
log
(
e
)
const
filePath
=
this
.
data
.
poster
,
const
filePath
=
this
.
data
.
poster
,
_this
=
this
_this
=
this
wx
.
saveImageToPhotosAlbum
({
wx
.
saveImageToPhotosAlbum
({
...
...
components/sharePopup/sharePopup.scss
View file @
c76098d
...
@@ -86,8 +86,8 @@
...
@@ -86,8 +86,8 @@
}
}
}
}
.content-box
{
.content-box
{
padding
:
32rpx
;
width
:
100%
;
width
:
100%
;
padding
:
32rpx
32rpx
0
32rpx
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
.posters_img
{
.posters_img
{
margin
:
0
auto
;
margin
:
0
auto
;
...
@@ -137,9 +137,8 @@
...
@@ -137,9 +137,8 @@
}
}
.canvas-box
{
.canvas-box
{
position
:
absolute
;
position
:
absolute
;
// left: -9999rpx;
left
:
-9999rpx
;
// top: -9999rpx;
top
:
-9999rpx
;
z-index
:
10000
;
width
:
750rpx
;
width
:
750rpx
;
height
:
750rpx
;
height
:
750rpx
;
}
}
...
...
components/sharePopup/sharePopup.wxml
View file @
c76098d
<!--components/sharePopup/sharePopup.wxml-->
<!--components/sharePopup/sharePopup.wxml-->
<view class="share-popup" wx:if="{{
show
}}" catchtouchmove="noScroll">
<view class="share-popup" wx:if="{{
data.showSharePopup
}}" catchtouchmove="noScroll">
<view class="share-popup-bg" />
<view class="share-popup-bg" />
<view class="share-box" style="transform: translate(-50%, calc(-50% + {{navHeight / 2}}px));">
<view class="share-box" style="transform: translate(-50%, calc(-50% + {{navHeight / 2}}px));">
<view class="close-box">
<view class="close-box">
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<image webp src="{{IMGURL}}popup_close_btn.png"></image>
<image webp src="{{IMGURL}}popup_close_btn.png"></image>
</view>
</view>
</view>
</view>
<view class="share-popup-content" style="
max-
height: {{postersBoxHeight}}px;">
<view class="share-popup-content" style="height: {{postersBoxHeight}}px;">
<!-- 用户活动信息 -->
<!-- 用户活动信息 -->
<block>
<block>
<image class="bg" style="height: {{boxImageHeight}}px;" webp src="{{IMGURL}}taskDetail_bg.png"></image>
<image class="bg" style="height: {{boxImageHeight}}px;" webp src="{{IMGURL}}taskDetail_bg.png"></image>
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
<!-- 海报 -->
<!-- 海报 -->
<block>
<block>
<view class="content-box">
<view class="content-box">
<image class="posters_img" style="height: {{postersImageHeight}}
rpx;
" src="{{data.posterImg}}"></image>
<image class="posters_img" style="height: {{postersImageHeight}}
px;" mode="aspectFit
" src="{{data.posterImg}}"></image>
<view class="merchant_box">
<
!-- <
view class="merchant_box">
<view class="merchant_message">
<view class="merchant_message">
<view class="name">{{USERINFO.merchantName}}</view>
<view class="name">{{USERINFO.merchantName}}</view>
<view class="address">{{data.address}}</view>
<view class="address">{{data.address}}</view>
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
<view class="qrcode">
<view class="qrcode">
<image src="{{data.imagePath}}"></image>
<image src="{{data.imagePath}}"></image>
</view>
</view>
</view>
</view>
-->
</view>
</view>
</block>
</block>
<!-- 保存 -->
<!-- 保存 -->
...
...
packageActivity/pages/taskDetail/taskDetail.js
View file @
c76098d
...
@@ -134,14 +134,16 @@ Page({
...
@@ -134,14 +134,16 @@ Page({
})
})
}
else
{
}
else
{
let
item
=
this
.
data
.
detailInfo
let
item
=
this
.
data
.
detailInfo
console
.
log
(
item
)
wx
.
$api
.
showLoading
()
ActivityApi
.
getActivityPosters
({
id
:
item
.
activityId
}).
then
(
res
=>
{
this
.
setData
({
this
.
setData
({
sharePopupData
:
{
sharePopupData
:
{
imagePath
:
QR
.
createQrCodeImg
(
`
${
item
.
linkUrl
}
`
)
,
posterImg
:
res
,
activityName
:
item
.
activityName
,
activityName
:
item
.
activityName
,
showSharePopup
:
true
showSharePopup
:
true
},
},
})
})
})
}
}
},
},
...
...
packageActivity/pages/taskDetail/taskDetail.scss
View file @
c76098d
/* packageActivity/pages/taskDetail/taskDetail.wxss */
/* packageActivity/pages/taskDetail/taskDetail.wxss */
.layout
{
height
:
100vh
;;
}
.task-detail-box
{
.task-detail-box
{
padding
:
32rpx
24rpx
;
padding
:
32rpx
24rpx
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
overflow-y
:
auto
;
.title
{
.title
{
margin
:
0
0
24rpx
16rpx
;
margin
:
0
0
24rpx
16rpx
;
font-weight
:
600
;
font-weight
:
600
;
...
@@ -206,4 +210,11 @@
...
@@ -206,4 +210,11 @@
color
:
#fff
;
color
:
#fff
;
}
}
}
}
.canvas-box
{
position
:
absolute
;
left
:
-9999rpx
;
top
:
-9999rpx
;
width
:
750rpx
;
height
:
750rpx
;
}
}
}
\ No newline at end of file
\ No newline at end of file
packageActivity/pages/taskDetail/taskDetail.wxml
View file @
c76098d
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
}
}
module.exports.indexOf = indexOf
module.exports.indexOf = indexOf
</wxs>
</wxs>
<view class="task-detail-box">
<view class="task-detail-box
layout
">
<view class="title">任务</view>
<view class="title">任务</view>
<view class="task-box">
<view class="task-box">
<view class="left">
<view class="left">
...
@@ -72,4 +72,9 @@
...
@@ -72,4 +72,9 @@
<view class="btn-box">
<view class="btn-box">
<view class="btn primary" bind:tap="shareEvent">分享<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" /></view>
<view class="btn primary" bind:tap="shareEvent">分享<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" /></view>
</view>
</view>
<!-- 分享活动弹窗 -->
<share-popup show="{{sharePopupData.showSharePopup}}" data="{{sharePopupData}}"></share-popup>
<view class="canvas-box">
<canvas style="width: 352rpx;height: 352rpx;" canvas-id="mycanvas" />
</view>
</view>
</view>
pages/tab/index/components/activeBox/activeBox.js
View file @
c76098d
...
@@ -142,32 +142,39 @@ Component({
...
@@ -142,32 +142,39 @@ Component({
copyActivityUrl
(
e
)
{
copyActivityUrl
(
e
)
{
let
{
item
}
=
e
.
currentTarget
.
dataset
let
{
item
}
=
e
.
currentTarget
.
dataset
let
thisPage
=
wx
.
$router
.
getPageInstance
()
let
thisPage
=
wx
.
$router
.
getPageInstance
()
ActivityApi
.
getActivityPosters
({
activityId
:
item
.
id
}).
then
(
res
=>
{
wx
.
$api
.
showLoading
()
var
code
=
QR
.
createQrCodeImg
(
res
.
activityUrl
);
ActivityApi
.
getActivityPosters
({
id
:
item
.
id
}).
then
(
res
=>
{
/*code是指图片base64格式数据*/
// var code= QR.createQrCodeImg(res.activityUrl);
//声明文件系统
// /*code是指图片base64格式数据*/
const
fs
=
wx
.
getFileSystemManager
();
// //声明文件系统
//随机定义路径名称
// const fs = wx.getFileSystemManager();
var
times
=
new
Date
().
getTime
();
// //随机定义路径名称
var
codeimg
=
wx
.
env
.
USER_DATA_PATH
+
'/'
+
times
+
'.png'
;
// var times = new Date().getTime();
//将base64图片写入
// var codeimg = wx.env.USER_DATA_PATH + '/' + times + '.png';
fs
.
writeFile
({
// //将base64图片写入
filePath
:
codeimg
,
// fs.writeFile({
data
:
code
.
slice
(
22
),
// filePath: codeimg,
encoding
:
'base64'
,
// data: code.slice(22),
success
:
()
=>
{
// encoding: 'base64',
// success: () => {
// thisPage.setData({
// sharePopupData: {
// imagePath: codeimg,
// activityName: res.activityName,
// address: res.activityAddressDetailName,
// posterImg: res.posterImg,
// showSharePopup: true
// },
// })
// }
// });
thisPage
.
setData
({
thisPage
.
setData
({
sharePopupData
:
{
sharePopupData
:
{
imagePath
:
codeimg
,
posterImg
:
res
,
activityName
:
res
.
activityName
,
activityName
:
item
.
activityName
,
address
:
res
.
activityAddressDetailName
,
posterImg
:
res
.
posterImg
,
showSharePopup
:
true
showSharePopup
:
true
},
},
})
})
}
});
})
})
},
},
// 活动详情
// 活动详情
...
...
pages/tab/index/index.wxml
View file @
c76098d
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
<!-- 预约安装弹窗 -->
<!-- 预约安装弹窗 -->
<install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup>
<install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup>
<!-- 分享活动弹窗 -->
<!-- 分享活动弹窗 -->
<share-popup
show="{{sharePopupData.showSharePopup}}"
data="{{sharePopupData}}"></share-popup>
<share-popup data="{{sharePopupData}}"></share-popup>
<!-- <van-popup show="{{ showSharePopup }}" round bind:close="onClose">
<!-- <van-popup show="{{ showSharePopup }}" round bind:close="onClose">
<image style="width: 352rpx; height: 352rpx;" src="{{imagePath}}"></image>
<image style="width: 352rpx; height: 352rpx;" src="{{imagePath}}"></image>
</van-popup> -->
</van-popup> -->
...
...
utils/Draw.js
View file @
c76098d
...
@@ -16,7 +16,7 @@ class Draw {
...
@@ -16,7 +16,7 @@ class Draw {
type
:
'2d'
,
type
:
'2d'
,
width
,
width
,
height
,
height
,
compInst
:
isCompInst
compInst
:
isCompInst
}),
}),
ctx
=
canvas
.
getContext
(
'2d'
)
ctx
=
canvas
.
getContext
(
'2d'
)
this
[
_canvas_
]
=
canvas
this
[
_canvas_
]
=
canvas
...
@@ -58,6 +58,7 @@ class Draw {
...
@@ -58,6 +58,7 @@ class Draw {
}
}
let
image
=
this
[
_canvas_
].
createImage
()
let
image
=
this
[
_canvas_
].
createImage
()
image
.
src
=
`
${
url
}
?v=
${
Date
.
now
()}
`
image
.
src
=
`
${
url
}
?v=
${
Date
.
now
()}
`
console
.
log
(
image
.
src
)
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
image
.
onload
=
()
=>
{
image
.
onload
=
()
=>
{
this
[
_ctx_
].
drawImage
(
image
,
x
,
y
,
width
,
height
)
this
[
_ctx_
].
drawImage
(
image
,
x
,
y
,
width
,
height
)
...
@@ -65,6 +66,14 @@ class Draw {
...
@@ -65,6 +66,14 @@ class Draw {
if
(
callback
)
callback
()
if
(
callback
)
callback
()
resolve
(
imageParams
)
resolve
(
imageParams
)
}
}
image
.
onerror
=
err
=>
{
console
.
log
(
image
.
src
)
wx
.
hideLoading
()
wx
.
showToast
({
title
:
'图片加载失败'
,
icon
:
'error'
})
}
})
})
}
}
toRpx
(
val
)
{
toRpx
(
val
)
{
...
@@ -133,44 +142,10 @@ class Draw {
...
@@ -133,44 +142,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
)
{
let
boxX
=
this
.
toRpx
(
textParams
.
x
-
4.5
),
boxY
=
this
.
toRpx
(
textParams
.
y
-
0.5
),
boxWidth
=
text_width
+
this
.
toRpx
(
9
),
boxHeight
=
lineHeight
+
this
.
toRpx
(
4
)
if
(
boxWidth
>
width
-
fontX
-
this
.
getTextWidth
(
'…'
)
-
fontSize
)
{
boxWidth
=
width
-
boxX
+
this
.
toRpx
(
9
)
}
this
.
drawFill
({
x
:
boxX
,
y
:
boxY
,
width
:
boxWidth
,
height
:
boxHeight
,
color
:
textParams
.
border
})
}
if
(
textParams
.
background
)
{
let
boxX
=
this
.
toRpx
(
textParams
.
x
-
4
),
boxY
=
this
.
toRpx
(
textParams
.
y
),
boxWidth
=
text_width
+
this
.
toRpx
(
8
),
boxHeight
=
lineHeight
+
this
.
toRpx
(
3
)
if
(
boxWidth
>
width
-
fontX
-
this
.
getTextWidth
(
'…'
)
-
fontSize
)
{
boxWidth
=
width
-
boxX
+
this
.
toRpx
(
8
)
}
this
.
drawFill
({
x
:
boxX
,
y
:
boxY
,
width
:
boxWidth
,
height
:
boxHeight
,
color
:
textParams
.
background
})
}
const
drawOneLineText
=
()
=>
{
const
drawOneLineText
=
()
=>
{
let
textArr
=
text
.
toString
().
split
(
''
),
let
textArr
=
text
.
toString
().
split
(
''
),
newText
=
''
,
newText
=
''
,
...
@@ -249,11 +224,112 @@ class Draw {
...
@@ -249,11 +224,112 @@ 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
()
}
drawBorder
(
params
)
{
let
{
x
,
y
,
text
,
color
,
width
,
radius
,
opacity
,
padding
,
fontSize
}
=
params
,
paddingX
=
0
,
paddingY
=
0
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
)
{
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_
].
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
,
...
@@ -262,18 +338,20 @@ class Draw {
...
@@ -262,18 +338,20 @@ class Draw {
endX
,
endX
,
endY
endY
}
=
lineParams
}
=
lineParams
if
(
!
noTransition
)
{
startX
=
this
.
toRpx
(
startX
)
startX
=
this
.
toRpx
(
startX
)
startY
=
this
.
toRpx
(
startY
)
startY
=
this
.
toRpx
(
startY
)
width
=
this
.
toRpx
(
width
)
width
=
this
.
toRpx
(
width
)
endX
=
this
.
toRpx
(
endX
)
endX
=
this
.
toRpx
(
endX
)
endY
=
this
.
toRpx
(
endY
)
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
()
}
}
...
@@ -411,7 +489,7 @@ class Draw {
...
@@ -411,7 +489,7 @@ class Draw {
if
(
index
==
data
.
imageList
.
length
-
1
)
drawFun
()
if
(
index
==
data
.
imageList
.
length
-
1
)
drawFun
()
}
}
else
drawFun
()
else
drawFun
()
}
}
else
drawFun
()
})
})
}
}
}
}
...
...
utils/request/environment.js
View file @
c76098d
...
@@ -6,7 +6,7 @@ const target = ['ip', 'dev', 'uat', 'prod']
...
@@ -6,7 +6,7 @@ const target = ['ip', 'dev', 'uat', 'prod']
2测试
2测试
3生产
3生产
*/
*/
const
index
=
1
const
index
=
2
const
secretKey
=
{
const
secretKey
=
{
ip
:
{},
ip
:
{},
dev
:
{
dev
:
{
...
...
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