generate-placeholder.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>生成占位二维码</title>
  7. <style>
  8. body {
  9. display: flex;
  10. justify-content: center;
  11. align-items: center;
  12. min-height: 100vh;
  13. background: #f5f5f5;
  14. font-family: Arial, sans-serif;
  15. }
  16. .container {
  17. text-align: center;
  18. background: white;
  19. padding: 40px;
  20. border-radius: 10px;
  21. box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  22. }
  23. canvas {
  24. border: 1px solid #ddd;
  25. margin: 20px 0;
  26. }
  27. button {
  28. padding: 10px 20px;
  29. background: #4caf50;
  30. color: white;
  31. border: none;
  32. border-radius: 5px;
  33. cursor: pointer;
  34. font-size: 16px;
  35. }
  36. button:hover {
  37. background: #45a049;
  38. }
  39. .note {
  40. margin-top: 20px;
  41. color: #666;
  42. font-size: 14px;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <div class="container">
  48. <h2>生成占位二维码图片</h2>
  49. <canvas id="canvas" width="200" height="200"></canvas>
  50. <br>
  51. <button onclick="downloadImage()">下载为 payment-qrcode.png</button>
  52. <div class="note">
  53. <p>这是一个占位图片,请替换为你的真实支付二维码</p>
  54. <p>下载后放在 images 文件夹中即可</p>
  55. </div>
  56. </div>
  57. <script>
  58. // 绘制占位二维码
  59. const canvas = document.getElementById('canvas');
  60. const ctx = canvas.getContext('2d');
  61. // 背景
  62. ctx.fillStyle = '#ffffff';
  63. ctx.fillRect(0, 0, 200, 200);
  64. // 边框
  65. ctx.strokeStyle = '#333';
  66. ctx.lineWidth = 2;
  67. ctx.strokeRect(10, 10, 180, 180);
  68. // 文字
  69. ctx.fillStyle = '#333';
  70. ctx.font = 'bold 16px Arial';
  71. ctx.textAlign = 'center';
  72. ctx.fillText('支付二维码', 100, 90);
  73. ctx.font = '12px Arial';
  74. ctx.fillText('请替换为真实二维码', 100, 110);
  75. // 简单的二维码图案
  76. ctx.fillStyle = '#333';
  77. for (let i = 0; i < 8; i++) {
  78. for (let j = 0; j < 8; j++) {
  79. if ((i + j) % 2 === 0) {
  80. ctx.fillRect(50 + i * 12, 120 + j * 8, 10, 6);
  81. }
  82. }
  83. }
  84. function downloadImage() {
  85. const link = document.createElement('a');
  86. link.download = 'payment-qrcode.png';
  87. link.href = canvas.toDataURL('image/png');
  88. link.click();
  89. }
  90. </script>
  91. </body>
  92. </html>