1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import {
- createWxCode
- } from '~/api/global'
- Component({
- properties: {},
- data: {
- state: false,
- qrCode: ''
- },
- methods: {
- async open() {
- let qrCode = await createWxCode({
- page: "pages/index/index",
- scene: wx.getStorageSync('uid')
- })
- console.log(qrCode);
- this.setData({
- state: true,
- qrCode
- })
- },
- 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();
- console.log(this.data.qrCode);
- pl.src = this.data.qrCode
- pl.onload = async () => {
- console.log('11');
- ctx.drawImage(pl, 29, 756, 170, 170)
- let {
- tempFilePath
- } = await wx.canvasToTempFilePath({
- canvas
- })
- wx.saveImageToPhotosAlbum({
- filePath: tempFilePath,
- success() {
- wx.showToast({
- title: '保存成功',
- icon: 'none'
- })
- }
- })
- }
- }
- })
- }
- }
- })
|