test-cancel-dialog.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. /* 模拟取消原因对话框的样式 */
  6. .cancel-reason-option {
  7. padding: 12px 16px;
  8. border: 1px solid #d1d5db;
  9. border-radius: 6px;
  10. cursor: pointer;
  11. transition: all 0.2s;
  12. background: white;
  13. margin-bottom: 8px;
  14. }
  15. .cancel-reason-option:hover {
  16. background-color: #f9fafb;
  17. }
  18. .cancel-reason-option.selected {
  19. border-color: #3b82f6;
  20. background-color: #eff6ff;
  21. }
  22. /* 检查是否有任何可能阻止点击的样式 */
  23. * {
  24. box-sizing: border-box;
  25. }
  26. body {
  27. font-family: sans-serif;
  28. padding: 20px;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <h2>测试取消原因对话框按钮点击</h2>
  34. <div class="cancel-reason-option" onclick="console.log('点击了: 我不想买了')">
  35. 我不想买了
  36. </div>
  37. <div class="cancel-reason-option" onclick="console.log('点击了: 信息填写错误,重新下单')">
  38. 信息填写错误,重新下单
  39. </div>
  40. <div class="cancel-reason-option" onclick="console.log('点击了: 商家缺货')">
  41. 商家缺货
  42. </div>
  43. <div class="cancel-reason-option" onclick="console.log('点击了: 价格不合适')">
  44. 价格不合适
  45. </div>
  46. <p>点击上面的选项,检查浏览器控制台是否有输出</p>
  47. <script>
  48. // 添加点击事件监听器
  49. const options = document.querySelectorAll('.cancel-reason-option');
  50. options.forEach(option => {
  51. option.addEventListener('click', function() {
  52. console.log('事件监听器触发:', this.textContent);
  53. // 移除其他选项的选中状态
  54. options.forEach(opt => opt.classList.remove('selected'));
  55. // 添加当前选项的选中状态
  56. this.classList.add('selected');
  57. });
  58. });
  59. </script>
  60. </body>
  61. </html>