123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- Component({
- properties: {},
- data: {
- state: false,
- img: ''
- },
- methods: {
- open() {
- this.setData({
- state: true
- })
- },
- closeMediaBox() {
- this.setData({
- state: false
- })
- },
- savePoster() {
- const query = wx.createSelectorQuery().in(this);
- let canvas
- query
- .select('#cavansId')
- .fields({
- node: true,
- size: true
- }).exec(async (res) => {
- canvas = res[0].node;
- const ctx = canvas.getContext('2d');
- const dpr = wx.getSystemInfoSync().pixelRatio;
- canvas.width = 646;
- canvas.height = 959;
- let pic = canvas.createImage();
- pic.src = 'https://reader-wx.ai160.com/images/reader/pay/shareBg.jpg'
- pic.onload = () => {
- ctx.drawImage(pic, 0, 0, 646, 959);
- let pl = canvas.createImage();
- pl.src = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEs8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZzR0ZTE2T2M5N1UxYURaYU5CY1QAAgSHoQplAwQgHAAA'
- 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'
- })
- }
- })
- }
- }
- })
- }
- }
- })
|