Commit b02f10be by 李伟康

提交代码

1 parent c830b6a5
...@@ -35,31 +35,59 @@ Component({ ...@@ -35,31 +35,59 @@ Component({
{ {
userInfo userInfo
} = wx.$storage.get(), } = wx.$storage.get(),
res = await drawfun.begin({ merchantName = userInfo.merchantName.length > 12 ? `${userInfo.merchantName.substring(0, 12)}...` : userInfo.merchantName,
imageList: [{ res = await drawfun.begin({
x: 0, imageList: [{
y: 0, x: 0,
width: 279, y: 0,
height: 66, width: 279,
url: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png' height: 66,
}, url: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png'
{ },
x: 16, {
y: 70, x: 16,
width: 247, y: 70,
height: 472, width: 247,
url: n.posterUrl height: 472,
} url: n.posterUrl
], }
textList: [{ ],
x: 12, textList: [{
y: 14, x: 12,
fontSize: 14, y: 14,
color: '#2D2D33', fontSize: 14,
text: userInfo.merchantName, color: '#2D2D33',
textBaseline:'top' text: merchantName,
}] textBaseline: 'top'
}) },
{
x: 12,
y: 36,
fontSize: 14,
color: '#1B233D',
text: n.activityName,
textBaseline: 'top',
fontWeight: 500
},
{
x: 12 + drawfun.getTextWidth(n.activityName, 14) + 9,
y: 38,
fontSize: 10,
color: '#4466F0',
text: '众筹',
textBaseline: 'top'
}
],
lineList: [{
startX: 12 + drawfun.getTextWidth(n.activityName, 14) + 4,
startY: 38,
width: 1,
endX: 12 + drawfun.getTextWidth(n.activityName, 14) + 4,
endY: 54,
color: '#8FA5FF',
opacity: 0.5
}]
})
console.log(res) console.log(res)
wx.hideLoading() wx.hideLoading()
this.setData({ this.setData({
...@@ -67,11 +95,18 @@ Component({ ...@@ -67,11 +95,18 @@ Component({
show: true show: true
}) })
}, },
download() {
const filePath = this.data.poster
wx.saveImageToPhotosAlbum({
filePath
})
},
hide() { hide() {
this.setData({ this.setData({
show: false, show: false,
poster: '' poster: ''
}) })
} },
noScroll() {}
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
z-index: 998; z-index: 998;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.bg { .bg {
position: absolute; position: absolute;
...@@ -13,12 +17,31 @@ ...@@ -13,12 +17,31 @@
height: 100%; height: 100%;
z-index: -1; z-index: -1;
background: rgba(28, 27, 35, 0.60); background: rgba(28, 27, 35, 0.60);
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.80), 0 0 1px 0 rgba(92, 114, 246, 0.30), inset 0 0 1px 0 rgba(93, 115, 235, 0.30);
} }
.poster { .poster {
width: 558rpx; width: 558rpx;
height: 1108rpx; height: 60%;
border-radius: 8rpx; border-radius: 8rpx;
} }
.btn {
width: 320rpx;
height: 88rpx;
line-height: 88rpx;
background-image: linear-gradient(-60deg, #556AF5 0%, #7197FF 100%);
border-radius: 16rpx;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
text-align: center;
margin-top: 32rpx;
}
.tips {
margin: 16rpx 80rpx 0;
font-size: 24rpx;
color: #FFFFFF;
line-height: 36rpx;
}
} }
\ No newline at end of file \ No newline at end of file
<block wx:if="{{show}}"> <block wx:if="{{show}}">
<view class="layout"> <view class="layout" catchtouchmove="noScroll">
<view class="bg" bindtap="hide"></view> <view class="bg" bindtap="hide"></view>
<image src="{{poster}}" class="poster"></image> <image src="{{poster}}" class="poster" mode="aspectFit"></image>
<view class="btn" bindtap="download">保存至相册</view>
<view class="tips">
提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。
</view>
</view> </view>
</block> </block>
\ No newline at end of file \ No newline at end of file
...@@ -146,12 +146,12 @@ class Draw { ...@@ -146,12 +146,12 @@ class Draw {
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) { if (textParams.border) {
let boxX = this.toRpx(textParams.x - 4.5), let boxX = textParams.x - 4.5,
boxY = this.toRpx(textParams.y - 0.5), boxY = textParams.y - 0.5,
boxWidth = text_width + this.toRpx(9), boxWidth = text_width + 9,
boxHeight = lineHeight + this.toRpx(4) boxHeight = lineHeight + 4
if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) { if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) {
boxWidth = width - boxX + this.toRpx(9) boxWidth = width - boxX + 9
} }
this.drawFill({ this.drawFill({
x: boxX, x: boxX,
...@@ -162,12 +162,12 @@ class Draw { ...@@ -162,12 +162,12 @@ class Draw {
}) })
} }
if (textParams.background) { if (textParams.background) {
let boxX = this.toRpx(textParams.x - 4), let boxX = textParams.x - 4,
boxY = this.toRpx(textParams.y), boxY = textParams.y,
boxWidth = text_width + this.toRpx(8), boxWidth = text_width + 8,
boxHeight = lineHeight + this.toRpx(3) boxHeight = lineHeight + 3
if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) { if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) {
boxWidth = width - boxX + this.toRpx(8) boxWidth = width - boxX + 8
} }
this.drawFill({ this.drawFill({
x: boxX, x: boxX,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!