Commit f94dea52 by 李伟康

增加活动海报

1 parent 1a22e947
// packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.js
import Draw from '~/utils/Draw'
Component({
/**
* 组件的属性列表
*/
properties: {
item: {
type: Object,
observer(n) {
console.log(n, '=================')
this.init(n)
}
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
async init(n) {
wx.$api.showLoading()
const drawfun = new Draw({
width: 279,
height: 554
}, this),
{
userInfo
} = wx.$storage.get(),
res = await drawfun.begin({
imageList: [{
x: 0,
y: 0,
width: 279,
height: 66,
url: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png'
},
{
x: 16,
y: 70,
width: 247,
height: 472,
url: n.posterUrl
}
],
textList: [{
x: 12,
y: 14,
fontSize: 14,
color: '#2D2D33',
text: userInfo.merchantName,
textBaseline:'top'
}]
})
console.log(res)
wx.hideLoading()
this.setData({
poster: res.path,
show: true
})
},
hide() {
this.setData({
show: false,
poster: ''
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.wxss */
.layout {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 998;
.bg {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
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 {
width: 558rpx;
height: 1108rpx;
border-radius: 8rpx;
}
}
\ No newline at end of file
<block wx:if="{{show}}">
<view class="layout">
<view class="bg" bindtap="hide"></view>
<image src="{{poster}}" class="poster"></image>
</view>
</block>
\ No newline at end of file
......@@ -132,6 +132,12 @@ Component({
}
})
})
},
download(e){
const {item} = e.currentTarget.dataset
this.setData({
posterItem: item
})
}
}
})
{
"component": true,
"usingComponents": {}
"usingComponents": {
"crowdfund-poster":"../CrowdfundPoster/CrowdfundPoster"
}
}
\ No newline at end of file
......@@ -12,7 +12,8 @@
<view class="box merchant" wx:for="{{orderObj.activityList}}" wx:key="index">
<view class="head">
<view class="text-hide head-title">{{item.activityName}}</view>
<view class="head-link" bindtap="handleCopy" data-idx="{{index}}">复制活动链接</view>
<view class="head-link" bindtap="download" data-item="{{item}}">下载海报</view>
<!-- <view class="head-link" bindtap="handleCopy" data-idx="{{index}}">复制活动链接</view> -->
</view>
<view class="content">
<view class="content-row" wx:for="{{merchantFormList}}" wx:for-item="subItem" wx:for-index="idx" wx:key="idx">
......@@ -67,4 +68,5 @@
</view>
</view>
</view>
</view>
\ No newline at end of file
</view>
<crowdfund-poster item="{{posterItem}}" />
\ No newline at end of file
......@@ -16,7 +16,7 @@ class Draw {
type: '2d',
width,
height,
compInst:isCompInst
compInst: isCompInst
}),
ctx = canvas.getContext('2d')
this[_canvas_] = canvas
......@@ -65,6 +65,13 @@ class Draw {
if (callback) callback()
resolve(imageParams)
}
image.onerror = err => {
wx.hideLoading()
wx.showToast({
title: '图片加载失败',
icon: 'error'
})
}
})
}
toRpx(val) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!