|
@@ -1,7 +1,7 @@
|
|
Component({
|
|
Component({
|
|
properties: {},
|
|
properties: {},
|
|
data: {
|
|
data: {
|
|
- state: true,
|
|
|
|
|
|
+ state: false,
|
|
img: ''
|
|
img: ''
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -17,28 +17,44 @@ Component({
|
|
},
|
|
},
|
|
savePoster() {
|
|
savePoster() {
|
|
const query = wx.createSelectorQuery().in(this);
|
|
const query = wx.createSelectorQuery().in(this);
|
|
|
|
+ let canvas
|
|
query
|
|
query
|
|
.select('#cavansId')
|
|
.select('#cavansId')
|
|
.fields({
|
|
.fields({
|
|
node: true,
|
|
node: true,
|
|
size: true
|
|
size: true
|
|
}).exec(async (res) => {
|
|
}).exec(async (res) => {
|
|
- const canvas = res[0].node;
|
|
|
|
|
|
+ canvas = res[0].node;
|
|
const ctx = canvas.getContext('2d');
|
|
const ctx = canvas.getContext('2d');
|
|
const dpr = wx.getSystemInfoSync().pixelRatio;
|
|
const dpr = wx.getSystemInfoSync().pixelRatio;
|
|
- canvas.width = res[0].width * dpr;
|
|
|
|
- canvas.height = res[0].height * dpr;
|
|
|
|
|
|
+ canvas.width = 646;
|
|
|
|
+ canvas.height = 959;
|
|
let pic = canvas.createImage();
|
|
let pic = canvas.createImage();
|
|
pic.src = 'https://reader-wx.ai160.com/images/reader/pay/shareBg.jpg'
|
|
pic.src = 'https://reader-wx.ai160.com/images/reader/pay/shareBg.jpg'
|
|
pic.onload = () => {
|
|
pic.onload = () => {
|
|
ctx.drawImage(pic, 0, 0, 646, 959);
|
|
ctx.drawImage(pic, 0, 0, 646, 959);
|
|
let pl = canvas.createImage();
|
|
let pl = canvas.createImage();
|
|
pl.src = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEs8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZzR0ZTE2T2M5N1UxYURaYU5CY1QAAgSHoQplAwQgHAAA'
|
|
pl.src = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEs8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZzR0ZTE2T2M5N1UxYURaYU5CY1QAAgSHoQplAwQgHAAA'
|
|
- pl.onload = () => {
|
|
|
|
- ctx.drawImage(pl, 25, 747, 173, 173)
|
|
|
|
|
|
+ pl.onload = async () => {
|
|
|
|
+ ctx.drawImage(pl, 29, 756, 170, 170)
|
|
|
|
+ let {
|
|
|
|
+ tempFilePath
|
|
|
|
+ } = await wx.canvasToTempFilePath({
|
|
|
|
+ canvas
|
|
|
|
+ })
|
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
|
+ filePath: tempFilePath,
|
|
|
|
+ success() {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '保存成功',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|