No Description

alipayRedEnvelopes.html 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="yes" name="apple-mobile-web-app-capable">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
  7. <link rel="stylesheet" type="text/css" href="../common/reset.css"/>
  8. <script type="text/javascript" src="../common/jquery-2.1.0.js"></script>
  9. <title>支付宝红包</title>
  10. <script type="text/javascript">
  11. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  12. window.onresize = function(){
  13. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  14. }
  15. </script>
  16. <style type="text/css">
  17. body{
  18. width: 100%;min-height: 100vh;background: #FFC495;
  19. }
  20. .container{
  21. background: url(img/alipayBg.png) no-repeat;
  22. background-size:100% ;
  23. height:11.01rem;
  24. width: 100%;
  25. position: relative;
  26. }
  27. .searchCode{
  28. position: absolute;
  29. font-size:0.22rem;
  30. color:rgba(255,255,255,1);
  31. line-height:0.3rem;
  32. letter-spacing:0.02rem;
  33. top: 2.42rem;
  34. left: 0;
  35. right: 0;
  36. margin: auto;
  37. text-align: center;
  38. }
  39. .openAlipayButton{
  40. width: 2.1rem;
  41. height: 0.54rem;
  42. background: url(img/alipayButton.png) no-repeat;
  43. background-size:100% ;
  44. position: absolute;
  45. top: 4.3rem;
  46. left: 0;
  47. right: 0;
  48. margin: auto;
  49. border: none;
  50. }
  51. #copy_1,#copy_2{
  52. position: absolute;
  53. left: -1000rem;
  54. }
  55. .alert-info {
  56. position: fixed;
  57. top: 3.3rem;
  58. right: 0;
  59. left: 0;
  60. bottom: 0;
  61. text-align: center;
  62. }
  63. .alert-info p {
  64. display: inline-block;
  65. height: 0.38rem;
  66. color: #fff;
  67. font-size: 0.14rem;
  68. line-height: 0.38rem;
  69. padding: 0 0.10rem;
  70. background-color: rgba(0, 0, 0, 0.7);
  71. border-radius: 5px;
  72. }
  73. </style>
  74. </head>
  75. <body>
  76. <input id="copy_1" type="text" readOnly="true" value=""/>
  77. <div id="copy_2"></div>
  78. <div class="container">
  79. <div class="searchCode">627364862</div>
  80. <button class="openAlipayButton" onclick="copyEvent()"></button>
  81. </div>
  82. <div class="alert-info" style="display: none;">
  83. <!-- tip提示,3s后消失 -->
  84. <p></p>
  85. </div>
  86. </body>
  87. </html>
  88. <script type="text/javascript">
  89. function showMsg(msg) {
  90. var msgBox = document.getElementsByClassName('alert-info')[0];
  91. msgBox.children[0].innerText = msg;
  92. msgBox.style.display="block";
  93. setTimeout(function() {
  94. msgBox.style.display="none";
  95. }, 1500);
  96. }
  97. function copyEvent () {
  98. var data='627364862';
  99. copy_2.innerHTML = data;
  100. copy_1.value = data;
  101. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  102. //区分iPhone设备
  103. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  104. var Url2=document.getElementById("copy_2");//要复制文字的节点
  105. var range = document.createRange();
  106. // 选中需要复制的节点
  107. range.selectNode(Url2);
  108. // 执行选中元素
  109. window.getSelection().addRange(range);
  110. // 执行 copy 操作
  111. var successful = document.execCommand('copy');
  112. // 移除选中的元素
  113. window.getSelection().removeAllRanges();
  114. }else{
  115. var Url2=document.getElementById("copy_1");//要复制文字的节点
  116. Url2.select(); // 选择对象
  117. document.execCommand("Copy"); // 执行浏览器复制命令
  118. }
  119. showMsg('复制成功,打来支付宝领取!')//toast
  120. }
  121. </script>