GuilhermeRamalho

shareReceipt.js

Feb 23rd, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             function shareReceipt() {
  2.                 var canvas = document.getElementById("receipt");
  3.                 var context = canvas.getContext("2d");
  4.  
  5.                 const messages = [
  6.                   "################################",
  7.                   "Central Jogos",
  8.                   "################################",
  9.                   "Apostador: test",
  10.                   "Valor apostado: R$ 5,00",
  11.                   "Valor de retorno: R$ 6,15",
  12.                   "Data da aposta: 19/02/2017 15:07",
  13.                   "Quantidade de jogos: 1",
  14.                   "--------------------------------",
  15.                   "Vasco X Flamengo",
  16.                   "Empate: 1.23",
  17.                   "10/03/2017 15:30",
  18.                   "================================",
  19.                   "Cambista: Cambista Teste",
  20.                   "Telefone: (82) 9977-8877"
  21.                 ];
  22.  
  23.                 context.font = "12px Courier new";
  24.  
  25.                 y = 12;
  26.                 for (var i in messages)
  27.                 {
  28.                   context.fillText(messages[i], 0, y);
  29.                   y += 18;
  30.                 }
  31.  
  32.                 //console.log(context.canvas.toDataURL());
  33.                 var base64 = context.canvas.toDataURL();
  34.  
  35.                 alert(base64);
  36.  
  37.                 window.plugins.socialsharing.share(
  38.                     null,
  39.                     'Comprovante de Aposta',
  40.                     base64,
  41.                     null
  42.                 );
  43.  
  44.                 /*window.plugins.socialsharing.shareViaWhatsApp(
  45.                     'Message via WhatsApp',
  46.                     null,
  47.                     null,
  48.                     function() {alert('share ok');},
  49.                     function(errormsg){alert(errormsg);}
  50.                 );*/
  51.             }
Advertisement
Add Comment
Please, Sign In to add comment