Нет описания

520.html 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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>520</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: #f9a7b6;}
  18. .container{width: 100%;min-height: 100vh;background: url(img/520bg.png) no-repeat;background-size:100% ;}
  19. .button{
  20. display:block;width:2.6rem;height: 0.9rem;background: url(img/520button.png) no-repeat;background-size:100% ;position: absolute;left: 0;right: 0;top: 4rem;margin: auto;}
  21. .con{
  22. width: 80%;
  23. background: #fff;
  24. position: absolute;
  25. top: 5rem;
  26. left: 0;
  27. right: 0;
  28. margin: auto;
  29. padding: 0.15rem;
  30. box-sizing: border-box;
  31. border-radius: 0.1rem;
  32. border: 0.02rem solid #fbc494;
  33. font-size: 0.12rem;
  34. line-height: 0.2rem;
  35. color: #333;
  36. min-height: 1.5rem;
  37. }
  38. .con .copyButton{
  39. width: 1rem;
  40. height: 0.3rem;
  41. background: #f42a77;
  42. color: #fff;
  43. display: block;
  44. margin: 0.2rem auto 0;
  45. font-size: 0.14rem;
  46. border-radius: 0.3rem;
  47. }
  48. #taokouling{
  49. display: block;
  50. min-height: 0.6rem;
  51. }
  52. #copy_1,#copy_2{
  53. position: absolute;
  54. left: -1000rem;
  55. }
  56. .alert-info {
  57. position: absolute;
  58. top: 1.74rem;
  59. right: 0;
  60. left: 0;
  61. bottom: 0;
  62. text-align: center;
  63. }
  64. .alert-info p {
  65. display: inline-block;
  66. height: 0.38rem;
  67. color: #fff;
  68. font-size: 0.14rem;
  69. line-height: 0.38rem;
  70. padding: 0 0.10rem;
  71. background-color: rgba(0, 0, 0, 0.7);
  72. border-radius: 5px;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <div class="container">
  78. <input id="copy_1" type="text" readOnly="true" value=""/>
  79. <div id="copy_2"></div>
  80. <button class="button" onclick="toTaobao()"></button>
  81. <div class="con">
  82. <text id="taokouling"></text>
  83. <button class="copyButton" onclick="copyPassword()">复制信息</button>
  84. </div>
  85. </div>
  86. <div class="alert-info" style="display: none;">
  87. <!-- tip提示,3s后消失 -->
  88. <p></p>
  89. </div>
  90. </body>
  91. </html>
  92. <script type="text/javascript">
  93. var token=''
  94. var tbUrl=''
  95. $().ready(function () {
  96. getToken()
  97. })
  98. // 获取token
  99. function getToken() {
  100. var param = {
  101. "js_callback" : "callbackLogin"
  102. };
  103. param = JSON.stringify(param)
  104. try {
  105. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  106. window.webkit.messageHandlers.app_h5_login.postMessage(param);
  107. }
  108. if (navigator.userAgent.match(/android/i)) {
  109. obj4H5.app_h5_login(param);
  110. }
  111. } catch (e) {
  112. // token='4f422467a11afa2cedaa593686f9b1d4257657'
  113. // todayTbkPassword()
  114. }
  115. }
  116. function callbackLogin(data) {//app token 回调
  117. var data = JSON.parse(data); //上线时添加
  118. token=data.token; //上线时添加
  119. if(token) {
  120. todayTbkPassword()
  121. }
  122. }
  123. //获取淘口令
  124. function todayTbkPassword(type) {
  125. if(token) {
  126. $.ajax({
  127. type: "post",
  128. url: "/api/v2/adzone/double12taoToken",
  129. typeData: 'json',
  130. headers:{
  131. token:token
  132. },
  133. success: function (res) {
  134. if (res && res.errno == 0) {
  135. var tkl=res.rst.data.wenan
  136. tbUrl=res.rst.data.m_url
  137. $("#taokouling").text(tkl);
  138. }else {
  139. showMsg(res.err)
  140. }
  141. }
  142. });
  143. }else {
  144. getToken();
  145. }
  146. }
  147. // 复制文字
  148. function copyPassword() {
  149. if(token) {
  150. var data = document.getElementById("taokouling").innerHTML;
  151. copy_2.innerHTML = data;
  152. copy_1.value = data;
  153. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  154. //区分iPhone设备
  155. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  156. var Url2 = document.getElementById("copy_2");//要复制文字的节点
  157. var range = document.createRange();
  158. // 选中需要复制的节点
  159. range.selectNode(Url2);
  160. // 执行选中元素
  161. window.getSelection().addRange(range);
  162. // 执行 copy 操作
  163. var successful = document.execCommand('copy');
  164. // 移除选中的元素
  165. window.getSelection().removeAllRanges();
  166. } else {
  167. var Url2 = document.getElementById("copy_1");//要复制文字的节点
  168. Url2.select(); // 选择对象
  169. document.execCommand("Copy"); // 执行浏览器复制命令
  170. }
  171. showMsg('复制成功')
  172. }else {
  173. getToken()
  174. }
  175. }
  176. // 打开淘宝
  177. function toTaobao() {
  178. if(token) {
  179. var param = {
  180. "taobaoUrl" : tbUrl,//淘宝链接
  181. }
  182. param = JSON.stringify(param)
  183. try {
  184. if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
  185. window.webkit.messageHandlers.app_h5_open_taobao_url.postMessage(param);
  186. }
  187. if(navigator.userAgent.match(/android/i)){
  188. obj4H5.app_h5_open_taobao_url(param);
  189. }
  190. } catch (error) {
  191. }
  192. }else {
  193. getToken()
  194. }
  195. }
  196. function showMsg(msg) {
  197. //弹框
  198. var msgBox = document.getElementsByClassName('alert-info')[0];
  199. msgBox.children[0].innerText = msg;
  200. msgBox.style.display="block";
  201. setTimeout(function() {
  202. msgBox.style.display="none";
  203. }, 1500);
  204. }
  205. </script>