index.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>lime-qrcode</title>
  8. <style>
  9. html,body,canvas {
  10. margin: 0;
  11. padding: 0;
  12. width: 100%;
  13. height: 100%;
  14. pointer-events: none;
  15. /* background-color: rgba(255,0,0,0.1) */
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <canvas id="lime-qrcode"></canvas>
  21. <script type="text/javascript" src="./uni.webview.1.5.3.js"></script>
  22. <script type="text/javascript" src="./qrcode.min.js"></script>
  23. <script>
  24. var canvas = document.querySelector('#lime-qrcode')
  25. var pixelRatio = window.devicePixelRatio || 1
  26. function appendWatermark(image) {
  27. emit('append', mark.toDataURL())
  28. }
  29. var qrcode = new lime.QRCodeCanvas(canvas, {
  30. pixelRatio,
  31. })
  32. function render(props) {
  33. if(props.pixelRatio) {
  34. pixelRatio = props.pixelRatio
  35. }
  36. if(qrcode) {
  37. qrcode.render(props)
  38. }
  39. }
  40. function toDataURL(file) {
  41. if(qrcode && canvas) {
  42. try{
  43. const image = canvas.toDataURL()
  44. emit('toDataURL', {
  45. file,
  46. image
  47. })
  48. }catch(e){
  49. emit('toDataURL', {
  50. file,
  51. msg: e
  52. })
  53. }
  54. }
  55. }
  56. function emit(event, data) {
  57. postMessage({
  58. event,
  59. data
  60. });
  61. };
  62. function postMessage(data) {
  63. uni.postMessage({
  64. data
  65. });
  66. };
  67. // render({
  68. // content: ['Lime UI'],
  69. // // rotate: -22,
  70. // // baseSize: 2,
  71. // // fontGap: 3
  72. // })
  73. </script>
  74. </body>
  75. </html>