Commit 1dc2f2d2 by 李伟康

修改代码

1 parent 59ef301c
......@@ -94,9 +94,17 @@ Component({
})
},
download() {
const filePath = this.data.poster
const filePath = this.data.poster,
_this = this
wx.saveImageToPhotosAlbum({
filePath
filePath,
success(){
wx.$api.showToast('保存成功')
},
fail(err) {
const auth = _this.selectComponent('#auth')
auth.check()
}
})
},
hide() {
......@@ -105,6 +113,11 @@ Component({
poster: ''
})
},
noScroll() {}
noScroll() {},
authFail(e) {
this.setData({
showAuth: true
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
"usingComponents": {
"authorize":"/components/Authorize/Authorize"
}
}
\ No newline at end of file
......@@ -7,4 +7,5 @@
提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。
</view>
</view>
</block>
\ No newline at end of file
</block>
<authorize scopeType="writePhotosAlbum" bindfail="authFail" show="{{showAuth}}" id="auth"></authorize>
\ No newline at end of file
// 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(),
merchantName = userInfo.merchantName.length > 12 ? `${userInfo.merchantName.substring(0, 12)}...` : userInfo.merchantName,
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: merchantName,
textBaseline: 'top'
},
{
x: 16 + drawfun.getTextWidth(merchantName, 14),
y: 15,
fontSize: 12,
color: '#6E6E7A',
text: '邀请你参加',
textBaseline: 'top'
},
{
x: 12,
y: 36,
fontSize: 14,
color: '#1B233D',
text: n.activityName,
textBaseline: 'top',
fontWeight: 500
},
{
x: 14 + drawfun.getTextWidth(n.activityName, 14) + 9,
y: 39,
fontSize: 10,
color: '#4466F0',
text: '众筹',
border: {
width: 1,
color: '#8FA5FF',
radius: 2,
padding: [5, 5]
}
}
],
})
console.log(res)
wx.hideLoading()
this.setData({
poster: res.path
})
},
download() {
const filePath = this.data.poster,
_this = this
wx.saveImageToPhotosAlbum({
filePath,
success(){
wx.$api.showToast('保存成功')
},
fail(err) {
const auth = _this.selectComponent('#auth')
auth.check()
}
}
)
},
hide() {
this.setData({
poster: ''
})
},
noScroll() {},
authFail(e) {
this.setData({
showAuth: true
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
"authorize":"/components/Authorize/Authorize"
}
}
\ 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;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.bg {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
background: rgba(28, 27, 35, 0.60);
}
.poster {
width: 558rpx;
height: 60%;
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
<block wx:if="{{poster}}">
<view class="layout" catchtouchmove="noScroll">
<view class="bg" bindtap="hide"></view>
<image src="{{poster}}" class="poster" mode="aspectFit"></image>
<view class="btn" bindtap="download">保存至相册</view>
<view class="tips">
提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。
</view>
</view>
</block>
<authorize scopeType="writePhotosAlbum" bindfail="authFail" show="{{showAuth}}" id="auth"></authorize>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!