Aucune description

index03.html 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. <title>淘宝红包</title>
  8. <link rel="stylesheet" type="text/css" href="public.css"/>
  9. <script type="text/javascript" src="public/jquery-2.1.0.js"></script>
  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{width: 100%;min-height: 100vh;background: #dd3938;}
  18. .container{width: 100%;min-height: 100vh;background: url(https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/guoqingBgRedEnvelopes.png) no-repeat;background-size:100% ;}
  19. button{display:block;width:1.735rem;height: 0.4rem;background: url(https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/guoqing/bg_button_index03.png) no-repeat;background-size:100% ;position: absolute;left: 0;right: 0;top: 3.7rem;margin: auto;}
  20. #copy_1,#copy_2,#taokouling{
  21. position: absolute;
  22. left: -1000rem;
  23. }
  24. .alert-info {
  25. position: absolute;
  26. top: 1.74rem;
  27. right: 0;
  28. left: 0;
  29. bottom: 0;
  30. text-align: center;
  31. }
  32. .alert-info p {
  33. display: inline-block;
  34. height: 0.38rem;
  35. color: #fff;
  36. font-size: 0.14rem;
  37. line-height: 0.38rem;
  38. padding: 0 0.10rem;
  39. background-color: rgba(0, 0, 0, 0.7);
  40. border-radius: 5px;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="container">
  46. <input id="copy_1" type="text" readOnly="true" value=""/>
  47. <div id="copy_2"></div>
  48. <text id="taokouling">¥6pJfnNwEQ¥</text>
  49. <button class="button" onclick="copyPassword()"></button>
  50. </div>
  51. <div class="alert-info" style="display: none;">
  52. <!-- tip提示,3s后消失 -->
  53. <p></p>
  54. </div>
  55. </body>
  56. </html>
  57. <script type="text/javascript">
  58. var tkl = '¥6pJfnNwEQ¥';
  59. $().ready(function() {
  60. todayTbkPassword()
  61. })
  62. //获取淘口令
  63. function todayTbkPassword () {
  64. $.ajax({
  65. type:"post",
  66. url:"/api/v2/goods/todayTbkPassword",
  67. typeData:'json',
  68. success: function (res){
  69. if(res && res.errno == 0){
  70. if(res.rst.password){
  71. tkl = res.rst.password;
  72. }
  73. }
  74. $("#taokouling").text(tkl);
  75. }
  76. });
  77. }
  78. function copyPassword() {
  79. var data=document.getElementById("taokouling").innerHTML;
  80. copy_2.innerHTML = data;
  81. copy_1.value = data;
  82. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  83. //区分iPhone设备
  84. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  85. var Url2=document.getElementById("copy_2");//要复制文字的节点
  86. var range = document.createRange();
  87. // 选中需要复制的节点
  88. range.selectNode(Url2);
  89. // 执行选中元素
  90. window.getSelection().addRange(range);
  91. // 执行 copy 操作
  92. var successful = document.execCommand('copy');
  93. // 移除选中的元素
  94. window.getSelection().removeAllRanges();
  95. }else{
  96. var Url2=document.getElementById("copy_1");//要复制文字的节点
  97. Url2.select(); // 选择对象
  98. document.execCommand("Copy"); // 执行浏览器复制命令
  99. }
  100. showMsg('复制成功')
  101. }
  102. //提示弹框
  103. function showMsg(msg) {
  104. var msgBox = $('.alert-info');
  105. msgBox.children('p').text(msg);
  106. msgBox.show();
  107. setTimeout(function() {
  108. msgBox.hide();
  109. }, 3000);
  110. }
  111. </script>