index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Component({
  2. properties: {},
  3. data: {
  4. state: true,
  5. img: ''
  6. },
  7. methods: {
  8. open() {
  9. this.setData({
  10. state: true
  11. })
  12. },
  13. closeMediaBox() {
  14. this.setData({
  15. state: false
  16. })
  17. },
  18. savePoster() {
  19. const query = wx.createSelectorQuery().in(this);
  20. query
  21. .select('#cavansId')
  22. .fields({
  23. node: true,
  24. size: true
  25. }).exec(async (res) => {
  26. const canvas = res[0].node;
  27. const ctx = canvas.getContext('2d');
  28. const dpr = wx.getSystemInfoSync().pixelRatio;
  29. canvas.width = res[0].width * dpr;
  30. canvas.height = res[0].height * dpr;
  31. let pic = canvas.createImage();
  32. pic.src = 'https://reader-wx.ai160.com/images/reader/pay/shareBg.jpg'
  33. pic.onload = () => {
  34. ctx.drawImage(pic, 0, 0, 646, 959);
  35. let pl = canvas.createImage();
  36. pl.src = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEs8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZzR0ZTE2T2M5N1UxYURaYU5CY1QAAgSHoQplAwQgHAAA'
  37. pl.onload = () => {
  38. ctx.drawImage(pl, 25, 747, 173, 173)
  39. }
  40. }
  41. })
  42. }
  43. }
  44. })